function ovr(in_td) {
	if (in_td.className == 'largeButtonBrownOff') {
		in_td.className = 'largeButtonBrownOver';
		
	} else if (in_td.className == 'largeButtonBlueOff'){
	    in_td.className = 'largeButtonBlueOver';
	}
}

function off(in_td) {
	if (in_td.className == 'largeButtonBrownOver') {
		in_td.className = 'largeButtonBrownOff';
		
	} else if (in_td.className == 'largeButtonBlueOver'){
	    in_td.className = 'largeButtonBlueOff';
	}
}

function validateNewsletter(){
    var retValid = true;
    var strError = '';
    var focusField = '';
    var atpos = -1;
    var dotpos = -1;
	var chkError = true;
	var chkIndex = 0;
    
    // validate bottom up, so that the highest error field winds up with the focus
    if (document.getElementById('eMail').value + '' == ''){
        strError += '\nYou must provide an eMail address.\n';
        focusField = 'eMail';
    } else {
        atpos = document.getElementById('eMail').value.indexOf("@")
        dotpos = document.getElementById('eMail').value.lastIndexOf(".")

        if ((atpos == -1) || (dotpos == -1) || (dotpos < (atpos + 2))) {
            strError += '\nYou must provide a valid eMail address.\n';
            focusField = 'eMail';
        }
    }
    
	// arrChkName is created and populated by ASP.NET

	// see:
	// App_Code/dgFuncs.vb and App_Code/frmNewsletter

	for (chkIndex = 0; chkIndex < arrChkName.length ; chkIndex++){
		if (document.getElementById(arrChkName[chkIndex]).checked == true){
			chkError = false;
		}
	}

    if (chkError){
        strError += '\nYou didn\'t choose either eNewsletter.\n';
    }
    
    if (strError != ''){
        alert(strError);
        if (focusField != ''){
            document.getElementById(focusField).focus();
            document.getElementById(focusField).select();
        }
		retValid = false;
    }
    return retValid;
}

function validateSearch(){
    var retValid = true;
    var strError = '';
    var focusField = '';
    
    // validate bottom up, so that the highest error field winds up with the focus
    if (document.getElementById('terms').value + '' == ''){
        strError += '\nYou must provide search keywords.\n';
        focusField = 'txtSearch';
    }
    
    if (strError != ''){
        alert(strError);
        if (focusField != ''){
            document.getElementById(focusField).focus();
            document.getElementById(focusField).select();
        }
    retValid = false;
    }
    return retValid;
}

function doSearch(){
    if (validateSearch()){
        document.forms.frmSearch.submit();
    }
}

function doNewsletter(){
    //if (validateNewsletter()){
		
        document.forms.frmNewsletter.submit();
    //}
}

function doNamedNewsletter(x)
{
 document.forms[x].submit();
}

function getCookie(NameOfCookie){

	if (document.cookie.length > 0){ 

	begin = document.cookie.indexOf(NameOfCookie+"="); 
	if (begin != -1){ 

	begin += NameOfCookie.length+1; 
	end = document.cookie.indexOf(";", begin);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(begin, end)); } 
	}
	return ''; 

}

function setCookie(NameOfCookie, value, expiredays){

	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

	document.cookie = NameOfCookie + "=" + escape(value) + 
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie){

	if (getCookie(NameOfCookie)) {
	document.cookie = NameOfCookie + "=" +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function doCTAR(prod_id, cid){
    var qty = parseInt(document.getElementById('qright').value);
    if (!isNaN(qty)){
        if (qty < 1){
            qty = 1;
        }
    } else {
        qty = 1;
    }
    location.href = 'https://store.legalworkplace.com/ahiStore1/basket.aspx?Product_ID=' + prod_id + '&Quantity=' + qty + '&ekpsid=' + cid;
}

function doCTAB(prod_id, cid){
    var qty = parseInt(document.getElementById('qbottom').value);
    if (!isNaN(qty)){
        if (qty < 1){
            qty = 1;
        }
    } else {
        qty = 1;
    }
    location.href = 'https://store.legalworkplace.com/ahiStore1/basket.aspx?Product_ID=' + prod_id + '&Quantity=' + qty + '&ekpsid=' + cid;
}

function doNewsletterRR(){

document.forms[2].submit();

    }
