
// Function to post to URL

function doPost(sLocation)
{
	if(sLocation!="")
		window.location=sLocation;
	else
		alert("Location is undefined");
}



// Functions from existing site

if (document.images){

        status_open = new Image();status_close = new Image();

        status_open.src = "https://imagesak.securepaynet.net/aaa/sb/bul_open.gif";status_close.src = "https://imagesak.securepaynet.net/aaa/sb/bul_close.gif";}



function gosb(url,t){

        if(t == "")t="_self";window.open(url,t);}



function sbStatus(){

        var dpClosed = false;

        var item = new Array("qs","mc","ma","s","e","rp","b","cr","mr","mn","rg"); //sidebar open/close

        for(x=0;x<item.length;x++){

                if(getCookie('sidebar_' + item[x]) == "1"){

                        if(document.images [item[x]+"_img"]) document.images [item[x]+"_img"].src = status_close.src;

                        if(document.getElementById(item[x]+'_div')) document.getElementById(item[x]+'_div').style.display = "";

                        if((item[x]=="rp")||(item[x]=="s")) dpClosed = true;}

        }



        var item = new Array("customize","test");//landing page open/close

        for(x=0;x<item.length;x++){

                if(getCookie('sidebar_' + item[x]) == "1"){

                        if (document.images [item[x]+"_img"]){

                                document.images [item[x]+"_img"].src = status_open.src;document.getElementById(item[x]+'_div').style.display = "none";}

}}}



function checkHome(item)

{

        //homepage sidebar hasn't been activated yet, reload

        var url = "https://www.securepaynet.net/gdshop/default.asp?prog%5Fid=433206&app%5Fhdr=&sb=1&item=sbitem";

        url = url.replace('sbitem', item);window.open(url,'_self');}



function togSB(item){

        if(document.images [item+"_img"])        document.images [item+"_img"].src = (document.images [item+"_img"].src == status_open.src) ? status_close.src:status_open.src;

        if(document.getElementById(item+'_div')) document.getElementById(item+'_div').style.display = (document.getElementById(item+'_div').style.display=="none") ? "":"none";

        if(getCookie('sidebar_' + item) == "1"){

                eraseCookie('sidebar_' + item);

                if((document.getElementById('dp_divB'))&&(getCookie('sidebar_rp') != "1")&&(getCookie('sidebar_s') != "1")) document.getElementById('dp_divB').style.display = "";

        }

        else{

                createCookie('sidebar_' + item,1,'');

                if((document.getElementById('dp_divB'))&&((getCookie('sidebar_rp') == "1")||(getCookie('sidebar_s') == "1"))) document.getElementById('dp_divB').style.display = "none";

}}



function linkSB(url){

        location.href = url;}



function createCookie(name,value,days){

        if (days){

                var date = new Date();

                date.setTime(date.getTime()+(days*24*60*60*1000));

                var expires = "; expires="+date.toGMTString();}

        else var expires = "";

        document.cookie = name+"="+value+expires+"; path=/";

}



function getCookie(name){

        var nameEQ = name + "=";

        var ca = document.cookie.split(';');

        for(var i=0;i < ca.length;i++){

                var c = ca[i];

                while (c.charAt(0)==' ') c = c.substring(1,c.length);

                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}

        return null;

}



function eraseCookie(name){

        createCookie(name,"",-1);}



function editSBselected(theForm, theVal, theDomain){

        if (theVal){

                theForm.searchSBselected.value = theForm.searchSBselected.value + '|' + theDomain + '|'}

        else{

                var theStr = theForm.searchSBselected.value;theStr = theStr.replace('|' + theDomain + '|', '');theForm.searchSBselected.value = theStr

}}



function checkSBDomain(searchForm){

        var canSubmit = false;

        var searchValue;

        if ('' == '' && searchForm.domainToCheck){

                searchValue = searchForm.domainToCheck.value;

                if (searchValue != ''){

                        var regExInvalidChars = /[^a-zA-Z0-9-\s.]+/;

                        if (regExInvalidChars.test(searchValue)){

                                alert('Invalid character in domain.\n\nOnly letters, numbers or hyphens are allowed.')}

                        else{

                        canSubmit = true;}

                }

        }

        if (canSubmit){

                return true;

        }

        else{

                return false;}

}

