function SignIn() {
	var url = '';
}

function SignOut() {
	//window.top.location = '/signout.asp';
}

var newWindow = null;

function GalleryWin(url) {
	window.name = "MainWin";
	winl = (screen.width) ? parseInt((screen.width - 766)/2) : 0;
	wint = (screen.height) ? parseInt((screen.height - 426)/2) : 0;
	newWindow = window.open(url,"GalleryWin",'height=426,width=766,top='+wint+',left='+winl+',scrollbars=no,resizable=no');
	if (newWindow.window.focus) newWindow.window.focus();
}

function HelpWin(url) {
	try {
		window.name = "MainWin";
		winl = (screen.width) ? parseInt((screen.width - 380)/2) : 0;
		wint = (screen.height) ? parseInt((screen.height - 380)/2) : 0;
		newWindow = window.open(url,"HelpWin",'height=380,width=380,top='+wint+',left='+winl+',scrollbars=no,resizable=no');
		if (newWindow.window.focus) newWindow.window.focus();
		return false;
	} catch(e) {
		return true;
	}
}

function PopWin(url) {
	window.name = "MainWin";
	winl = (screen.width) ? parseInt((screen.width - 380)/2) : 0;
	wint = (screen.height) ? parseInt((screen.height - 380)/2) : 0;
	newWindow = window.open(url,"HelpWin",'height=380,width=380,top='+wint+',left='+winl+',scrollbars=yes,resizable=yes');
	if (newWindow.window.focus) newWindow.window.focus();
}

function randomizer(URL) {
	window.open(URL,'Randomizer','width=350,height=290,resizable=yes, scroll=yes, top=200,left=380,alwaysRaised=yes');
}

function NavBarGoHome() {
	var lnkHome = document.getElementById("t-home");
	if (lnkHome && lnkHome.href != 'undefined')
	{
		var searchParams = "&txtkeys1=" + GetSearchParameter("txtkeys1");
		searchParams = searchParams + "&chkRMFilter=" + GetSearchParameter("chkRMFilter");
		searchParams = searchParams + "&chkRFFilter=" + GetSearchParameter("chkRFFilter");
		searchParams = searchParams + "&lstImageType=" + GetSearchParameter("lstImageType");
		searchParams = searchParams + "&imgextra0=" + GetSearchParameter("imgextra0");
		searchParams = searchParams + "&imgextra1=" + GetSearchParameter("imgextra1");
		searchParams = searchParams + "&imgextra2=" + GetSearchParameter("imgextra2");
		searchParams = searchParams + "&imgextra3=" + GetSearchParameter("imgextra3");
		searchParams = searchParams + "&chkorientsh=" + GetSearchParameter("chkorientsh");
		searchParams = searchParams + "&chkorientsv=" + GetSearchParameter("chkorientsv");
		searchParams = searchParams + "&chkbw=" + GetSearchParameter("chkbw");
		searchParams = searchParams + "&chkcolor=" + GetSearchParameter("chkcolor");
		lnkHome.href = lnkHome.href + searchParams;
	}
}

function NavBarGoCart() {
	window.top.location = "/cart.asp";
}

// Karn 2007.08.07 - this is so we can change the Lightbox on the Lightbox page and
// still have the nav link carry the correct LightboxID
//var lstpasteboards = "<%= Session("CurrentLightboxID") %>";
function NavBarGo(action, tag) {
    if (tag == "results") {
	document.formnavbar.action = "/resultsframe.asp";
	document.formnavbar.btnshow.value = "1";
    }
    else {
	document.formnavbar.action = action;
    }

    document.formnavbar.sender.value = GetCurrentPage();
    document.formnavbar.tag.value = tag;
    document.formnavbar.submit();
}

function NavBarLightbox() {
	var ie = (document.all)? true:false
	if (ie)
		document.formnavbar.action = "/lightboxiframes.asp";
	else
		document.formnavbar.action = "/lightboxmove.asp";

	document.formnavbar.submit();
}

function GetCurrentLightboxID() {
	var LightboxID = "";
	var lowerFrame = window.parent.parent.frames["bottomFrame"];
	if (lowerFrame)
	{
		var myForm = lowerFrame.document.forms["myform"];

		if (myForm)
		{
			LightboxID = myForm.pb.value;
		}
	}

	return LightboxID
}

function GetCurrentPage() {
	var page = "";
	var path = new String(window.location);
	var slash = path.lastIndexOf('/');
	if (slash > 0 && slash < path.length)
	{
		path = new String(path.substring(slash + 1));
		var dot = path.lastIndexOf('.');
		if (dot > 0)
		{
			page = path.substring(0, dot);
		}
	}
	return page;
}

function GetSearchParameter(param) {
	var paramValue = "";
	var mainFrame = window.parent.parent.frames["mainFrame"];
	if (mainFrame)
	{
		var searchBox = mainFrame.document.forms["frmSearch"];
		if (searchBox)
		{
			var elem = null;

			if (param == "txtkeys1")
			{
				elem = searchBox.txtkeys1;
				if (elem) { paramValue = elem.value; }
			}
			else if (param == "lstImageType")
			{
				elem = searchBox.lstImageType;
				if (elem) { paramValue = elem.options[elem.selectedIndex].value; }
			}
			else
			{
				if (param == "chkRMFilter") { elem = searchBox.chkRMFilter; }
				else if (param == "chkRFFilter") { elem = searchBox.chkRFFilter; }
				else if (param == "imgextra0") { elem = searchBox.imgextra0; }
				else if (param == "imgextra1") { elem = searchBox.imgextra1; }
				else if (param == "imgextra2") { elem = searchBox.imgextra2; }
				else if (param == "imgextra3") { elem = searchBox.imgextra3; }
				else if (param == "chkorientsh" ) { elem = searchBox.chkorientsh; }
				else if (param == "chkorientsv" ) { elem = searchBox.chkorientsv; }
				else if (param == "chkbw") { elem = searchBox.chkbw; }
				else if (param == "chkcolor") { elem = searchBox.chkcolor; }

				if (elem && elem.checked == true) { paramValue = elem.value; }
			}
		}
	}

	return paramValue;
}

function SubmitCountrySelection() {
	//set page over again

	var NavBarCountryList = document.getElementById("NavBarCountryList");
	var option = NavBarCountryList.options[NavBarCountryList.selectedIndex];

	document.FormCountryPicked.FCP_UserCountryID.value = option.value;
	document.FormCountryPicked.FCP_Country.value = option.text;
	document.FormCountryPicked.FCP_Action.value = "SelectCountry";
	document.FormCountryPicked.action = document.location.href;
	if (typeof(document.frmSearch) != 'undefined')
	{
		document.FormCountryPicked.FCP_SearchVals.value = form2ArrayString(document.frmSearch);
	}
	document.FormCountryPicked.submit();
}

function ClearCountry() {
	document.FormCountryPicked.FCP_UserCountryID.value = "";
	document.FormCountryPicked.FCP_Country.value = "";
	document.FormCountryPicked.FCP_Action.value = "ClearCountry";
	document.FormCountryPicked.submit();
}

function LoadSearchVals() {
	var oldSearchFormVals = '';
	if (oldSearchFormVals.length > 0)
	{
		if (typeof(document.frmSearch) != 'undefined')
		{
			string2FormObj(document.frmSearch, oldSearchFormVals);
		}
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}
addLoadEvent(LoadSearchVals);