//*********************************** Copyrights Statement Starts Here *******************************************

// Owner: 					Cyber Search Internet Services - Canada/Cyber Search (Pvt) Limited - Pakistan
// Location: 				22C-14th Street, No.8, Phase V, DHA, Karachi 75500, Pakistan
////                			605 Foster Ave, Coquitlam, BC V3J 2L6, Canada
// Software Name: 			Cyber Search Software
// Software Version of declaration form: Ver-CS-0.01
// File Name:				Productjava.js
// Description:				validations for product page
// Copyrights 2006-2007-2008
// Statement: 				Copyright © 2006 Cyber Search Software™. All rights reserved.

//*********************************** Copyrights Statement Ends Here **********************************************
/********************************Custom Pop Up Setting******************************************/

// JavaScript Document
function BrowserCheck() {
var b = navigator.appName;
if (b == "Netscape") this.b = "NS";
else if (b == "Microsoft Internet Explorer") this.b = "IE";
else this.b = b;
this.v = parseInt(navigator.appVersion);
this.NS = (this.b == "NS" && this.v>=4);
this.NS4 = (this.b == "NS" && this.v == 4);
this.NS5 = (this.b == "NS" && this.v == 5);
this.IE = (this.b == "IE" && this.v>=4);
this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0);
this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0);
if (this.IE5 || this.NS5) this.VER5 = true;
if (this.IE4 || this.NS4) this.VER4 = true;
this.OLD = (! this.VER5 && ! this.VER4) ? true : false;
this.min = (this.NS||this.IE);
}
is = new BrowserCheck();
alertBox = (is.VER5) ? document.getElementById("alertLayer").style
: (is.NS) ? document.layers["alertLayer"]
: document.all["alertLayer"].style;

function hideAlert(){
alertBox.visibility = "hidden";}

function makeAlert(aTitle,aMessage){
document.all.alertLayer.innerHTML = "<table border=0 width=100% height=100%>" +
"<tr height=5><td colspan=4 class=alertTitle>" + " " + aTitle + "</td></tr>" +
"<tr height=5><td width=5></td></tr>" +
"<tr><td width=5></td><td width=20 align=left><img src='alert.gif'></td><td align=center class=alertMessage>" + aMessage + "<BR></td><td width=5></td></tr>" + 
"<tr height=5><td width=5></td></tr>" +
"<tr><td width=5></td><td colspan=2 align=center><input type=button value='OK' onClick='hideAlert()' class=okButton><BR></td><td width=5></td></tr>" +
"<tr height=5><td width=5></td></tr></table>";
thisText = aMessage.length;
if (aTitle.length > aMessage.length){ thisText = aTitle.length; }

aWidth = (thisText * 5) + 80;
aHeight = 100;
if (aWidth < 150){ aWidth = 200; }
if (aWidth > 350){ aWidth = 350; }
if (thisText > 60){ aHeight = 110; }
if (thisText > 120){ aHeight = 130; }
if (thisText > 180){ aHeight = 150; }
if (thisText > 240){ aHeight = 170; }
if (thisText > 300){ aHeight = 190; }
if (thisText > 360){ aHeight = 210; }
if (thisText > 420){ aHeight = 230; }
if (thisText > 490){ aHeight = 250; }
if (thisText > 550){ aHeight = 270; }
if (thisText > 610){ aHeight = 290; }

alertBox.width = aWidth;
alertBox.height = aHeight;
alertBox.left = (document.body.clientWidth - aWidth)/2;
alertBox.top = (document.body.clientHeight - aHeight)/2;

alertBox.visibility = "visible";
}

// WHEN YOU WANT TO GENERATE AN ALERT DO THIS:
// CALL THE makeAlert FUNCTION AND PASS THE ALERT TITLE AND THE MESSAGE
// TO THE FUNCTION.
// eg. makeAlert('My Alert Title' , 'My Alert Message'); 

/********************************Custom Pop Up Setting******************************************/

function validate_Form()
{
	var count=document.myForm.elements.length
	for (i=0; i<count; i++)
	{
		if (document.myForm.elements[i].value=="")
		{
			makeAlert('Cyber Search Alert Box','Please enter all of the fields!');	
			//alert("Please enter all of the fields!");
			document.myForm.elements[i].focus()
			return false
		}			
	}
}
function validate_Email()
{
	x=document.myForm
	at=x.Email.value.indexOf("@")
	dot=x.Email.value.indexOf(".")
	
	if (((at == -1)) || ((dot == -1)))
	{
		makeAlert('Cyber Search Alert Box','Invalid e-mail address.');
		//alert("Invalid e-mail address")
		return false
	}

}

/*function validate_Email1()
{
	x=document.myForm
	at=x.U_Email.value.indexOf("@")
	dot=x.U_Email.value.indexOf(".")
	
	if (((at == -1)) || ((dot == -1)))
	{
		makeAlert('Cyber Search Alert Box','Invalid e-mail address.');
		//alert("Invalid e-mail address")
		return false
	}

}
*/
function validateMyForm()
{
	
   if(document.myForm.U_Name.value=="")
	{
		document.myForm.U_Name.focus();
		makeAlert('Cyber Search Alert Box','Please enter your name.');
		//alert("Please enter your name.");
		return false;
	}
	
 if(document.myForm.U_Email.value=="")
	{
		document.myForm.U_Email.focus();
		makeAlert('Cyber Search Alert Box','Please enter your email address.');
		//alert("Please enter your email adrress.");
		return false;
	}
	
 if(document.myForm.P_Name.value=="")
	{
		document.myForm.P_Name.focus();
		makeAlert('Cyber Search Alert Box','Product Name Cannot be left blank.');
		//alert("Product Name Cannot be left blank");
		return false;
	}
	
		
 if(document.myForm.Manufac.value=="")
	{
		document.myForm.Manufac.focus();
		makeAlert('Cyber Search Alert Box','Manufacturer Name Cannot be left blank.');
		//alert("Manufacturer Name Cannot be left blank");
		return false;
	}
	
if(document.myForm.Industry.value=="")
	{
		document.myForm.Industry.focus();
		makeAlert('Cyber Search Alert Box','Industry Name Cannot be left blank.');
		//alert("Industry Name Cannot be left blank");
		return false;
	}
	
	
 if(document.myForm.Agree.checked == false)
	{
		//document.myForm.S_Name.focus();
		makeAlert('Cyber Search Alert Box','You must first agree to our terms and conditions.');
		//alert("You must first agree to our terms and conditions.");
		return false;
	}
	
	else 
		return true;
	
	
	
}


function validate_phoneNumber()
{
	var len=document.myForm.txtPNumb.value.length
	
	if(len>11)
	{
		makeAlert('Cyber Search Alert Box','You cannot enter more than 11 numbers.');
		//alert("You cannot enter more than 11 numbers");
		document.myForm.txtPNumb.focus()
		return false;
	}
}



function pNumbIsNumeric()
{
	
	if (window.event.keyCode < 48 || window.event.keyCode > 57) 
	if(window.event.keyCode < 8 || window.event.keyCode > 8)
	if(window.event.keyCode !=45 )
	{
		window.event.keyCode = 0;
		makeAlert('Cyber Search Alert Box','Only numeric values and dashes are allowed.');
		//alert(" Only numeric values and dashes are allowed.");
		//document.myForm.txtPNumb.focus();
		ret = false;
	}
}

function OnlyNumeric()
{
	
	if (window.event.keyCode < 48 || window.event.keyCode > 57) 
	if(window.event.keyCode < 8 || window.event.keyCode > 8)
	{
		window.event.keyCode = 0;
		makeAlert('Cyber Search Alert Box','Only numeric values are allowed.');
		//alert(" Only numeric values and dashes are allowed.");
		//document.myForm.txtPNumb.focus();
		ret = false;
	}
}



function Name_isAlphabet()
{
	var ret = true;
	if (window.event.keyCode < 65 || window.event.keyCode > 90) 
	if(window.event.keyCode < 97 || window.event.keyCode > 122)
	if(window.event.keyCode < 32 || window.event.keyCode > 32)
	if(window.event.keyCode < 8 || window.event.keyCode > 8)
	{
		window.event.keyCode = 0;
		makeAlert('Cyber Search Alert Box','Please enter Alphabets.');
		//alert("Please enter Alphabets");
		//document.myForm.txtName.focus();
		ret = false;
	}
}
//*********************************** Copyrights Statement Starts Here *******************************************

// Owner: 					Cyber Search Internet Services - Canada/Cyber Search (Pvt) Limited - Pakistan
// Location: 				22C-14th Street, No.8, Phase V, DHA, Karachi 75500, Pakistan
////                			605 Foster Ave, Coquitlam, BC V3J 2L6, Canada
// Software Name: 			Cyber Search Software
// Software Version of declaration form: Ver-CS-0.01
// File Name:				Productjava.js
// Description:				validations for product page
// Copyrights 2006-2007-2008
// Statement: 				Copyright © 2006 Cyber Search Software™. All rights reserved.

//*********************************** Copyrights Statement Ends Here **********************************************