// JavaScript Document
function val_Emptyddl(ddl,span)
{
	if(document.getElementById(ddl).selectedIndex==0)
	{
		//document.getElementById('ddlCategory').focus();
		document.getElementById(span).innerHTML="Please select Category";		
		return false;
	}
	else
	{
		document.getElementById(span).innerHTML="";
		return true;
	}
	
}

function donor_validation()
{
	if(document.getElementById('ddlDonor').selectedIndex==0)
	{
		document.getElementById('err_donor').innerHTML="Please select Category";
	}
}

function foc_donor()
{
	if(document.getElementById('ddlDonor').selectedIndex == 0)
	{
		document.getElementById('ddlDonor').focus();
		return false;
	}
	return true;
}

function need_validation()
{
	if(document.getElementById('ddlNeed').selectedIndex==0)
	{
		document.getElementById('err_need').innerHTML="Please select Category";
	}
}

function foc_need()
{
	if(document.getElementById('ddlNeed').selectedIndex == 0)
	{
		document.getElementById('ddlNeed').focus();
		return false;
	}
	return true;
}

function prof_search_valid()
{
	if(document.getElementById('profile_id').value == '')
	{
		document.getElementById('err_prof_id').innerHTML ="Please Enter any Profile Id";
		document.getElementById('profile_id').focus();
		return false;
	}
	else 
	{			
			document.getElementById('err_prof_id').innerHTML ="";			
			return true;
			
	}	
}

function profilecheck()
{
		
		document.getElementById('fade').style.display='block';
		showalert('login/lightbox_need.php','','','search','profile_search');
		/*var x= confirm('Are you sure you want to contact this profile');
		if(x)
		{
			window.location.href = "needy.php";
		} */
}

function reset_search()
 {
	 document.getElementById('date_cal').style.display='none';
	 document.getElementById('ddlCategoryin').length=0;
	 document.getElementById('ddlTypein').length=0;
	 document.getElementById('ddlNeedin').length=0;
	 document.getElementById('ddlCountryin').length=0;
	 document.getElementById('ddlStatein').length=0;	 
}

function cal_enable()
{	 
	 if(document.getElementById('checkDate').checked==true)
	 {
		document.getElementById('date_cal').style.display='';
	 }
	 else
	 {
		 document.getElementById('date_cal').style.display='none';
	 }
 }
 
 function name_city(txtCtrl)
  {
  	var v = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'. ";
    var w = "";
    for (i=0; i < txtCtrl.value.length; i++) 
	{
        x = txtCtrl.value.charAt(i);
        if (v.indexOf(x,0) != -1)
        w += x;
    }
    txtCtrl.value = w;
 } 
 
 function val_country(txtControl,msgControl)
 {
		if((document.getElementById(txtControl).selectedIndex) !=0) {
			document.getElementById(msgControl).innerHTML = "";	
			return true;
		}
	
 }
 
 function donint_validation()
 {
		if(document.getElementById('textAbout_n').value=='') 
		{
			document.getElementById('abterror_n').innerHTML = "Please provide Reason";	
			return false;
		}
		else if((document.getElementById('textAbout_n').value.length<10) || (document.getElementById('textAbout_n').value.length>250))
	{
     document.getElementById('abterror_n').innerHTML="";
 	 document.getElementById('abterror_n').innerHTML="Details should be  10 to 250 characters";	
	 return false;
      
 	}
		dbdonate(document.getElementById('loginid').value,document.getElementById('pid').value,document.getElementById('messages').value,document.getElementById('textAbout_n').value,document.getElementById('cattype').value,document.getElementById('fname').value,'payamount_db.php');
		return true;
 }
 
 function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	    catch (e)
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }
	return xmlHttp;
}
 
function viewforum(pageurl,id,limit,pages)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		  alert ("Your browser does not support AJAX!");
		  return;
	} 	  
	var url=pageurl;
	url=url+"?id="+id+"&limit="+limit+"&page="+pages;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=forumPage;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function forumPage()
{
	if (xmlHttp.readyState==4)	
	{			 	
		//alert(xmlHttp.responseText);			
		document.getElementById('forumdiv').innerHTML = xmlHttp.responseText;
	}
}

function mainforum1(pageurl,limit,pages,i,k)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		  alert ("Your browser does not support AJAX!");
		  return;
	} 
	if(k != '') {
		var i = k;
	} else {
		var i = i;	
	}
	var url=pageurl;
	url=url+"?limit="+limit+"&page="+pages+"&i="+i;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=forummain1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function forummain1()
{
	if (xmlHttp.readyState==4)	
	{			 	
		//alert(xmlHttp.responseText);			
		document.getElementById('mainforumdiv').innerHTML = xmlHttp.responseText;
	}
}

function forumthread(pageurl,id,limit,pages,limits,page,l,k)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		  alert ("Your browser does not support AJAX!");
		  return;
	} 	  
	
	var url=pageurl;
	url=url+"?id="+id+"&limit="+limit+"&page="+pages+"&limts="+limits+"&pags="+page+"&l="+l+"&k="+k;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=threadsforum;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function threadsforum()
{
	if (xmlHttp.readyState==4)	
	{			 	
		//alert(xmlHttp.responseText);			
		document.getElementById('threaddiv').innerHTML = xmlHttp.responseText;
	}
}