﻿

function checkdefaultterm() {
    var dft = $('hfDefaultTerm').value;
    if (dft != null || dft != "") {
        if ($('topterm_' + dft) != null) {
            $('topterm_' + dft).checked = true;
        }
    }
}


function checkterm(id) {

    //alert(id);
    $(id).checked = true;    
    $('topterm_' + id).checked = true;

}


function validateEmail(emailaddress) {
    //alert('validate');
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;    
    if (!emailaddress.match(emailRegEx)) {
        //alert('return false');
        return false;
    }
    return true;
}


/*
    This function is used to make sure the "I Accept" 
    check box on landing pages is checked - BWH 01/30/07
*/
function acceptCheckScript(isForm) 
{
  var doc = document.forms[0];
	if (doc == null) return true;

	var checkAgree1 = null;
	var checkAgree2 = null;
	if (doc.chkAgree != null)
	{
		checkAgree1 = doc.chkAgree;
	}
	else
	{
//		alert("Check agree 1 is null");
	}
	
	if (doc.chkAgree2 != null)
	{
		checkAgree2 = doc.chkAgree2;
	}
	else
	{
//		alert("Check agree 2 is null");
	}

	if (checkAgree1 != null && checkAgree2 != null)
	{
		if (checkAgree1.checked || checkAgree2.checked)
		{
			return true;
		}
		alert("Please agree to our Terms and Conditions and then click \"Buy Now\"");
		return false;
	}
    
	if (checkAgree1 != null)
	{
		if (checkAgree1.checked)
		{
			return true;
		}
		alert("Please agree to our Terms and Conditions and then click \"Buy Now\"");
		return false;
	}

	if (checkAgree2 != null)
	{
		if (checkAgree2.checked)
		{
			return true;
		}
		alert("Please agree to our Terms and Conditions and then click \"Buy Now\"");
		return false;
	}
	
	return true;
}

/*
 Try to use the OpenWindow function to open pop-up windows whenever possible. - BWH 0201/07
 winURL = the URL of the page
 winParameters = all the specific window parameters
 EXAMPLE: OpenWindow('/members/sdb/blah.aspx', 'width=450, height=500')
 */
function OpenWindow(winUrl, winParameters)
{
	window.open(winUrl, "SIRWindow", winParameters);
}

function GetQuote()
{
	var strNewUrl;
	var strSearchTerm;

	strSymbol = document.getElementById("headerquote").value;
	strNewUrl = "/streetools/stock_quotes.aspx?ticker_symbol=" + escape(strSymbol);
	window.location = strNewUrl;
}

function prodpop(popupID)
{
	window.open("bernie_guidance.aspx?popupID=" + popupID,"prodpop","width=450,height=550, location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left=10,top=10,screenx=10,screeny=10");
}

function prodpop1(popupID)
{
	window.open("Disclaimer.aspx?ProductLineID=" + popupID,"prodpop","width=450,height=550, location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left=10,top=10,screenx=10,screeny=10");
}

function prodpop2(popupID)
{
	window.open("Disclaimer.aspx?DisclaimerID=" + popupID,"prodpop","width=450,height=550, location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left=10,top=10,screenx=10,screeny=10");
}

function swapdiv(idShow, idHide) {
    hidediv(idHide);
    showdiv(idShow);
}


function hidediv(id) {
    //safe function to hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}

function showdiv(id) {
    //safe function to show an element with a specified id

    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
