// JavaScript Document

var emailChanged=0;

function setContents(cID,cHTML) {
	var tmpCnt = document.getElementById(cID);  
	if (cHTML == '') {
		tmpCnt.innerHTML = '&nbsp;';
	} else {
		tmpCnt.innerHTML = cHTML;
	}

}

function viewCoupon(vcID) {
	var URL = "/MarketPlace/Coupon.asp?vcID=" + vcID;
	//var windowAttributes = "width=500,height=360,toolbar=0,menubar=0,scrollbars=0,resizable=0,status=0,location=0,directories=0,copyhistory=0,left=120,top=120"
	//windowVar = window.open(URL, "south_gate_CW", windowAttributes);
	location.href = URL;
}

function setContentsDyn(cID,cObj) {
	var container = document.getElementById(cID);  
	container.innerHTML = eval(cObj);

}


function setClassName(src,newClassName) {
	//src.className = newClassName;
	var tmpObj = document.getElementById(src);
	tmpObj.className = newClassName;
}


function toggleDisplay(divId) {
	divStyle = document.getElementById(divId).style;
	if ( (divStyle.display == "block") || (divStyle.display == "") ) {
		divStyle.display = "none";
	} else {
		divStyle.display = "block";
	}
}

function toggleClass(className1, className2) {
	currClass = this.className;
	if ( currClass == className1 ) {
		currClass = className2;
	} else {
		currClass = className1;
	}
}



function showDiv(divId) {
	divStyle = document.getElementById(divId).style;
	divStyle.display = "block";
}

function hideDiv(divId) {
	divStyle = document.getElementById(divId).style;
	divStyle.display = "none";
}

function helpWin(anchorPoint) {
	var URL = "/lib/glossary.asp#" + anchorPoint;
	var windowAttributes = "width=360,height=400,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,copyhistory=0,left=120,top=120"
	windowVar = window.open(URL, "south_gate_RW", windowAttributes);
}

function openWin(URL,width,height) {
	var windowVar;
	var leftPos, topPos, wdwWidth, wdwHeight;
	wdwWidth = width;
	wdwHeight = height;
	leftPos = screen.width/2 - wdwWidth/2;
	topPos = screen.height/2 - wdwHeight/2 - 60;
	var windowAttributes = "width=" + wdwWidth + ",height=" + wdwHeight + ",toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,copyhistory=0,left=" + leftPos + ",top=" + topPos + ""
	windowVar = window.open(URL, "south_gate_RW", windowAttributes);
}

function openWin2(URL,width,height,newParams) {
	var windowVar;
	var leftPos, topPos, wdwWidth, wdwHeight;
	wdwWidth = width;
	wdwHeight = height;
	leftPos = screen.width/2 - wdwWidth/2;
	topPos = screen.height/2 - wdwHeight/2 - 60;
	var windowAttributes = "width=" + wdwWidth + ",height=" + wdwHeight + ",toolbar=0,menubar=0,resizable=0,status=0,location=0,directories=0,copyhistory=0,left=" + leftPos + ",top=" + topPos + "," + newParams + "";
	windowVar = window.open(URL, "south_gate_RW", windowAttributes);
}


	function act(imgName) {
		if (document.images) {
			document [imgName].src = eval(imgName + "_on.src");
		}
	}
	
	function deact(imgName) {
		if (document.images) {
			document [imgName].src = eval(imgName + "_off.src");
		}
	}

	function mOvr(src) { if (!src.contains(event.fromElement)){src.bgColor = '#003663';src.children(0).style.color='#FFFFFF'}}
	function mOut(src) { if (!src.contains(event.toElement))  {src.bgColor = '#C1D0E0';src.children(0).style.color='#000000'}}



var gAutoPrint = false; // Flag for whether or not to automatically call the print function

function printerFriendlyVC() {
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY>\n';
		html += '<BR><center><table border=0 width=430 cellpadding=0 cellspacing=0><TR><TD><img src=/images/South_Gate_CA_logo.jpg width=160 height=60></TD><TD align=right>';
		html += '<H2>Virtual Coupon</H2></TD></TR></table></center><BR>';
		
		var printReadyElem = document.getElementById("printReadyVC");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
		var printWin = window.open("","printerFriendly");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		var detect = navigator.userAgent.toLowerCase();
		if (gAutoPrint && (detect.indexOf("netscape") == -1) )
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}
