var whitespace = " \t\n\r";
var defaultEmptyOK = false;
var NS4 = (document.layers) ? true : false;

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}


function isWhitespace (s)

{   
	var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);

    if (isWhitespace(s)) return false;

    var i = 1;
    var sLength = s.length;

    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isDigit (c)
{  
	return ((c >= "0") && (c <= "9"))
}

function isInteger (s)

{  
	var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }
    return true;
}

function goToPage(url)
{
	window.location.href=url;
}

function openPage(url)
{
	window.open(url,"_blank","width=700,height=600,scrollbars=1,resizable=1");
}

function openMapPage(url)
{
	window.open(url,"_blank","width=630,height=610,scrollbars=1,resizable=0");
}

function showmenu(elmnt)
{
	document.getElementById(elmnt).style.visibility="visible"
}

function hidemenu(elmnt)
{
	document.getElementById(elmnt).style.visibility="hidden"
}

function DoPrint()
{
	window.open('PrintPage.asp','PrintPage','width=770,height=550,scrollbars=yes')
}

function DoContact()
{
	if(isWhitespace(ClientForm.salutation.value))
	{
		alert("Please select Salutation.");
		ClientForm.salutation.focus();
	}
	else if(isWhitespace(ClientForm.last_name.value))
	{
		alert("Please enter Last Name.");
		ClientForm.last_name.focus();
	}
	else if(isWhitespace(ClientForm.first_name.value))
	{
		alert("Please enter First Name.");
		ClientForm.first_name.focus();
	}
	else if(!(isEmail(ClientForm.email.value)))
	{
		alert("Please enter valid Email address.");
		ClientForm.email.focus();
	}
	else if(isWhitespace(ClientForm.country.value))
	{
		alert("Please enter Country.");
		ClientForm.country.focus();
	}
	else if(ClientForm.industry.selectedIndex==0)
	{
		alert("Please choose Industry.");
		ClientForm.industry.focus();
	}
	
	else
	{
	
		ClientForm.state.value=ClientForm.state1__c.options(ClientForm.state1__c.selectedIndex).text;
		ClientForm.action = "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
		ClientForm.submit();
	}
}

function DoSupport()
{
	if(isWhitespace(ClientForm.name.value))
	{
		alert("Please enter Name.");
		ClientForm.name.focus();
	}
	else if(!(isEmail(ClientForm.email.value)))
	{
		alert("Please enter valid Email address.");
		ClientForm.email.focus();
	}
	else if(isWhitespace(ClientForm.Product.value))
	{
		alert("Please select Product.");
		ClientForm.Product.focus();
	}
	else if(isWhitespace(ClientForm.reason.value))
	{
		alert("Please select Case Reason.");
		ClientForm.reason.focus();
	}
	else if(isWhitespace(ClientForm.subject.value))
	{
		alert("Please enter Subject.");
		ClientForm.subject.focus();
	}
	else
	{
		ClientForm.action = "https://www.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8";
		ClientForm.submit();
	}
}

function SearchSite()
{	
	kw = document.SearchFrom.kw.value;
	
	if(isWhitespace(kw))
	{
		alert("Please enter at least 2 Chars.");
	}
	else if(kw.length < 2)
	{
		alert("Please enter at least 2 Chars.");
	}
	else
	{
		document.SearchFrom.submit();
	}
}

function checkForEnter(event, Str)
{     
    var code = 0;
    
    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
    if (code==13)
        eval(Str);
}

function open_close_ans(idd)
{
	if (eval('document.getElementById("'+idd+'").style.display==""'))
	{
		eval('document.getElementById("'+idd+'").style.display="none"')
	}
	else
	{
		eval('document.getElementById("'+idd+'").style.display=""');
	} 
}

function hmenu()
{
																					if(ClientForm.country.options(ClientForm.country.selectedIndex).text == "United States")
	{
		ClientForm.state1__c.options(ClientForm.state1__c.selectedIndex).text ="Alabama"
		ClientForm.state1__c.disabled = false
		//ClientForm.state.disabled = true
	}
	else
	{
		ClientForm.state1__c.options(ClientForm.state1__c.selectedIndex).text ="Non US"
		ClientForm.state1__c.disabled =true 
		ClientForm.state.value=""
		ClientForm.state.disabled=false
	}
}