﻿//This function is used to submit when the market dropdown selection changes.
function submitMarket(psPageName, psValue)
{
    var sQS = "";
    var sAryQS = null;
    var sAryQSItem = null;
    var sAction = psPageName;
    var sMarketQS = "market=";
    var sMarketSelected = "NTL";
    
    if (location.search != "")
    {
        sAryQS = location.search.substring(1).split("&");
    }
    
	 if (psValue != null && psValue != "")
	 {
		  sMarketSelected = psValue;
	 }
	 
	 sMarketQS += sMarketSelected;
	 
	 if (sAryQS != null)
	 {
		  for (var i=0; i<sAryQS.length; i++)
		  {
				sAryQSItem = sAryQS[i].split("=");
				
				if (sAryQSItem[0].toLowerCase() != "market")
				{
					 if (sQS != "")
					 {
						  sQS += "&";
					 }
					 
					 sQS += sAryQSItem[0] + "=" + sAryQSItem[1];
				}
		  }
	 }
	 
	 if (sQS != "")
	 {
		  sAction += "?" + sQS + "&" + sMarketQS;
	 }
	 else
	 {
		  sAction += "?" + sMarketQS;
	 }
    
    document.forms[0].action = sAction;
    document.forms[0].submit();
}
				
function ChangePage(poForm)
{
	 if (typeof(poForm.__VIEWSTATE) != "undefined")
	 {
		  poForm.__VIEWSTATE.disabled = true;
	 }
	 
	 if (typeof(poForm.__EVENTVALIDATION) != "undefined")
	 {
		  poForm.__EVENTVALIDATION.disabled = true;
	 }
	 
	 poForm.submit();
}

//This function is used to submit when the market dropdown selection changes.
function ChangeMarket(psAction)
{
    var oForm = document.forms[0];
    
    if (typeof(oForm.Page) != "undefined")
    {
        oForm.Page.value = "1";
    }
    
    this.ChangePage(oForm)
}