function ChangeSize(intSize,intpid,intmfid,intmid)
{
	var strString;
	if(intSize=="")
	{
		alert("Please select size")
		return;
	}
	strString="modelsclopay.asp?pid=" + intpid + "&mfid=" + intmfid + "&mid=" + intmid + "&size=" + intSize
	window.open(strString,'_self')
}
function ValidateCart(txtObj)
{
	if(txtObj.value=="0")
	{
		alert("Empty cart can not be saved")
		return false;
	}
	return true;
}
function ValidateCartCont(txtObj)
{
	if(txtObj.value=="0")
	{
		alert("Cart is empty")
		return false;
	}
	return true;
}
function chkRemove()
{
	var intChecked;
	intChecked = 0;
	var i;
	if(document.frmCart.chkCount.value == 1 )
	{
		if(document.frmCart.chkCatalogue.checked)
		{
			return true;
		}
		else
		{
			alert("You must select a product to remove")
			return false;
		}
	}
	else
	{
		for(i=0;i<document.frmCart.chkCatalogue.length;i++)
		{
			if(document.frmCart.chkCatalogue[i].checked)
			{
				intChecked = intChecked + 1
			}
		}
		if(intChecked >= 1)
		{
			return true;
		}
		else
		{
			alert("You must select a product to remove")
			return false;
		}
	}
}
function editcart(intCatalogueId,txtObj)
{
	var strString;
	strString = txtObj.value
	var strValidChars = "0123456789";
	var strChar;
    if(strString == 0)
	{
		alert("Quantity can not be zero")
		txtObj.value = ''
		txtObj.focus();
		return;
	}
      if (strString.length == 0)
      {
        alert("Quantity can not be left blank")
        txtObj.value = ''
        txtObj.focus();
        return;
      }
	for (i = 0; i < strString.length; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
           alert("Please enter valid quantity")
           txtObj.focus();
	       txtObj.value = ''
           return;
        }
    }
    var strLink;
	strLink = "Editcart.asp?edid=" + intCatalogueId + "&val=" + txtObj.value
	window.open(strLink,'_self')
}
function viewoptions(pid,mfid,mid)
{
	var strString;
	strString = "accessories.asp?pid=" + pid.toString() + "&mfid=" + mfid.toString() + "&mid=" + mid.toString()
	window.open(strString,'_self')
}
function viewoptionsmetallic(pid,mfid,mid)
{
	var strString;
	strString = "accessoriesmetallic.asp?pid=" + pid.toString() + "&mfid=" + mfid.toString() + "&mid=" + mid.toString()
	window.open(strString,'_self')
}
function viewoptionsGBP(pid,mfid,mid)
{
	var strString;
	strString = "accessoriesGBP.asp?pid=" + pid.toString() + "&mfid=" + mfid.toString() + "&mid=" + mid.toString()
	window.open(strString,'_self')
}
function QtyValidate(frmObj)
{
	var strString;
	strString = frmObj.quantity.value
	var strValidChars = "0123456789";
	var strChar;
      var blnResult = true;
	if(strString == 0)
	{
		alert("Quantity can not be zero")
		frmObj.quantity.value = ''
		return false;
	}
      if (strString.length == 0)
      {
        alert("Quantity can not be left blank")
        frmObj.quantity.value = ''
        return false;
      }
	for (i = 0; i < strString.length && blnResult == true; i++)
      {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
           alert("Please enter valid quantity")
           frmObj.quantity.value = ''
           blnResult = false;
        }
      }
      return blnResult;
}
function validate1()
{
	var emailID=document.frmEmail.txtEmail
	
	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
	}
	return true
}
function validate2()
{

	var emailID=document.frmEmail2.txtEmail
	var Pass=document.frmEmail2.txtPassword
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your Email ID")
		emailID.focus()
		return false
	}
	if ((Pass.value==null)||(Pass.value=="")){
		alert("Please enter your password")
		Pass.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
}

function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	//alert(str.indexOf(at))
if (lstr != 0)
{	
	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-1){
	    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(dot,(lat+2))==-1){
	    alert("Invalid E-mail ID")
	    return false
	}
	if (str.substring(ldot+1,ldot+2)==dot){
	    alert("Invalid E-mail ID")
	    return false
	}


	if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail ID")
	    return false
	}
}
	return true					
}
function Email_validate()
{
	var a;
	a=Email_validation();
	if (a.length > 0)
	{
	alert(a);
	frmEmail.txtEmail.focus();
	}
	else 
	{
		frmEmail.submit();
     }
}
function check_enter()
{
	if (window.event.keyCode==13)
	{		
		window.event.keyCode=0;
		Email_validate();
	}

}

function Email_validation()
{   var message
        message="";
	if(document.frmEmail.txtEmail.value =="")
		message= message + "\n Please enter a valid email address";
	else if(document.frmEmail.txtEmail.value !="")
			{ if(!isEmail(document.frmEmail.txtEmail.value))
				message= message + "\n Please enter a valid email address";
			}
	
	return message;
}

function isCharsInBag (str, bag)
{  
	var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < str.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = str.charAt(i);
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
}

function isEmail(str)
{
	if (checkNull(str))
    
    // is s whitespace?
    if (isWhitespace(str)) return false;
 
    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    
	var i = 1;
    var sLength = str.length;
 
    // look for @
    while ((i < sLength) && (str.charAt(i) != "@"))
    { 
    i++
    }
    
    if ((i >= sLength) || (str.charAt(i) != "@")) return false;
    else i += 2;
 
    // look for .
    
    while ((i < sLength) && (str.charAt(i) != "."))
    { 
    i++
    }
 
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (str.charAt(i) != ".")) return false;
    else return true;
 }

function isWhitespace (str)
{  
	var i;
 	// Is s empty?
 	if (checkNull(str)) return true;

 	// Search through string's characters one by one
 	// until we find a non-whitespace character.
 	// When we do, return false; if we don't, return true.
 	
 	for (i = 0; i < str.length; i++)
 	{   
 		// Check that current character isn't whitespace.
 	    var c = str.charAt(i);
	
	    if (whitespace.indexOf(c) == -1) return false;
 	}
	
 	// All characters are whitespace.
	return true;
}

function checkNull(x)
{         
	return ((x == "") || (x.length == 0))
}

function CheckEmailPassword()
{
	if (checkNull(frmEmail.txtEmail.value))
	{
		alert("Login name can't be null")
		frmEmail.txtEmail.focus();
	}
	else if(checkNull(frmEmail.txtPassword.value))
	{
		alert("Password can't be null")
		frmEmail.txtPassword.focus();
	}
	else
		Email_validate();
}
function Reset()
{
	frmEmail.txtEmail.value="";
	frmEmail.txtPassword.value ="";
}

