﻿// Local variable
var regex_Email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; 
var hyphenEnters = false;
// onmouseoverimgsrc function to change the image source on Mouseover
function onmouseoverimgsrc(jid, cateId) {
    var imgPath = new String();
    if (cateId == 101) {
        imgPath = document.getElementById(jid).style.backgroundImage;
        if (imgPath == "url(./images/ProBoyBox.jpg)" || imgPath == "") {
            document.getElementById(jid).style.backgroundImage = "url(./images/ProBoyBoxOver.jpg)";
        }
    }
    else if (cateId == 102) {
        imgPath = document.getElementById(jid).style.backgroundImage;
        if (imgPath == "url(./images/ProGirlBox.jpg)" || imgPath == "") {
            document.getElementById(jid).style.backgroundImage = "url(./images/ProGirlBoxOver.jpg)";
        }
    }
}
// onmouseoutimgsrc function to change the image source on Mouseout
function onmouseoutimgsrc(jid,cateId) {
    var imgPath = new String();
    if (cateId == 101) {
        imgPath = document.getElementById(jid).style.backgroundImage;
        if (imgPath == "url(./images/ProBoyBoxOver.jpg)" || imgPath == "") {
            document.getElementById(jid).style.backgroundImage = "url(./images/ProBoyBox.jpg)";
        }
    }
    else if (cateId == 102) {
        imgPath = document.getElementById(jid).style.backgroundImage;
        if (imgPath == "url(./images/ProGirlBoxOver.jpg)" || imgPath == "") {
            document.getElementById(jid).style.backgroundImage = "url(./images/ProGirlBox.jpg)";
        }
    }
    
}

function onmouseovertabsrc(jid){
    switch(jid)
    {
        case 'H':
        document.getElementById(jid).src = "./images/BtnHomeOver.gif";        
        break;
        case 'S':
        document.getElementById(jid).src = "./images/BtnShopOver.gif";        
        break;
        case 'O':
        document.getElementById(jid).src = "./images/BtnOrderingOver.gif";        
        break;
        case 'L':
        document.getElementById(jid).src = "./images/BtnLogInOver.gif";        
        break;
        case 'F':
        document.getElementById(jid).src = "./images/BtnFindUsOver.gif";        
        break;
        case 'C':
        document.getElementById(jid).src = "./images/BtnFSCCOver.gif";
        break;
        case 'N':
        document.getElementById(jid).src = "./images/BtnContactUsOver.gif";        
        break;
    }

}
function onmouseouttabsrc(jid){
    switch(jid)
    {
        case 'H':
        document.getElementById(jid).src = "./images/BtnHome.gif";        
        break;
        case 'S':
        document.getElementById(jid).src = "./images/BtnShop.gif";        
        break;
        case 'O':
        document.getElementById(jid).src = "./images/BtnOrdering.gif";        
        break;
        case 'L':
        document.getElementById(jid).src = "./images/BtnLogIn.gif";        
        break;
        case 'F':
        document.getElementById(jid).src = "./images/BtnFindUs.gif";
        break;
        case 'C':
        document.getElementById(jid).src = "./images/BtnFSCC.gif";
        break;
        case 'N':
        document.getElementById(jid).src = "./images/BtnContactUs.gif";
        break;
    }
}

// Function written to validate Email Id
function validate(email){  
     if (!regex_Email.test(email)) {
        return false;  
     }
     else
     {
        return true;
     }
}

//function to trim leading white spaces on left side of the string
function LeftTrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

//function to trim trailing white spaces on right side of the string
function RightTrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

//function to trim leading and trailing white spaces
function Trim(str, chars) {
    return LeftTrim(RightTrim(str, chars), chars);
}

//function to restrict characters other than numeric
function CheckGivenValueIsNan(txt) 
{   
    if (isNaN(document.getElementById(txt).value) == true) {        
        document.getElementById(txt).value = "";
        document.getElementById(txt).focus();        
    }
}
//function to restrict characters other than numeric and hyphen
function CheckGivenValueIsNanAndAllowHyphen(txt) 
{   
    if (isNaN(document.getElementById(txt).value) == true) {        
        if (!AllowHyphen(document.getElementById(txt).value) || hyphenEnters==true)
        {   
            hyphenEnters=false;
            document.getElementById(txt).value = "";
            document.getElementById(txt).focus();                  
        }
        else
        {
            hyphenEnters=true;
        }        
    }
}
//function to validate empty or zero
function CheckGivenValueIsEmpty(txt,msg) 
{   
    if (document.getElementById(txt).value == "" || document.getElementById(txt).value == 0) {        
        if (msg != "")
        {
            //document.getElementById(txt).focus();
            alert(msg);
        }
        document.getElementById(txt).value = "0";
    }
}
//function to check hyphen
function AllowHyphen(str)
{
    var reg = new RegExp("-");    
    if (reg.test(str)) 
	{
	 	return true;        
    }
    else
    {
		return false;
	}
}
//function to restrict special characters
//---------------------------------------
function RestrictSpecialCharacters(str) {    
	var reg = new RegExp("'|&|\"");
    if (reg.test(str)) 
	{
	 	return true;        
    }
    else
    {
		return false;
	}
}
