﻿// JScript File
function GoToTop() {
    window.scrollTo(0, 0);
}
function RedirectMe(where)
{
	window.document.location.href = where;
}
function endsWith(str, s)
{
	var reg = new RegExp(s + "$");
	return reg.test(str);
}
function fnReset(frm) 
{
    frm.reset();
    for(var i=0; i<=frm.elements.lemgth; i++)
    {
	    if((frm.elements[i].type == "text")||(frm.elements[i].type == "password")||(frm.elements[i].type == "textarea"))
	    {
		    frm.elements[i].value = "";
	    }
	    else if(frm.elements[i].type == "select-one")
	    {			
		    frm.elements[i].selectedIndex = 0;
	    }
	}
	return false;
}
function closeMe()
{
	window.close();
}
function isText(val)
{	
    var reText = /\S+$/;
    if(reText.test(val) == true)
	    return true;
    else
	    return false;	
}
function leftTrim(sString)
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    return sString;
}
function rightTrim(sString)
{
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}
function trimAll(sString)
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function openChildWindow(page, specs, w, h, scroll, resize) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable=' + resize;
    window.open(page, specs, winprops);
}

function GoEmailSignup(urlpath) {
    RedirectMe(urlpath + "/NewsletterSignup.aspx");    
}
function GoSearch(urlpath) 
{
    var q = document.getElementById("txtSearch").value;
    if (q == "") 
    {
        alert("Enter your keyword and press the 'Search' button");
        document.getElementById("txtSearch").focus();
    }
    else 
    {
        var u = urlpath + "/Search.aspx?q=" + q;
        RedirectMe(u);
    }
}
function logout(urlpath) {
    if (confirm('Are you sure to logout from Blackhawk website?')) {
        RedirectMe(urlpath + "/Login.aspx?l=1");
    }
}      
