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 open_close_ans(idd)
{
	if (eval('document.getElementById("'+idd+'").style.display==""'))
	{
		eval('document.getElementById("'+idd+'").style.display="none"')
		eval('document.getElementById("'+idd+'_img").src="images/plus.gif"')
	}
	else
	{
		eval('document.getElementById("'+idd+'").style.display=""');
		eval('document.getElementById("'+idd+'_img").src="images/minus.gif"')
	} 
}

function ChangeCareer(Str)
{
	if (Str == 0)
		window.location.href = "Careers.asp";
	else
		window.location.href = "Careers.asp?cID=" + Str;
}

var http_request = false;
var Get_http_response;

function makeRequest(url) 
{
	if(!(isWhitespace(document.form1.Username.value)) && !(isWhitespace(document.form1.Password.value))) 
	{
		url=url+"?username="+document.form1.Username.value +"&password="+document.form1.Password.value+"&Status=1";
		http_request = false;
		if (window.XMLHttpRequest) 
		{ // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) 
			{
				http_request.overrideMimeType('text/xml');
			}
		}
		else if (window.ActiveXObject) 
		{ // IE
			try 
			{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) 
			{
				try 
				{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e) {}
			}
		}
		
		if (!http_request) 
		{
			alert("Cannot create an XMLHTTP instance");
			return false;
		}
		http_request.onreadystatechange = alertContents;
		http_request.open('POST', url, true);
		http_request.send(null);
	}
	else
	{
		alert("Please enter Username & Password.");
	}
}

function alertContents() 
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{
			Get_http_response=http_request.responseText;
			if (Get_http_response=="0")
			{
				document.all.myerror.style.display="inline";
			}
			else if (Get_http_response=="1")
			{
				document.location.href = document.form1.returnUrl.value;
			}
		} 
	else
		{
			alert('There was a problem with the request.');
		}
	}
}

function MM_goToURL() 
{
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function DoPrint()
{
	window.open('PrintPage.asp','PrintPage','width=770,height=550,scrollbars=yes')
}

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 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 NewsArchive(Str)
{
	if (Str != "")
	{
		self.location.href = "News.asp?year=" + Str;
	}
	else
	{
		self.location.href = "News.asp";
	}
}

function InvestNewsArchive(Str)
{
	if (Str != "")
	{
		self.location.href = "InvestNews.asp?year=" + Str;
	}
	else
	{
		self.location.href = "InvestNews.asp";
	}
}

function FlipUrl(Str)
{
	if (Str != "")
	{
		self.location.href = Str;
	}
}

function popUp(url) 
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=440,height=310');
	self.name = "mainWin"; 
}