/*
		document.SUPEForm.eRequestedPageType.value = "";
		document.SUPEForm.ListingAgentFormat.value = "";
		document.SUPEForm.ClassID.value = "";
		document.SUPEForm.ProductID.value = "";
		document.SUPEForm.Tab.value = "";
		document.SUPEForm.DoSetCookie.value = "off";
		document.SUPEForm.Alphabet.value = "";
		document.SUPEForm.DisableViewSwtich.value = "false";
		document.SUPEForm.PageBossPageNumber.value = "";
		document.SUPEForm.ListBossPageNumber.value = "";
		document.SUPEForm.IProdItemId.value = "";
*/
var isWebService = false;
var isLocalhost = false;
if(document.location.href.indexOf("localhost") != -1)
	isLocalhost = true;

var isCaseyTextArea = false;
if(document.location.href.indexOf("caseytextarea") != -1)
	isCaseyTextArea = true;

// Submit Function for Summary Page
function submitFormSummary(InterstitialSelection, TypeChoice, ChoiceID) // THIRD PARAMETER IS OPTIONAL
{ 
	if( InterstitialSelection == "1" ) 
		InterstitialSelection =  "eSYPE";
	else 
		InterstitialSelection =  "eSUPE";

	setAction(InterstitialSelection);  // Set PageBossPage or ListBossPage

	document.SUPEForm.eRequestedPageType.value = TypeChoice;  // Method call parameter will specify the appropriate use case.
	document.SUPEForm.DisableViewSwitch.value = "false";
	document.SUPEForm.ListingAgentFormat.value = InterstitialSelection;

	if(ChoiceID != null)
		document.SUPEForm.ClassID.value = ChoiceID;  // Capture ID of user's choice.
	else
		document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.

	document.SUPEForm.submit();
}

// Submit Function for Interstitial Page
function submitFormInterstitial(Format, SetCookie, DoForward)
{
	document.SUPEForm.eRequestedPageType.value = "Summary";  // return to Summary Use case
	document.SUPEForm.ListingAgentFormat.value = Format;  // Go to User Specified Format
	if(DoForward == true)
	{
		setAction(Format);  // Force Action to ListBossPage or PageBossPage
		document.SUPEForm.DisableViewSwitch.value = "false";
	}
	else
	{
		setAction("Interstitial");  // Force Action to SumaryPage
	}
	document.SUPEForm.DoSetCookie.value = SetCookie;  // Whether user wants cookie set or not
	document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.
	document.SUPEForm.submit();
}

// Interstitial Cookie Checkbox Function
var SetCookie = "off";
function SetUpHrefForCookie()
{
	if(SetCookie == "on")
		SetCookie = "off";
	else
		SetCookie = "on";
	document.all.PBHref = "javascript:submitFormInterstitial('eSYPE','" + SetCookie + "')";
	document.all.LBHref = "javascript:submitFormInterstitial('eSUPE','" + SetCookie + "')";
}

// Submit Function for Related Classification Picker
function submitFormRelatedClass(TypeChoice, ClassID){
	document.SUPEForm.ListingAgentFormat.value = "eSUPE"; // keep SUPE as listing agent since it can cause problems
	document.SUPEForm.eRequestedPageType.value = TypeChoice;  // Uses ListingsByClass use case only for now.
	document.SUPEForm.ClassID.value = ClassID;  // Capture ID of user's choice.
	document.SUPEForm.submit();
}

// Submit Function for Next/Prev in ListBoss
function submitFormNextPrev(TypeChoice, PageNum){
	document.SUPEForm.eRequestedPageType.value = TypeChoice;  // Method call parameter will specify the appropriate use case.
	document.SUPEForm.ListBossPageNumber.value = PageNum;  // Specifies what page to display.
	document.SUPEForm.ListingAgentFormat.value = "eSUPE"; // keep SUPE as listing agent since it can cause problems
	document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.
	document.SUPEForm.submit();
}

// Submit Function for Next/Prev in PageBoss
function submitFormPageNumber(PageNum)
{
	setAction("eSYPE");  // Force Action to PageBossPage to strip query string if necessary.
	document.SUPEForm.eRequestedPageType.value = "PageBossPage";  // Method call parameter will specify the appropriate use case.
	document.SUPEForm.PageBossPageNumber.value = PageNum;  // Specifies what page to display.
	document.SUPEForm.DisableViewSwitch.value = "true";  // Disables view switch.
	document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.
	document.SUPEForm.ListingAgentFormat.value = "eSYPE"; // keep SYPE as listing agent since it can cause problems
	document.SUPEForm.submit();
}

// Submit Function for AlphaBar
function submitFormAlpha(Alpha){
	document.SUPEForm.eRequestedPageType.value = "ListingsByAlpha";  // Specify the alpha use case
	document.SUPEForm.ListingAgentFormat.value = "eSUPE"; // switch SUPE for all alpha
	document.SUPEForm.Alphabet.value = Alpha;  // set the alpha selected character
	document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.
	document.SUPEForm.DisableViewSwitch.value = "false";  // Disables view switch.
	document.SUPEForm.submit();
	document.SUPEForm.Alphabet.value = "";
}

// Submit Function for ViewSwitch
function submitFormViewSwitch(TypeChoice, Format){
	if(document.SUPEForm.DisableViewSwitch.value == "false")
	{
	
		document.SUPEForm.eRequestedPageType.value = TypeChoice; // preserve the current use case.
		document.SUPEForm.ListingAgentFormat.value = Format; // switch to the other Format.
		setAction(Format);  // Force Action to ListBossPage or PageBossPage
		document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.
		//document.SUPEForm.DisableViewSwitch.value = "false";
		document.SUPEForm.submit();
	}
	
}

// Submit Function for PageBoss More Results
function submitFormMoreResults(){
	document.SUPEForm.eRequestedPageType.value = "PageBossMoreResult"; // preserve the current use case.
	document.SUPEForm.ListingAgentFormat.value = "eSYPE"; // switch to the other Format.
	document.SUPEForm.ClassID.value = "";  // Clear ID since it can cause problems.
	document.SUPEForm.submit();
}

// Submit Function for IProd
function submitFormIProd(productID, tab,IProdItemID)
{
	var isNewWindowOpen;
	isNewWindowOpen = !SUPENewWindowOpener('',800,600,'no'); // opens new window named "newWindow" with target "popUp"

	document.SUPEForm.ProductID.value = productID;  // send ProductID to IProd.
	document.SUPEForm.Tab.value = tab;  // send tab to IProd.
	document.SUPEForm.IProdItemID.value = IProdItemID;  // send IProdItemID to IProd.


	document.SUPEForm.target = "popUp"; // submit form to new window.
	document.SUPEForm.action = "http://Enhanced.ypsolutions.com/multitab.aspx"; // submit form to new window.
	document.SUPEForm.submit();
	document.SUPEForm.target = "";
	document.SUPEForm.action = "";
}

// Force Action to ListBossPage or PageBossPage
function setAction(Format)
{
	if (isWebService) return;
	if(Format == "Interstitial")
		if(isLocalhost && isCaseyTextArea)
			document.SUPEForm.action = "/MyAGUnitTester/SummaryPage.html?caseytextarea=on";  // Force Action to SummaryPage
		else if(isLocalhost && !isCaseyTextArea)
			document.SUPEForm.action = "/MyAGUnitTester/SummaryPage.html";  // Force Action to SummaryPage
		else if(!isLocalhost && isCaseyTextArea)
			document.SUPEForm.action = "/SummaryPage.html?caseytextarea=on";  // Force Action to SummaryPage
		else
			document.SUPEForm.action = "/SummaryPage.html";  // Force Action to SummaryPage
	else if(Format == "eSUPE")
		if(isLocalhost && isCaseyTextArea)
			document.SUPEForm.action = "/MyAGUnitTester/ListBossPage.html?caseytextarea=on";  // Force Action to ListBossPage
		else if(isLocalhost && !isCaseyTextArea)
			document.SUPEForm.action = "/MyAGUnitTester/ListBossPage.html";  // Force Action to ListBossPage
		else if(!isLocalhost && isCaseyTextArea)
			document.SUPEForm.action = "/ListBossPage.html?caseytextarea=on";  // Force Action to ListBossPage
		else
			document.SUPEForm.action = "/ListBossPage.html";  // Force Action to ListBossPage
	else if(Format == "eSYPE")
		if(isLocalhost && isCaseyTextArea)
			document.SUPEForm.action = "/MyAGUnitTester/PageBossPage.html?caseytextarea=on";  // Force Action to ListBossPage
		else if(isLocalhost && !isCaseyTextArea)
			document.SUPEForm.action = "/MyAGUnitTester/PageBossPage.html";  // Force Action to ListBossPage
		else if(!isLocalhost && isCaseyTextArea)
			document.SUPEForm.action = "/PageBossPage.html?caseytextarea=on";  // Force Action to ListBossPage
		else
			document.SUPEForm.action = "/PageBossPage.html";  // Force Action to ListBossPage
}

function DoViewSwitchTabs()
{
	if (document.topnavdemo_r1_c3 && document.SUPEForm )
	{	
		if  (document.SUPEForm.DisableViewSwitch == "true")
		{
			for (i = 0; i < document.images.length; i++)
			{	 
				if (document.images[i].name == "topnavdemo_r1_c3")
				{	 
					document.images[i].height = 0;
					document.images[i].width = 0;
				}
			}
		}
	}
}



self.setInterval("DoViewSwitchTabs()", 100);
