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 sendContact()
{
	if(isWhitespace(sendCont.txtName.value))
	{
		alert("Please enter Name.");
		sendCont.txtName.focus();
	}
	else if(isWhitespace(sendCont.txtTitle.value))
	{
		alert("Please enter Title.");
		sendCont.txtTitle.focus();
	}
	else if(isWhitespace(sendCont.txtCompany.value))
	{
		alert("Please enter Company.");
		sendCont.txtCompany.focus();
	}
	else if(!(isEmail(sendCont.txtEmail.value)))
	{
		alert("Please enter valid Email address.");
		sendCont.txtEmail.focus();
	}
	else if(isWhitespace(sendCont.txtIntrest.value))
	{
		alert("Please select company intrest.");
		sendCont.txtIntrest.focus();
	}	
	else if(isWhitespace(sendCont.txtCountry.value))
	{
		alert("Please enter Country.");
		sendCont.txtCountry.focus();
	}
	else
	{
		sendCont.action = "Contact_Form.asp"
		sendCont.submit();
	}
}

function checkForEnter(event, Str)
{     
    var code = 0;
    
    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
    if (code==13)
        eval(Str);
}

function openPage(url)
{
	window.open(url,"_blank","width=700,height=600,scrollbars=1,resizable=1");
}

function DoPrint()
{
	window.open('PrintPage.asp','PrintPage','width=770,height=550,scrollbars=yes')
}

function ClientContact()
{
	if(isWhitespace(ClientForm.txtFirstName.value))
	{
		alert("Please enter First Name.");
		ClientForm.txtFirstName.focus();
	}
	else if(isWhitespace(ClientForm.txtLastName.value))
	{
		alert("Please enter Last Name.");
		ClientForm.txtLastName.focus();
	}
	else if(!(isEmail(ClientForm.txtEmail.value)))
	{
		alert("Please enter correct email address.");
		ClientForm.txtEmail.focus();
	}
	else if(isWhitespace(ClientForm.txtSubject.value))
	{
		alert("Please enter Subject.");
		ClientForm.txtSubject.focus();
	}
	else if(isWhitespace(ClientForm.strCAPTCHA.value))
	{
		alert("Please enter Security Code.");
		ClientForm.strCAPTCHA.focus();
	}
	else
	{
	ClientForm.submit();		
	}	
}

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 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 showmenu(elmnt)
{
	document.getElementById(elmnt).style.visibility="visible"
}

function hidemenu(elmnt)
{
	document.getElementById(elmnt).style.visibility="hidden"
}