// common.js - This file should be included in most (if not all) of the gapinc.com redesign templates
function openPopupWindow(url)
{
	window.open(url,"popupWindow","width=620,height=500,directories=no,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes");
}

function printFriendly()
{
	if (document.getElementById != null)
	{
		var html = '<HTML class="printerFriendly">\n<HEAD>\n';
		var headTags = document.getElementsByTagName("head");
		html += headTags[0].innerHTML;
		html += '\n</HEAD>\n<BODY><TABLE class="border" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"><TR><TD class="closeWindow" width="500"><IMG height="34" alt="Gap Inc." src="/public/images/00_x_global/x_printerbar_summer.gif" width="500" /></TD><TD class="closeWindow" width="110"><A href="javascript:window.close()">close window</A></TD></TR></TABLE>';
		html += '<br /><table cellspacing="0" cellpadding="0"  align="center" width="500"><tr><td>';
		
		var printPageElem = (document.getElementById("pf1").innerHTML) + (document.getElementById("pf2").innerHTML) + (document.getElementById("pf3").innerHTML) + (document.getElementById("pf4").innerHTML) + (document.getElementById("pf5").innerHTML);
		html += printPageElem;
		html += '</td></tr></table>';		
		html += '</BODY>\n</HTML>';
		
		var printWin = window.open("GapInc.","pf1","height=450,width=630,directories=no,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolbar=yes");
		printWin.document.open();
		printWin.document.write(html);
	}
	else
	{
		alert("Sorry, the printer friendly feature works\nonly in javascript enabled browsers.");
	}
}

function processPulldown(pulldownId,openNewWindow)
{
	var pulldownObject=document.getElementById(pulldownId);
	var selectedOption=pulldownObject.options[pulldownObject.selectedIndex].value;

	if (selectedOption.length > 0)
	{
		if (openNewWindow)
			openPopupWindow(selectedOption);
		else
			self.location=selectedOption;
	}
}
