function validateHeaderLogin()
{
	fieldArray = new Array('dvTxtEmail','dvTxtPassword');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;

	if(document.getElementById('txtEmail').value=='Email Adress')
	{
		document.getElementById('txtEmail').value='';
	}
	if(document.getElementById('txtPassword').value=='Password')
	{
		document.getElementById('txtPassword').value='';
	}

	if (trim(document.getElementById('txtEmail').value) == 0 || trim(document.getElementById('txtEmail').value)=='')
	{				
			setValue('dvTxtEmail','Please Enter Email');
			document.getElementById('txtEmail').value='';			
			txtReturnType = false;
	}else if(!CheckEmail(trim(document.getElementById('txtEmail').value)))
	{
			setValue('dvTxtEmail','Invalid Email');						
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtPassword').value) == 0 || trim(document.getElementById('txtPassword').value)=='')
	{				
			setValue('dvTxtPassword','Please Enter Password');
			document.getElementById('txtPassword').value='';			
			txtReturnType = false;
	}


	return txtReturnType;
}

function txtOnmouse()
{
	if(document.getElementById('txtEmail').value=='Email Address')
	{
		document.getElementById('txtEmail').value='';
	}
}

function txtOnmouseout()
{
	if(document.getElementById('txtEmail').value=='')
	{
		document.getElementById('txtEmail').value='Email Address';
	}
}

function txtOnmousePass()
{
	if(document.getElementById('txtPassword').value=='Password')
	{
		document.getElementById('txtPassword').value='';
	}
}

function txtOnmouseoutPass()
{
	if(document.getElementById('txtPassword').value=='')
	{
		document.getElementById('txtPassword').value='Password';
	}
}

function txtClrOnmouse(id,txtContent)
{
	if(document.getElementById(id).value==txtContent)
	{
		document.getElementById(id).value='';
	}
}

function txtFillOnmouseout(id,txtContent)
{
	if(document.getElementById(id).value=='')
	{
		document.getElementById(id).value= txtContent;
	}
}

function validateTxtfld(id,dvId,txtMsg,compTxt)
{ 
	var txtReturn = true;
	if(document.getElementById(id).value=='' || (compTxt == document.getElementById(id).value))
	{ 
		if(document.getElementById(dvId))
		{
			document.getElementById(dvId).value= txtMsg;
			txtReturn = false;
		}
		else
		{
			txtReturn=false;
			alert(txtMsg);			
		}
	}
	
	return txtReturn;
}

function validateRegistration()
{
	//fieldArray = new Array('dvTxtName','dvTxtSchool','dvTxtzip','txtzip','dvTxtEmailr','dvTxtPass','dvTxtRePass','dvTxtTerm');
	fieldArray = new Array('dvTxtName','dvTxtSchool','dvTxtzip','dvTxtzip','dvTxtEmailr','dvTxtPass');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;

	if (trim(document.getElementById('txtName').value) == 0 || trim(document.getElementById('txtName').value)=='')
	{				
			setValue('dvTxtName','Please Enter Name');
			document.getElementById('txtName').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtSchool').value) == 0 || trim(document.getElementById('txtSchool').value)=='')
	{				
			setValue('dvTxtSchool','Please Enter School');
			document.getElementById('txtSchool').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtzip').value) == 0 || trim(document.getElementById('txtzip').value)=='')
	{				
			setValue('dvTxtzip','Please Enter Zipcode');
			document.getElementById('txtzip').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtEmailr').value) == 0 || trim(document.getElementById('txtEmailr').value)=='')
	{				
			setValue('dvTxtEmailr','Please Enter Email');
			document.getElementById('txtEmailr').value='';			
			txtReturnType = false;
	}
	else if(!CheckEmail(trim(document.getElementById('txtEmailr').value)))
	{
			setValue('dvTxtEmailr','Invalid Email Address');						
			txtReturnType = false;
	}


	if (trim(document.getElementById('txtPass').value) == 0 || trim(document.getElementById('txtPass').value)=='')
	{				
			setValue('dvTxtPass','Please Enter Password');
			document.getElementById('txtPass').value='';			
			txtReturnType = false;
	}

	
	/*if (trim(document.getElementById('txtRePass').value) == 0 || trim(document.getElementById('txtRePass').value)=='')
	{				
			setValue('dvTxtRePass','Please Re-Enter Password');
			document.getElementById('txtRePass').value='';			
			txtReturnType = false;
	}
	else if ((trim(document.getElementById('txtPass').value)) != (trim(document.getElementById('txtRePass').value)))
	{				
			setValue('dvTxtRePass','Password Must be Match');					
			txtReturnType = false;
	}

	if (!document.getElementById('txtTerm').checked)
	{	
			setValue('dvTxtTerm','Please Select Term');
			txtReturnType = false;
	}*/
	
	if(txtReturnType)
	{
		var txtName = document.getElementById('txtName').value;
		var txtSchool = document.getElementById('txtSchool').value;
		var txtzip = document.getElementById('txtzip').value;
		var txtEmailr = document.getElementById('txtEmailr').value;
		var txtPass = document.getElementById('txtPass').value;
		
		  var url = "index.php?oper=signupajax&txtName="+document.getElementById('txtName').value+"&txtSchool="+txtSchool+"&txtzip="+txtzip+"&txtEmailr="+txtEmailr+"&txtPass="+txtPass;	
		  
		  //document.getElementById("dvIndicatorReg").style.display='block';
		  //document.getElementById("regSucc").innerHTML='';
			 if(window.XMLHttpRequest) {		 
				 reqDes = new XMLHttpRequest();
			} else if(window.ActiveXObject) {			 
			 reqDes = new ActiveXObject("Microsoft.XMLHTTP");
			 }
			 reqDes.open("POST", url, true);
			 reqDes.onreadystatechange = callbackRegistration;
			 reqDes.send(null);
		
		txtReturnType = false;
	}


	return false;
}

	function callbackRegistration()
	{
		if(reqDes.readyState == 4) 
		{
			
		 if(reqDes.status == 200) 
		 {
			  responseDes = reqDes.responseText;
			 // alert(responseDes);
			 // document.getElementById("regSucc").innerHTML =responseDes;
			  //document.getElementById("dvIndicatorReg").style.display='none';
			 // document.getElementById("dvRegForm").style.display='block';

			  if(responseDes=="Success")
			  {
				 //DvRegClose('DvRegComm');
				 window.location.reload(true);
			  }
			  else
			 {
				  alert(responseDes);
			  }
		 } 
		 else 
		 {
			alert("There was a problem retrieving the data:\n" + req.statusText);
		 }
		 }
	}


function validateRegistrationnew()
{
	//fieldArray = new Array('dvTxtName','dvTxtSchool','dvTxtzip','txtzip','dvTxtEmailr','dvTxtPass','dvTxtRePass','dvTxtTerm');
	fieldArray = new Array('dvTxtName','dvTxtSchool','dvTxtzip','dvTxtzip','dvTxtEmailr','dvTxtPass');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;

	if (trim(document.getElementById('txtName').value) == 0 || trim(document.getElementById('txtName').value)=='')
	{				
			setValue('dvTxtName','Please Enter Name');
			document.getElementById('txtName').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtSchool').value) == 0 || trim(document.getElementById('txtSchool').value)=='')
	{				
			setValue('dvTxtSchool','Please Enter School');
			document.getElementById('txtSchool').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtzip').value) == 0 || trim(document.getElementById('txtzip').value)=='')
	{				
			setValue('dvTxtzip','Please Enter Zipcode');
			document.getElementById('txtzip').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtEmailr').value) == 0 || trim(document.getElementById('txtEmailr').value)=='')
	{				
			setValue('dvTxtEmailr','Please Enter Email');
			document.getElementById('txtEmailr').value='';			
			txtReturnType = false;
	}
	else if(!CheckEmail(trim(document.getElementById('txtEmailr').value)))
	{
			setValue('dvTxtEmailr','Invalid Email Address');						
			txtReturnType = false;
	}


	if (trim(document.getElementById('txtPass').value) == 0 || trim(document.getElementById('txtPass').value)=='')
	{				
			setValue('dvTxtPass','Please Enter Password');
			document.getElementById('txtPass').value='';			
			txtReturnType = false;
	}

	
	/*if (trim(document.getElementById('txtRePass').value) == 0 || trim(document.getElementById('txtRePass').value)=='')
	{				
			setValue('dvTxtRePass','Please Re-Enter Password');
			document.getElementById('txtRePass').value='';			
			txtReturnType = false;
	}
	else if ((trim(document.getElementById('txtPass').value)) != (trim(document.getElementById('txtRePass').value)))
	{				
			setValue('dvTxtRePass','Password Must be Match');					
			txtReturnType = false;
	}

	if (!document.getElementById('txtTerm').checked)
	{	
			setValue('dvTxtTerm','Please Select Term');
			txtReturnType = false;
	}*/
	
	


	return txtReturnType;
}

function validateAccount()
{
	fieldArray = new Array('dvTxtName','dvTxtSchool','dvTxtzip','txtzip','dvTxtEmailr','dvTxtPass');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;
	
	if (trim(document.getElementById('txtName').value) == 0 || trim(document.getElementById('txtName').value)=='')
	{				
			setValue('dvTxtName','Please Enter Name');
			document.getElementById('txtName').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtSchool').value) == 0 || trim(document.getElementById('txtSchool').value)=='')
	{				
			setValue('dvTxtSchool','Please Enter School');
			document.getElementById('txtSchool').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtzip').value) == 0 || trim(document.getElementById('txtzip').value)=='')
	{				
			setValue('dvTxtzip','Please Enter Zipcode');
			document.getElementById('txtzip').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtEmailr').value) == 0 || trim(document.getElementById('txtEmailr').value)=='')
	{				
			setValue('dvTxtEmailr','Please Enter Email');
			document.getElementById('txtEmailr').value='';			
			txtReturnType = false;
	}
	else if(!CheckEmail(trim(document.getElementById('txtEmailr').value)))
	{
			setValue('dvTxtEmailr','Invalid Email Address');						
			txtReturnType = false;
	}


	if (trim(document.getElementById('txtPass').value) == 0 || trim(document.getElementById('txtPass').value)=='')
	{				
			setValue('dvTxtPass','Please Enter Password');
			document.getElementById('txtPass').value='';			
			txtReturnType = false;
	}

	return txtReturnType;
}


function validateContact()
{
	fieldArray = new Array('dvTxtName','dvTxtCompany','dvTxtEmailr','dvTxtComm');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;

	if (trim(document.getElementById('txtName').value) == 0 || trim(document.getElementById('txtName').value)=='')
	{				
			setValue('dvTxtName','Please Enter Name');
			document.getElementById('txtName').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtCompany').value) == 0 || trim(document.getElementById('txtCompany').value)=='')
	{				
			setValue('dvTxtCompany','Please Enter Company Name');
			document.getElementById('txtCompany').value='';			
			txtReturnType = false;
	}

	
	if (trim(document.getElementById('txtEmailr').value) == 0 || trim(document.getElementById('txtEmailr').value)=='')
	{				
			setValue('dvTxtEmailr','Please Enter Email');
			document.getElementById('txtEmailr').value='';			
			txtReturnType = false;
	}
	else if(!CheckEmail(trim(document.getElementById('txtEmailr').value)))
	{
			setValue('dvTxtEmailr','Invalid Email Address');						
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtComm').value) == 0 || trim(document.getElementById('txtComm').value)=='')
	{				
			setValue('dvTxtComm','Please Enter Comment');
			document.getElementById('txtComm').value='';			
			txtReturnType = false;
	}


	return txtReturnType;
}


function validateMessage()
{
	fieldArray = new Array('dvTxtMsg','dvTxtSub');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;

	if (trim(document.getElementById('txtMsg').value) == 0 || trim(document.getElementById('txtMsg').value)=='')
	{				
			setValue('dvTxtMsg','Please Enter Message');
			document.getElementById('txtMsg').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtSub').value) == 0 || trim(document.getElementById('txtSub').value)=='')
	{				
			setValue('dvTxtSub','Please Enter Subject');
			document.getElementById('txtSub').value='';			
			txtReturnType = false;
	}

	return txtReturnType;
}



	function checkAll(status){

  		var objForm = document.frmMailList;
  		var len = objForm.elements.length;
  		  		
  		for(var i=0;i<len;i++){
  			if(objForm.elements[i].type=='checkbox')
  				objForm.elements[i].checked=status;
  		
  		}
  	}
  	
  	function setStatus(status){
  		
  		var objForm = document.frmMailList;
  		var len = objForm.elements.length;
  		var checkedStaFlag = 1;
  		
  		if(status==true){
  		
	  		for(var i=0;i<len;i++){
	  			if(objForm.elements[i].name!='selAll'){
	  			
	  				if(objForm.elements[i].type=='checkbox' && objForm.elements[i].checked==false)
	  					checkedStaFlag = 0;
	  			}
	  		}
	  			
	  		if(checkedStaFlag==1){
	  		
	  			objForm.selAll.checked = true;
	  		
	  		}else{
	  		
	  			objForm.selAll.checked = false;
	  			
	  		}
	  		
	  	}else{
	  	
	  		objForm.selAll.checked = false;
	  	
	  	}
	  	
	  }


	function performAction(actId){

		var objForm = document.frmMailList;
		var len = objForm.elements.length;
		var checkedStaFlag = 0;
	
		if(actId>0){
		
			for(var i=0;i<len;i++){
				if(objForm.elements[i].name!='selAll'){
				
					if(objForm.elements[i].type=='checkbox' && objForm.elements[i].checked==true)
						checkedStaFlag = 1;
				}
			}
			
			if(checkedStaFlag==0){
				alert('Please Select At least One');
				return false;
			}else{
			
				objForm.actionId.value = actId;

				if(actId==1){
				
					/*if(confirmation('Are you sure wnat to delete?'))
					{*/						
						objForm.submit()
					//}
				
				}else
					objForm.submit();
			
			}
				
		}
	}


function validateAct()
{
	fieldArray = new Array('dvTxtEmailact');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;

	
	if (trim(document.getElementById('txtEmailact').value) == 0 || trim(document.getElementById('txtEmailact').value)=='')
	{				
			setValue('dvTxtEmailact','Please Enter Email');
			document.getElementById('txtEmailact').value='';			
			txtReturnType = false;
	}else if(!CheckEmail(trim(document.getElementById('txtEmailact').value)))
	{
			setValue('dvTxtEmailact','Invalid Email Address');						
			txtReturnType = false;
	}

	return txtReturnType;
}



function validateSellbook()
{
	fieldArray = new Array('dvTxtTitle','dvTxtCondition','dvTxtPrice','dvTxtNeg');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;
	

	if (trim(document.getElementById('txtTitle').value) == 0 || trim(document.getElementById('txtTitle').value)=='')
	{				
			setValue('dvTxtTitle','Please Enter Title');
			document.getElementById('txtTitle').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtCondition').value) == 0 || trim(document.getElementById('txtCondition').value)=='')
	{				
			setValue('dvTxtCondition','Please Choose Condition');
			document.getElementById('txtCondition').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtPrice').value) == 0 || trim(document.getElementById('txtPrice').value)=='')
	{				
			setValue('dvTxtPrice','Please Enter Price');
			document.getElementById('txtPrice').value='';			
			txtReturnType = false;
	}


	/*if (trim(document.getElementById('txtNeg').value) == 0 || trim(document.getElementById('txtNeg').value)=='')
	{				
			setValue('dvTxtNeg','Please Choose Negotiable');
			document.getElementById('txtNeg').value='';			
			txtReturnType = false;
	}*/

	return txtReturnType;
}

function validateWishlist()
{
	fieldArray = new Array('dvTxtTitle','dvTxtCondition','dvTxtPrice');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;
	

	if (trim(document.getElementById('txtTitle').value) == 0 || trim(document.getElementById('txtTitle').value)=='')
	{				
			setValue('dvTxtTitle','Please Enter Title');
			document.getElementById('txtTitle').value='';			
			txtReturnType = false;
	}

	if (trim(document.getElementById('txtCondition').value) == 0 || trim(document.getElementById('txtCondition').value)=='')
	{				
			setValue('dvTxtCondition','Please Choose Condition');
			document.getElementById('txtCondition').value='';			
			txtReturnType = false;
	}

	/*if (trim(document.getElementById('txtPrice').value) == 0 || trim(document.getElementById('txtPrice').value)=='')
	{				
			setValue('dvTxtPrice','Please Enter Email');
			document.getElementById('txtPrice').value='';			
			txtReturnType = false;
	}*/

	return txtReturnType;
}


function validateIsbn()
{
	fieldArray = new Array('dvTxtChkIsbn');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;
	
	if (trim(document.getElementById('txtChkIsbn').value) == 0 || trim(document.getElementById('txtChkIsbn').value)=='')
	{				
			setValue('dvTxtChkIsbn','Please Enter ISBN No');
			document.getElementById('txtChkIsbn').value='';			
			txtReturnType = false;
	}
	return txtReturnType;
}


function validateSearch()
{
	fieldArray = new Array('dvTxtSearch');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;
	

	if (trim(document.getElementById('txtSearchTitle').value)=='' && trim(document.getElementById('txtSearchAuthor').value)=='' && trim(document.getElementById('txtSearchZip').value)=='' && trim(document.getElementById('txtSearchClass').value)=='' && trim(document.getElementById('txtSearchEdition').value)=='')
	{				
			setValue('dvTxtSearch','Please Enter Search Criteria');
			txtReturnType = false;
	}

	return txtReturnType;
}



function validateConSeller()
{
	fieldArray = new Array('dvTxtComm');
	unSetVal(fieldArray); // function for unset the div error
	var txtReturnType = true;
	if (trim(document.getElementById('txtComm').value) == 0 || trim(document.getElementById('txtComm').value)=='')
	{				
			setValue('dvTxtComm','Please Enter Comment');
			document.getElementById('txtComm').value='';			
			txtReturnType = false;
	}

	return txtReturnType;
}



/* ajax for request*/
 function sendEnquiry()
	{

		fieldArray = new Array('dvTxtComm');
		unSetVal(fieldArray); // function for unset the div error
		var txtReturnType = true;
		if (trim(document.getElementById('txtComm').value) == 0 || trim(document.getElementById('txtComm').value)=='')
		{				
				setValue('dvTxtComm','Please Enter Comment');
				document.getElementById('txtComm').value='';			
				return false;
		}


	

		var txtBookId = document.getElementById("txtBookId").value;
		var txtComm = encodeURIComponent(document.getElementById("txtComm").value);	
		
		  var url = "account.php?oper=sendinquery&txtBookId="+txtBookId+"&txtComm="+txtComm;	
		  
		  document.getElementById("dvIndicatorSend").style.display='block';
		  document.getElementById("dvSendForm").style.display='none';

			 if(window.XMLHttpRequest) {		 
				 reqDes = new XMLHttpRequest();
			} else if(window.ActiveXObject) {			 
			 reqDes = new ActiveXObject("Microsoft.XMLHTTP");
			 }
			 reqDes.open("POST", url, true);
			 reqDes.onreadystatechange = callbackSendquery;
			 reqDes.send(null);

			 return false;
	}
	function callbackSendquery()
	{
		if(reqDes.readyState == 4) 
		{
		 if(reqDes.status == 200) 
		 {
			  responseDes = reqDes.responseText;
			  document.getElementById("msgSucc").innerHTML =responseDes;
			  document.getElementById("dvIndicatorSend").style.display='none';
			  document.getElementById("dvSendForm").style.display='block';

			  if(responseDes=="Message Send")
			  {
				 DvCommClose('DvMsgComm');
				  
			  }
		 } 
		 else 
		 {
			alert("There was a problem retrieving the data:\n" + req.statusText);
		 }
		 }
	}
/* end ajax for request*/


function logoutFB(logoutURL, fbUid)
{
	try 
	{
		var logoutLink = logoutURL;
		var facebook_id = fbUid;
		
		if (facebook_id)
		{
			FB.Connect.logoutAndRedirect(logoutLink);			
		}	
		else
		{
			window.location.href = logoutLink;
		}	
	}
	catch(e)
	{
		alert(e)
	}
}

function milesSubmit()
{
	document.getElementById('txtSearchMileshd').value = document.getElementById('txtSearchMiles').value;
	document.getElementById('frmTopsearch').submit();
}
