// JavaScript Document
function openWind(pid) {
	bigWindow = window.open('big_image.php?PID='+ pid +'&POS=P','test','height=535,width=535,top=0,left=0,toolbar=no,titlebar=no,location=no,scrollbars=1')
	bigWindow.focus();
}
////////////////////////////
var xmlHttp
function showpage(ctlName,page){
	var xmlHttp = GetXmlHttpObject();
	var url = page+"&sid="+Math.random();
	if (!xmlHttp){
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
//			if(xmlHttp.responseText=='&nbsp;'){
				document.getElementById(ctlName).innerHTML=xmlHttp.responseText;
//			}
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function GetXmlHttpObject(){ 
var objXMLHttp=null;

     if (window.XMLHttpRequest){
          objXMLHttp=new XMLHttpRequest();
     }else if (window.ActiveXObject){
          objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     return objXMLHttp;
}
/////////////////////
function test(obj,msg){
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if (regex.test(obj.value)){
		return true;
	}else{
		alert(msg);
		obj.focus();
		return false;
	}
}
function checkempty(obj,msg){
	if(obj.value==''){
		alert(msg);
		obj.focus()
		return false;
	}
	return true;
}
function confirmpass(obj,obj1,msg){
	if(obj1.value!=obj.value){
		alert(msg);
		obj1.focus();
		obj1.select();
		return false;
	}
	return true;
}
function chkStock(obj,obj1,msg){
	if(obj1.value>obj.value){
		alert(msg);
		obj1.focus();
		obj1.select();
		return false;
	}
	return true;
}
function checkdate(obj,msg){
	if(obj.value==''){
		alert(msg);
		document.all.trigger.focus();
		return false;
	}
	return true;
}
function checkZero(obj,msg){
	if(obj.value==0){
		alert(msg);
		return false;
	}
	return true;
}
function doSubmit(val){
	document.frmActions.act.value=val;
	document.frmActions.submit();
}
/////////////////////
function checkAll(theForm, cName, allNo_stat){
	var n=theForm.elements.length;
	for (var i=0;i<n;i++){
		if (theForm.elements[i].className.indexOf(cName) !=-1){
			if (allNo_stat.checked) {
				theForm.elements[i].checked = true;
			}else{
				theForm.elements[i].checked = false;
			}
		}
	}
}
function SelectedEmails(){
	var varEmails = document.frmCatalogue.Chk.length;
	var varEmailsSelect = 0;
	if(varEmails){
		for(i = 0; i <= varEmails-1; i++){
			if(document.frmCatalogue.Chk[i].checked){
				varEmailsSelect++;
			}
		}
	}
	if(!varEmails){
		if(document.frmCatalogue.Chk.checked){
				varEmailsSelect++;
		}
	}
	return(varEmailsSelect);
}

/////////////////////
function CheckUserLogin(){
	if(checkempty(document.frmUserLogin.txtUName,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmUserLogin.txtPass,"Information: Enter Password")==false) return false;
	return true;
}
function CheckUserLogin1(){
	if(checkempty(document.frmUserLogin1.txtUName,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmUserLogin1.txtPass,"Information: Enter Password")==false) return false;
	return true;
}
function CheckSearch(){
	if(checkempty(document.frmSearch.key,"Information: Enter Search Keywords")==false) return false;
	return true;
}
function chkQty(vfrm){
	if(checkempty(document.vfrm.qty,"Information: Enter Quantity")==false) return false;
	return true;
}
function chkNlFrm(){
	if(test(document.frmNl.email,"Information: Enter Valid Email Address")==false) return false;
	return true;
}
function chkfrmFP(){
	if(test(document.frmFP.email,"Information: Enter Valid Email Address")==false) return false;
	return true;
}
function CheckForgotFrm(){
	if(checkempty(document.frmFPass.txtUN,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmFPass.SHint,"Information: Select Secret Question")==false) return false;
	if(checkempty(document.frmFPass.txtHintAns,"Information: Enter Secret Answer")==false) return false;
	return true;
}
function chknUser(){
	if(checkempty(document.frmNewUser.txtcname,"Information: Enter Company Name")==false) return false;
	if(checkempty(document.frmNewUser.txtcperson,"Information: Enter Contact Person Name")==false) return false;
	if(test(document.frmNewUser.txtmail,"Information: Enter Email")==false) return false;
	return true;
}
function CheckSendInquiry(){
	if(checkempty(document.frmSendInquiry.txtCompName,"Information: Enter Company Name")==false) return false;
	if(checkempty(document.frmSendInquiry.txtCPerson,"Information: Enter Contact Person Name")==false) return false;
	if(checkempty(document.frmSendInquiry.txtPhone,"Information: Enter Phone")==false) return false;
	if(test(document.frmSendInquiry.txtEmail,"Information: Enter Email")==false) return false;
	if(checkempty(document.frmSendInquiry.txtAddress,"Information: Enter Address")==false) return false;
	if(checkempty(document.frmSendInquiry.txtCity,"Information: Enter City")==false) return false;
	if(checkempty(document.frmSendInquiry.txtZCode,"Information: Enter ZipCode")==false) return false;
	return true;
}
function chkfeedfrm(){
	if(checkempty(document.frmFeed.fullname,"Information: Enter Your Full Name")==false) return false;
	if(checkempty(document.frmFeed.phone,"Information: Enter Your Phone Number")==false) return false;
	if(test(document.frmFeed.email,"Information: Enter Your Email")==false) return false;
	if(checkempty(document.frmFeed.comments,"Information: Enter Comments")==false) return false;
	return true;
}
function chkfrmRegister(){
	if(checkempty(document.frmRegister.UserName,"Information: Please Enter Username")==false) return false;
	if(checkempty(document.frmRegister.Password,"Information: Please Enter Password")==false) return false;
	if(checkempty(document.frmRegister.CPassword,"Information: Please Enter Confirm Password")==false) return false;
	if(confirmpass(document.frmRegister.Password,document.frmRegister.CPassword,"Information: Password and Confirm Password does not match")==false) return false;
	if(checkempty(document.frmRegister.ContactPerson,"Information: Please Enter Contact Person")==false) return false;
	if(test(document.frmRegister.Email,"Information: Please Enter Valid Email")==false) return false;
	return true;
}
function chkfrmUpdateP(){
	if(checkempty(document.frmUpdateP.Password,"Information: Please Enter Password")==false) return false;
	if(checkempty(document.frmUpdateP.CPassword,"Information: Please Enter Confirm Password")==false) return false;
	if(confirmpass(document.frmUpdateP.Password,document.frmUpdateP.CPassword,"Information: Password and Confirm Password does not match")==false) return false;
	if(checkempty(document.frmUpdateP.ContactPerson,"Information: Please Enter Contact Person")==false) return false;
	if(test(document.frmUpdateP.Email,"Information: Please Enter Valid Email")==false) return false;
	return true;
}
function chkuFrmCP(){
	if(checkempty(document.frmUpduPass.oPass,"Information: Enter Your Old Password")==false) return false;
	if(checkempty(document.frmUpduPass.nPass,"Information: Enter Your New Password")==false) return false;
	if(checkempty(document.frmUpduPass.cnPass,"Information: Enter Confirm Password")==false) return false;
	if(confirmpass(document.frmUpduPass.nPass,document.frmUpduPass.cnPass,"Information: Password and Confirm Password does not match")==false) return false;
	return true;
}
function CheckSendCatalogue(){
	varSEmails = SelectedEmails()
	if(varSEmails <= 0){
		alert("Select Category")	
		return false;		
	}
	if(checkempty(document.frmCatalogue.txtcname,"Information: Please type company name")==false) return false;
	if(checkempty(document.frmCatalogue.txtcperson,"Information: Please type contact person")==false) return false;
	if(test(document.frmCatalogue.txtmail,"Information: Please type valid email")==false) return false;
	if(checkempty(document.frmCatalogue.txtaddress,"Information: Please type address")==false) return false;
	if(checkempty(document.frmCatalogue.txttel,"Information: Please type Phone no.")==false) return false;
	return true;
}
function chkShipDet(){
	if(checkempty(document.frmShip.fullname,"Information: Please type full name")==false) return false;
	if(checkempty(document.frmShip.phone,"Information: Please type phone number")==false) return false;
	if(test(document.frmShip.email,"Information: Please type valid email")==false) return false;
	if(checkempty(document.frmShip.address,"Information: Please type address")==false) return false;
	if(checkempty(document.frmShip.city,"Information: Please type city name")==false) return false;
	if(checkempty(document.frmShip.state,"Information: Please type state")==false) return false;
	if(checkempty(document.frmShip.zipcode,"Information: Please type zipcode")==false) return false;
	if(checkempty(document.frmShip.Country,"Information: Please select country")==false) return false;
	return true;
}