
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){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function isPhoneNumber(str){
	   var stripped = str.replace(/[\(\)\.\-\ ]/g, '');
   
	 if (isNaN(parseInt(stripped))) {
        alert("The phone number contains illegal characters. \n It must be numeric")
return false
    }
return true
 
}

function ValidateRegisterForm(){

	var firstname=document.frm_register.first
	var lastname=document.frm_register.last
	var emailID=document.frm_register.email
	var password1=document.frm_register.password
	var password2=document.frm_register.password2
	var phone=document.frm_register.phone
	var address=document.frm_register.address
	var city=document.frm_register.city
	if ((firstname.value==null)||(firstname.value=="")){
		alert("Please Enter your First name")
		firstname.focus()
		return false
	}
	if ((lastname.value==null)||(lastname.value=="") ){
		alert("Please Enter your Last name")
		lastname.focus()
		return false
	}
	 
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	if ((password1.value==null)||(password1.value=="") ){
		alert("Please Enter your Password")
		password1.focus()
		return false
	}
	if ((password2.value==null)||(password2.value=="") ){
		alert("Please Enter your Confirm Password")
		password2.focus()
		return false
	}
	if(password1.value!=password2.value){
		alert("Your password and confirm password are not the same")
		return false}
	if ((phone.value==null)||(phone.value=="") ){
		alert("Please Enter your Phone Number")
		phone.focus()
		return false
	}
		if (isPhoneNumber(phone.value)==false){
		phone.value=""
		
		phone.focus()
		return false}
		
	if ((address.value==null)||(address.value=="") ){
		alert("Please Enter your Address")
		address.focus()
		return false
	}
	if ((city.value==null)||(city.value=="") ){
		alert("Please Enter your City")
		city.focus()
		return false
	}
	return true
 }


function ValidateContactForm(){

	var firstname=document.frm_contact.first
	var lastname=document.frm_contact.last
	var emailID=document.frm_contact.email
	var question=document.frm_contact.message
	
	if ((firstname.value==null)||(firstname.value=="")){
		alert("Please Enter your First name")
		firstname.focus()
		return false
	}
	if ((lastname.value==null)||(lastname.value=="") ){
		alert("Please Enter your Last name")
		lastname.focus()
		return false
	}
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	if ((question.value==null)||(question.value=="") ){
		alert("Please Enter your question or message")
		question.focus()
		return false
	}
	
	return true
 }

function ValidateLoginForm(){

	
	var emailID=document.frm_login.mem_email
	var password=document.frm_login.mem_password
	

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	if ((password.value==null)||(password.value=="") ){
		alert("Please Enter your question or message")
		password.focus()
		return false
	}
	
	return true
 }
function ValidateChangeForm(){

	
	var pass=document.frm_change.mem_pass
	var pass2=document.frm_change.mem_pass2
	

	if ((pass.value==null)||(pass.value=="") ){
		alert("Please Enter your New Password")
		pass.focus()
		return false
	}
	if ((pass2.value==null)||(pass2.value=="") ){
		alert("Please Re-Enter your new password")
		pass2.focus()
		return false
	}
	if (pass.value!=pass2.value) {
		alert("Your passwords do not match")
		pass.focus()
		return false
	}
	return true
 }
function checksearch(){

	
	var searchtext=document.frm_search.search_text
	
	

	if ((searchtext.value==null)||(searchtext.value=="")){
		alert("Please Enter products you want to search")
		searchtext.focus()
		return false
	}
	
	return true
 }
window.onload = initForm;
window.onunload = function() {};

function initForm() {
	document.getElementById("newLocation").selectedIndex = 0;
	document.getElementById("newLocation").onchange = jumpPage;
}

function jumpPage() {
	var newLoc = document.getElementById("newLocation");
	var newPage = newLoc.options[newLoc.selectedIndex].value;

	if (newPage != "") {
		window.location = newPage;
	}
}
function clip() {
    // width of the banner container
    var contWidth =780;
    // height of the banner container
    var contHeight = 170;

    var id1 = document.getElementById('slideA');
    var id2 = document.getElementById('slideB');

    id1.style.left = parseInt(id1.style.left)-3 + 'px';

    document.getElementById('slideCont').style.width = contWidth + "px";
    document.getElementById('slideCont').style.clip = 'rect(auto,'+ contWidth +'px,' + contHeight +'px,auto)';
    id2.style.display = '';
    if(parseFloat(id1.style.left) == -(contWidth))     {
        id1.style.left = '0px';
    }
    setTimeout(clip,25)
}

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'fnction') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  clip();
});

function viewProd()
{
	with (window.document.frmListProduct) {
		if (cboCategory.selectedIndex == 0) {
			window.location.href = 'product.php';
		} else {
			window.location.href = 'product.php?c=' + cboCategory.options[cboCategory.selectedIndex].value;
		}
	}
}
