<!--FUNCTION FOR DIV SHOW HIDE-->
// for detecting browser 
var browser=navigator.appName;
var b_version=navigator.appVersion;
 var version=parseFloat(b_version);

function showAnswer(val){
 //alert(document.getElementById(val).style.display);
 var anc='anc_'+val;
 var txt='txt_'+val;
 for(i=1;i<=6;i++)
 {
 	document.getElementById('txt_'+i).style.display='none';
	var id=document.getElementById('anc_'+i);
	if ((browser=="Microsoft Internet Explorer")&& (version>=4))
     {
      id.setAttribute('className','');
     }
     else
     {
      id.setAttribute("class", "");
     }
	
 }

 if(document.getElementById(txt).style.display == 'none')
  {
 	var id=document.getElementById(txt);
	id.style.display='';
	var id=document.getElementById(anc);
	if ((browser=="Microsoft Internet Explorer")&& (version>=4))
     {
      id.setAttribute('className','active');
     }
     else
     {
      id.setAttribute("class", "active");
     }
 }
 else 
 document.getElementById(txt).style.display='none';
}


<!--END FUNCTION FOR DIV SHOW HIDE-->

//function for checking form validations
function validation()
{
	id=document.getElementById('buy');
	h_id='hid_'+'buy'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div1').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div1').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('spend');
	h_id='hid_'+'spend'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div2').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div2').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	var amt = document.getElementById('spend').value;	
	/*if(!isCurrency(amt))
		{	
			document.getElementById(h_id).style.display='';
			document.getElementById(h_id).innerHTML='Amount entered wrongly.';
			id.focus();
			return false;
		}
		*/
		if(isCurrency(id.value)==false)
		{
			if ((browser=="Microsoft Internet Explorer")&& (version>=4))
			 {
				 document.getElementById('div2').setAttribute('className','div_active');
			 }
			 else
			 {
				document.getElementById('div2').setAttribute("class", "div_active");
			 }	
			document.getElementById(h_id).style.display='';
			document.getElementById(h_id).innerHTML='Please enter the value in dollars';
			id.focus();
			return false;
		} 
		else 
		{ 
			document.getElementById(h_id).style.display='none';
		}

	
	id=document.getElementById('email');
	var email=document.getElementById('email').value;
	h_id='hid_'+'email'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div3').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div3').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter email address.';
		id.focus();
		return false;
	}
	
	if(echeck(id.value)!=true)
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div3').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div3').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML=echeck(id.value);
		id.focus();
		return false;
	}
	send_mail();
	return true;
	
}

//function for checking email validation
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return "Please enter a valid e-mail address.";
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return "Please enter a valid e-mail address."
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return "Please enter a valid e-mail address.";	}
	
	 if (str.indexOf(at,(lat+1))!=-1){
		return "Please enter a valid e-mail address.";	 }
	
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return "Please enter a valid e-mail address.";	 }
	
	 if (str.indexOf(dot,(lat+2))==-1){
		return "Please enter a valid e-mail address.";	 }
	
	 if (str.indexOf(" ")!=-1){
		return "Please enter a valid e-mail address.";	 
	}
	
	 return true;					
}

//function for submitting form through ajax
function send_mail()
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var buy=document.getElementById('buy').value;
	var spend=document.getElementById('spend').value;
	var email=document.getElementById('email').value;
	
	var url="ajax/sendmail.php";
	url=url+"?buy="+buy;
	url=url+"&spend="+spend;
	url=url+"&email="+email;
	url=url+"&sid="+Math.random();
	//alert(url);
	//alert(url);
	xmlHttp.open("get",url,true);
	//xmlHttp.send(null);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			
			if(xmlHttp.responseText != '')
			{
				window.location = 'http://www.asyus.com/thank-you.php';
				document.getElementById('main3col').style.display='';
				document.getElementById('main3col').innerHTML=xmlHttp.responseText;
								
			}
		}
	}
}


function show_content(divid1,divid2)
{
	document.getElementById(divid1).style.display='none';
	document.getElementById(divid2).style.display='';

}

//function for changing active div class 
function select_div(id1,id2,id3)
{
	var id1 = document.getElementById(id1);
	var id2 = document.getElementById(id2);
	var id3 = document.getElementById(id3);
	
	if ((browser=="Microsoft Internet Explorer")&& (version>=4))
     {
      id1.setAttribute('className','div_active');
	  id2.setAttribute('className','width300');
	  id3.setAttribute('className','width300');
     }
     else
     {
      id1.setAttribute("class", "div_active");
	  id2.setAttribute("class", "width300");
	  id3.setAttribute("class", "width300");
     }	
	return true;
}

function isCurrency(f)
{

	var nNum = 0;			
	var nDollarSign = 0;	
	var nDecimal = 0;		
	var nCommas = 0;		
	var txtLen;				
	var xTxt;				
	var sDollarVal;			
	var bComma;				
	var decPos;				
	var nNumCount = 0;		
	var i;					
	var x;					

	xTxt = f;
	txtLen = xTxt.length
	
	for(i = 0; i < txtLen; i++)
	{
		x = xTxt.substr(i, 1);
		if(x == "$")

			nDollarSign = nDollarSign + 1; 
		else if(x == ".")
			nDecimal = nDecimal + 1; 
		else if(x == ",")
			nCommas = nCommas + 1; 
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; 
		else
		{
			//alert("error");
			return false;
		} 

	} 

	if(nDollarSign > 1)
	{
		//alert("ERROR! \n\nYou have entered more then one dollar sign!\nPlease only enter one!");
		return false;

	} 
	if(nDecimal > 1)
	{
		//alert("ERROR! \n\nYou have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} 

	if(nDollarSign == 1)
	{
		if(xTxt.indexOf("$") != 0)
		{
			//alert("ERROR!  \n\nThe dollar sign you entered is not in the correct position!");
			return false;
		} 
	}
	if(nDecimal == 1)

	{
		decPos = (txtLen - 1) - xTxt.indexOf(".");
		if(decPos > 2)
		{
			//alert("ERROR! \n\nThe decimal point you entered is not in the correct position!");
			return false;
		} 
	} 
	if(nCommas == 0)
	{
		return true;
	}
	else
	{
		nNum = nNum - decPos;
	
		if(xTxt.indexOf("$", 0) == 0)
			sDollarVal = xTxt.substr(1, (nNum + nCommas));
		else
			sDollarVal = xTxt.substr(0, (nNum + nCommas));

		if(sDollarVal.lastIndexOf("0", 0) == 0 )
		{
			//alert("ERROR! \n\nYou cannot start the dollar amount out with a zero!");
			return false;
		}
		else if(sDollarVal.lastIndexOf(",", 0) == 0)
		{
			alert("ERROR! \n\nYou cannot start the dollar amount out with a comma!");
			return false;
		}
		else if(sDollarVal.indexOf(",", (sDollarVal.length - 1)) == (sDollarVal.length - 1))
		{
			alert("ERROR! \n\nYou cannot end the dollar amount with a comma!");
			return false;
		}
		else
		{
			bComma = false;
			for(i = 0; i < sDollarVal.length; i++)
			{
				x = sDollarVal.substr(i, 1);
				if(parseInt(x) >= 0 || parseInt(x) <= 9)
				{
					nNumCount = nNumCount + 1;
				if(nNumCount > 3)
				{
					alert("ERROR! \n\nYou have a mis-placed comma!");
					return false;
					} 
				}
				else
				{
					if(nNumCount != 3 && bComma)
					{
						alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;

					} 

					nNumCount = 0;
					bComma = true;

				} 

			} 

			if(nNumCount != 3 && bComma)
			{
				//alert("ERROR! \n\nYou have a mis-placed comma!");
				return false;
			} 
		} 
	} 

	return true;

}

///////////////////////////////////////functions used for Admin Panel/////////////////////////////////////////////////////////////////////////////////

//function for checking validations for admin login forms
function CheckAdminLogin()
{
 	if(document.adminLoginForm.username.value == "")
 	{
       document.getElementById("adminid").style.display='';
       document.getElementById("adminid").innerHTML = 'Please Enter User Name';
       document.adminLoginForm.username.focus();
   return false;
   }
   else if(document.adminLoginForm.password.value == "")
   {
        document.getElementById("passid").style.display='';
	    document.getElementById("passid").innerHTML = 'Please Enter Password';
		document.adminLoginForm.password.focus();
   return false;
   }
   else
   return true;
 }

//function for validating change password form
function validate_form()
{
	id=document.getElementById('pass');
	h_id='hid_'+'pass'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please Enter Password';
		id.focus();
		return false;
	}
	
	id=document.getElementById('cpass');
	h_id='hid_'+'cpass'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please Confirm your Password';
		id.focus();
		return false;
	}
	
	if(document.getElementById('cpass').value != document.getElementById('pass').value)
   {
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Password and Confirm Password must be same.';
		id.focus();
		return false;
   }
	  return true;
	
}

//function for validating Report page
function validate_report()
{
	id=document.getElementById('caseid');
	h_id='hid_'+'caseid'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('cus_email');
	h_id='hid_'+'cus_email'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(echeck(id.value)!=true)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML=echeck(id.value);
		id.focus();
		return false;
	}
	
	id=document.getElementById('cus_name');
	h_id='hid_'+'cus_name'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id1=document.getElementById('pro_name');
	id2=document.getElementById('pro_model');
	h_id1='hid_'+'pro_name'; 
	h_id2='hid_'+'pro_model'; 
	document.getElementById(h_id1).style.display='';
	document.getElementById(h_id1).innerHTML='';
	document.getElementById(h_id2).style.display='';
	document.getElementById(h_id2).innerHTML='';
	
	if(id1.value !='' && id2.value !='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='You can enter either Product Name or Product Model No.';
		id.focus();
		return false;
	}
	if(id1.value =='' && id2.value =='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='Please enter either Product Name or Product Model No.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('pro_detail');
	h_id='hid_'+'pro_detail'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id1=document.getElementById('prod_image1');
	id2=document.getElementById('prod_image2');
	h_id1='hid_'+'prod_image1'; 
	h_id2='hid_'+'prod_image2';
	document.getElementById(h_id1).style.display='';
	document.getElementById(h_id1).innerHTML='';
	document.getElementById(h_id2).style.display='';
	document.getElementById(h_id2).innerHTML='';
	if(id1.value !='' && id2.value !='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='You can enter either Product Image or Image URL';
		id.focus();
		return false;
	}
	if(id1.value =='' && id2.value =='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='Please enter either Product Image or Image URL';
		id.focus();
		return false;
	}
	
	id=document.getElementById('budget');
	h_id='hid_'+'budget'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(isCurrency(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter the value in dollars';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}
	
	id=document.getElementById('price');
	h_id='hid_'+'price'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(isCurrency(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter the value in dollars';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}
	
		
	id=document.getElementById('savings');
	h_id='hid_'+'savings'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(isCurrency(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter the value in dollars';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}
		
	id=document.getElementById('store_link');
	h_id='hid_'+'store_link'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('review_1');
	h_id='hid_'+'review_1'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	return true;		
}

//Function to check numeric values only
function IsNumeric(strString)
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

//function for rating
function rate(id,r_id)
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="../ajax/give_rating.php";
	url=url+"?rate_id="+id;
	url=url+"&rew_id="+r_id;
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true);
	//alert(url);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.responseText != '')
			{
				//alert(xmlHttp.responseText);
				if(r_id == 'rew_1')
				{
					document.getElementById('r_1').style.display='';
					document.getElementById('r_1').innerHTML='<div class="rating-txt">'+xmlHttp.responseText+'/5</div>';
					document.getElementById('review_one').value=xmlHttp.responseText;
					
					document.getElementById('rating_1').style.display='none';
					document.getElementById('rat_1').style.display='';
				}
				if(r_id == 'rew_2')
				{
					document.getElementById('r_2').style.display='';
					document.getElementById('r_2').innerHTML='<div class="rating-txt">'+xmlHttp.responseText+'/5</div>';
					document.getElementById('review_two').value=xmlHttp.responseText;
					document.getElementById('rat_2').style.display='';
					document.getElementById('rating_2').style.display='none';
				}
				if(r_id == 'rew_3')
				{
					document.getElementById('r_3').style.display='';
					document.getElementById('r_3').innerHTML='<div class="rating-txt">'+xmlHttp.responseText+'/5</div>';
					document.getElementById('review_three').value=xmlHttp.responseText;
					document.getElementById('rat_3').style.display='';
					document.getElementById('rating_3').style.display='none';
				}
			}
		}
	}
}

//function for getting pagination
function reload_complete_request(current_page, sort_by, sort_type)
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	//alert(current_page);
	if(current_page) 
	{ 
		document.getElementById('current_page').value=current_page; 
	}
	else 
	{ 
		current_page=document.getElementById('current_page').value; 
	}
	if(sort_type) 
	{ 
		document.getElementById('sort_type').value=sort_type; 
	}
	else 
	{ 
		sort_type=document.getElementById('sort_type').value; 
	}
	if(sort_by) 
	{ 
		document.getElementById('sort_by').value=sort_by; 
	}
	else 
	{ 
		sort_by=document.getElementById('sort_by').value; 
	}
	var search_str;
	search_str=document.getElementById('search_hid').value;
	//alert(current_page);
	
	 
	
	var url="../ajax/ajax_completed_request.php";
	url=url+"?model_id=''";
	url=url+"&current_page="+current_page;
	url=url+"&sort_by="+sort_by;
	url=url+"&sort_type="+sort_type;
	url=url+"&search_str="+search_str;
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.responseText != '')
			{
				//alert(xmlHttp.responseText);
				document.getElementById('main_listing_div').innerHTML='';
				document.getElementById('main_listing_div').innerHTML=xmlHttp.responseText;
			}
		}
	}

}

//function for displaying rating div
function show_rate_again(did)
{
	document.getElementById(did).style.display='';
	
}
<!--FUNCTION FOR DIV SHOW HIDE-->
// for detecting browser 
var browser=navigator.appName;
var b_version=navigator.appVersion;
 var version=parseFloat(b_version);

function showAnswer(val){
 //alert(document.getElementById(val).style.display);
 var anc='anc_'+val;
 var txt='txt_'+val;
 for(i=1;i<=6;i++)
 {
 	document.getElementById('txt_'+i).style.display='none';
	var id=document.getElementById('anc_'+i);
	if ((browser=="Microsoft Internet Explorer")&& (version>=4))
     {
      id.setAttribute('className','');
     }
     else
     {
      id.setAttribute("class", "");
     }
	
 }

 if(document.getElementById(txt).style.display == 'none')
  {
 	var id=document.getElementById(txt);
	id.style.display='';
	var id=document.getElementById(anc);
	if ((browser=="Microsoft Internet Explorer")&& (version>=4))
     {
      id.setAttribute('className','active');
     }
     else
     {
      id.setAttribute("class", "active");
     }
 }
 else 
 document.getElementById(txt).style.display='none';
}


<!--END FUNCTION FOR DIV SHOW HIDE-->

//function for checking form validations
function validation()
{
	id=document.getElementById('buy');
	h_id='hid_'+'buy'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div1').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div1').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('spend');
	h_id='hid_'+'spend'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div2').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div2').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	var amt = document.getElementById('spend').value;	
	/*if(!isCurrency(amt))
		{	
			document.getElementById(h_id).style.display='';
			document.getElementById(h_id).innerHTML='Amount entered wrongly.';
			id.focus();
			return false;
		}
		*/
		if(isCurrency(id.value)==false)
		{
			if ((browser=="Microsoft Internet Explorer")&& (version>=4))
			 {
				 document.getElementById('div2').setAttribute('className','div_active');
			 }
			 else
			 {
				document.getElementById('div2').setAttribute("class", "div_active");
			 }	
			document.getElementById(h_id).style.display='';
			document.getElementById(h_id).innerHTML='Please enter the value in dollars';
			id.focus();
			return false;
		} 
		else 
		{ 
			document.getElementById(h_id).style.display='none';
		}

	
	id=document.getElementById('email');
	var email=document.getElementById('email').value;
	h_id='hid_'+'email'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div3').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div3').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter email address.';
		id.focus();
		return false;
	}
	
	if(echeck(id.value)!=true)
	{
		if ((browser=="Microsoft Internet Explorer")&& (version>=4))
		 {
		 	 document.getElementById('div3').setAttribute('className','div_active');
		 }
		 else
		 {
		  	document.getElementById('div3').setAttribute("class", "div_active");
		 }	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML=echeck(id.value);
		id.focus();
		return false;
	}
	send_mail();
	return true;
	
}

//function for checking email validation
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return "Please enter a valid e-mail address.";
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return "Please enter a valid e-mail address."
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return "Please enter a valid e-mail address.";	}
	
	 if (str.indexOf(at,(lat+1))!=-1){
		return "Please enter a valid e-mail address.";	 }
	
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return "Please enter a valid e-mail address.";	 }
	
	 if (str.indexOf(dot,(lat+2))==-1){
		return "Please enter a valid e-mail address.";	 }
	
	 if (str.indexOf(" ")!=-1){
		return "Please enter a valid e-mail address.";	 
	}
	
	 return true;					
}

//function for submitting form through ajax
function send_mail()
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var buy=document.getElementById('buy').value;
	var spend=document.getElementById('spend').value;
	var email=document.getElementById('email').value;
	
	var url="ajax/sendmail.php";
	url=url+"?buy="+buy;
	url=url+"&spend="+spend;
	url=url+"&email="+email;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("get",url,true);
	//xmlHttp.send(null);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			
			if(xmlHttp.responseText != '')
			{
				document.getElementById('main3col').style.display='';
				document.getElementById('main3col').innerHTML=xmlHttp.responseText;
								
			}
		}
	}
}


function show_content(divid1,divid2)
{
	document.getElementById(divid1).style.display='none';
	document.getElementById(divid2).style.display='';

}

//function for changing active div class 
function select_div(id1,id2,id3)
{
	var id1 = document.getElementById(id1);
	var id2 = document.getElementById(id2);
	var id3 = document.getElementById(id3);
	
	if ((browser=="Microsoft Internet Explorer")&& (version>=4))
     {
      id1.setAttribute('className','div_active');
	  id2.setAttribute('className','width300');
	  id3.setAttribute('className','width300');
     }
     else
     {
      id1.setAttribute("class", "div_active");
	  id2.setAttribute("class", "width300");
	  id3.setAttribute("class", "width300");
     }	
	return true;
}

function isCurrency(f)
{

	var nNum = 0;			
	var nDollarSign = 0;	
	var nDecimal = 0;		
	var nCommas = 0;		
	var txtLen;				
	var xTxt;				
	var sDollarVal;			
	var bComma;				
	var decPos;				
	var nNumCount = 0;		
	var i;					
	var x;					

	xTxt = f;
	txtLen = xTxt.length
	
	for(i = 0; i < txtLen; i++)
	{
		x = xTxt.substr(i, 1);
		if(x == "$")

			nDollarSign = nDollarSign + 1; 
		else if(x == ".")
			nDecimal = nDecimal + 1; 
		else if(x == ",")
			nCommas = nCommas + 1; 
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; 
		else
		{
			//alert("error");
			return false;
		} 

	} 

	if(nDollarSign > 1)
	{
		//alert("ERROR! \n\nYou have entered more then one dollar sign!\nPlease only enter one!");
		return false;

	} 
	if(nDecimal > 1)
	{
		//alert("ERROR! \n\nYou have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} 

	if(nDollarSign == 1)
	{
		if(xTxt.indexOf("$") != 0)
		{
			//alert("ERROR!  \n\nThe dollar sign you entered is not in the correct position!");
			return false;
		} 
	}
	if(nDecimal == 1)

	{
		decPos = (txtLen - 1) - xTxt.indexOf(".");
		if(decPos > 2)
		{
			//alert("ERROR! \n\nThe decimal point you entered is not in the correct position!");
			return false;
		} 
	} 
	if(nCommas == 0)
	{
		return true;
	}
	else
	{
		nNum = nNum - decPos;
	
		if(xTxt.indexOf("$", 0) == 0)
			sDollarVal = xTxt.substr(1, (nNum + nCommas));
		else
			sDollarVal = xTxt.substr(0, (nNum + nCommas));

		if(sDollarVal.lastIndexOf("0", 0) == 0 )
		{
			//alert("ERROR! \n\nYou cannot start the dollar amount out with a zero!");
			return false;
		}
		else if(sDollarVal.lastIndexOf(",", 0) == 0)
		{
			alert("ERROR! \n\nYou cannot start the dollar amount out with a comma!");
			return false;
		}
		else if(sDollarVal.indexOf(",", (sDollarVal.length - 1)) == (sDollarVal.length - 1))
		{
			alert("ERROR! \n\nYou cannot end the dollar amount with a comma!");
			return false;
		}
		else
		{
			bComma = false;
			for(i = 0; i < sDollarVal.length; i++)
			{
				x = sDollarVal.substr(i, 1);
				if(parseInt(x) >= 0 || parseInt(x) <= 9)
				{
					nNumCount = nNumCount + 1;
				if(nNumCount > 3)
				{
					alert("ERROR! \n\nYou have a mis-placed comma!");
					return false;
					} 
				}
				else
				{
					if(nNumCount != 3 && bComma)
					{
						alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;

					} 

					nNumCount = 0;
					bComma = true;

				} 

			} 

			if(nNumCount != 3 && bComma)
			{
				//alert("ERROR! \n\nYou have a mis-placed comma!");
				return false;
			} 
		} 
	} 

	return true;

}

///////////////////////////////////////functions used for Admin Panel/////////////////////////////////////////////////////////////////////////////////

//function for checking validations for admin login forms
function CheckAdminLogin()
{
 	if(document.adminLoginForm.username.value == "")
 	{
       document.getElementById("adminid").style.display='';
       document.getElementById("adminid").innerHTML = 'Please Enter User Name';
       document.adminLoginForm.username.focus();
   return false;
   }
   else if(document.adminLoginForm.password.value == "")
   {
        document.getElementById("passid").style.display='';
	    document.getElementById("passid").innerHTML = 'Please Enter Password';
		document.adminLoginForm.password.focus();
   return false;
   }
   else
   return true;
 }

//function for validating change password form
function validate_form()
{
	id=document.getElementById('pass');
	h_id='hid_'+'pass'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please Enter Password';
		id.focus();
		return false;
	}
	
	id=document.getElementById('cpass');
	h_id='hid_'+'cpass'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please Confirm your Password';
		id.focus();
		return false;
	}
	
	if(document.getElementById('cpass').value != document.getElementById('pass').value)
   {
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Password and Confirm Password must be same.';
		id.focus();
		return false;
   }
	  return true;
	
}

//function for validating Report page
function validate_report()
{
	id=document.getElementById('caseid');
	h_id='hid_'+'caseid'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('cus_email');
	h_id='hid_'+'cus_email'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(echeck(id.value)!=true)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML=echeck(id.value);
		id.focus();
		return false;
	}
	
	id=document.getElementById('cus_name');
	h_id='hid_'+'cus_name'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id1=document.getElementById('pro_name');
	id2=document.getElementById('pro_model');
	h_id1='hid_'+'pro_name'; 
	h_id2='hid_'+'pro_model'; 
	document.getElementById(h_id1).style.display='';
	document.getElementById(h_id1).innerHTML='';
	document.getElementById(h_id2).style.display='';
	document.getElementById(h_id2).innerHTML='';
	
	if(id1.value !='' && id2.value !='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='You can enter either Product Name or Product Model No.';
		id.focus();
		return false;
	}
	if(id1.value =='' && id2.value =='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='Please enter either Product Name or Product Model No.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('pro_detail');
	h_id='hid_'+'pro_detail'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id1=document.getElementById('prod_image1');
	id2=document.getElementById('prod_image2');
	h_id1='hid_'+'prod_image1'; 
	h_id2='hid_'+'prod_image2';
	document.getElementById(h_id1).style.display='';
	document.getElementById(h_id1).innerHTML='';
	document.getElementById(h_id2).style.display='';
	document.getElementById(h_id2).innerHTML='';
	if(id1.value !='' && id2.value !='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='You can enter either Product Image or Image URL';
		id.focus();
		return false;
	}
	if(id1.value =='' && id2.value =='')
	{
		document.getElementById(h_id1).style.display='';
		document.getElementById(h_id1).innerHTML='Please enter either Product Image or Image URL';
		id.focus();
		return false;
	}
	
	id=document.getElementById('budget');
	h_id='hid_'+'budget'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(isCurrency(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter the value in dollars';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}
	
	id=document.getElementById('price');
	h_id='hid_'+'price'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(isCurrency(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter the value in dollars';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}
	
		
	id=document.getElementById('savings');
	h_id='hid_'+'savings'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	if(isCurrency(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter the value in dollars';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}
		
	id=document.getElementById('store_link');
	h_id='hid_'+'store_link'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	
	id=document.getElementById('review_1');
	h_id='hid_'+'review_1'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please fill in the required field.';
		id.focus();
		return false;
	}
	return true;		
}

//Function to check numeric values only
function IsNumeric(strString)
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

//function for rating
function rate(id,r_id)
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="../ajax/give_rating.php";
	url=url+"?rate_id="+id;
	url=url+"&rew_id="+r_id;
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true);
	//alert(url);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.responseText != '')
			{
				//alert(xmlHttp.responseText);
				if(r_id == 'rew_1')
				{
					document.getElementById('r_1').style.display='';
					document.getElementById('r_1').innerHTML='<div class="rating-txt">'+xmlHttp.responseText+'/5</div>';
					document.getElementById('review_one').value=xmlHttp.responseText;
					
					document.getElementById('rating_1').style.display='none';
					document.getElementById('rat_1').style.display='';
				}
				if(r_id == 'rew_2')
				{
					document.getElementById('r_2').style.display='';
					document.getElementById('r_2').innerHTML='<div class="rating-txt">'+xmlHttp.responseText+'/5</div>';
					document.getElementById('review_two').value=xmlHttp.responseText;
					document.getElementById('rat_2').style.display='';
					document.getElementById('rating_2').style.display='none';
				}
				if(r_id == 'rew_3')
				{
					document.getElementById('r_3').style.display='';
					document.getElementById('r_3').innerHTML='<div class="rating-txt">'+xmlHttp.responseText+'/5</div>';
					document.getElementById('review_three').value=xmlHttp.responseText;
					document.getElementById('rat_3').style.display='';
					document.getElementById('rating_3').style.display='none';
				}
			}
		}
	}
}

//function for getting pagination
function reload_complete_request(current_page, sort_by, sort_type)
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	//alert(current_page);
	if(current_page) 
	{ 
		document.getElementById('current_page').value=current_page; 
	}
	else 
	{ 
		current_page=document.getElementById('current_page').value; 
	}
	if(sort_type) 
	{ 
		document.getElementById('sort_type').value=sort_type; 
	}
	else 
	{ 
		sort_type=document.getElementById('sort_type').value; 
	}
	if(sort_by) 
	{ 
		document.getElementById('sort_by').value=sort_by; 
	}
	else 
	{ 
		sort_by=document.getElementById('sort_by').value; 
	}
	var search_str;
	search_str=document.getElementById('search_hid').value;
	//alert(current_page);
	
	 
	
	var url="../ajax/ajax_completed_request.php";
	url=url+"?model_id=''";
	url=url+"&current_page="+current_page;
	url=url+"&sort_by="+sort_by;
	url=url+"&sort_type="+sort_type;
	url=url+"&search_str="+search_str;
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.responseText != '')
			{
				//alert(xmlHttp.responseText);
				document.getElementById('main_listing_div').innerHTML='';
				document.getElementById('main_listing_div').innerHTML=xmlHttp.responseText;
			}
		}
	}

}

//function for displaying rating div
function show_rate_again(did)
{
	document.getElementById(did).style.display='';
	
}

//function for showing delete div
function show_del_div(del_div)
{
	document.getElementById(del_div).style.display='';
	return false;
}
function close_del_div(del_div)
{
	document.getElementById(del_div).style.display='none';
}

function delete_this(inc_id, report_id)
{
	xmlHttp=check_ajax_support();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="../ajax/delete_report.php";
	url=url+"?report_id="+report_id;
	url=url+"&act=update_report";
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true);
	//xmlHttp.send(null);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",url.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(url);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			if(xmlHttp.responseText != '')
			{
				//alert(xmlHttp.responseText);
				document.getElementById('del_div_'+inc_id).innerHTML=xmlHttp.responseText;
				document.getElementById('del_'+inc_id).focus();
				document.getElementById('del_div_'+inc_id).style.display='';
				fade('row_'+inc_id); 
				fade1('del_'+inc_id);
				var myInterval = setInterval("document.getElementById('row_"+inc_id+"').style.display='none'",3200);
				var myInterval = setInterval("document.getElementById('del_"+inc_id+"').style.display='none'",7200);
				
			}
		}
	}
}

