currentURL = location.href;

RunScript = false;

rExp = '(visitnortheastengland.com/)|(visitnortheastengland.com/)$|(visitnortheastengland.com)$|(visitnortheastengland.com/mtb)|(visitnortheastengland.com/au)|(visitnortheastengland.com/nz)|(visitnortheastengland.com/walkingmicrosite)';
VNErExp = '(visitnortheastengland.com/)|(visitnortheastengland.com/)$|(visitnortheastengland.com)$';
VNGrExp = '(visitnewcastlegateshead.co.uk/)|(visitnewcastlegateshead.co.uk/)$|(visitnewcastlegateshead.co.uk)$';

// Google Anayltics - VNE
if (currentURL.search(VNErExp) > - 1)
{
    _uacct = "UA-156551-1";

    urchinTracker();	
}

// Google Anayltics - Visit NewcastleGateshead
if (currentURL.search(VNGrExp) > - 1)
{
    _uacct = "UA-4219833-6";

    urchinTracker();	
}

if (currentURL.search(rExp) > - 1)
	RunScript = true;


// VNE Polygon Fix 
if (RunScript)
{

    if (document.getElementById('src_polygon'))
    {

    function GetCurrentPolyID(URLstr)
    {
	 CurrentID = '';
        
		ParamList = URLstr.split('?')[1];

		if (ParamList)
		{
			ParamArray = ParamList.split('&');
				
				
			//for (i=0; i <= ParamArray.length; i++)
			for (i in ParamArray)
			{
				Param = ParamArray[i].split('=');
			
				ParamName = Param[0];    
				ParamValue = Param[1];                               
											 
				if (ParamName == 'src_polygon')
				{              
				 CurrentID = ParamValue.replace(/%2C/g,',');
				 break;
				}						
			 } 					
		}
		
		return CurrentID;
    }                
	
	var PolyID = '';
		
		if (document.getElementById('src_polygon').selectedIndex)		
		{
			currentPolyIndex = document.getElementById('src_polygon').selectedIndex;
			PolyID = document.getElementById('src_polygon').options[currentPolyIndex].value;
		}	
		else
			PolyID = GetCurrentPolyID(currentURL);


        
        polyList = document.getElementById('src_polygon').options;
       

        polyList.length = 27;
        
        polyList[1].value = "491,501,511";
        polyList[1].text = "COUNTY DURHAM AREA";                       
        
        polyList[2].value = "491";
        polyList[2].text = "- Durham City";

        polyList[3].value = "501";
        polyList[3].text = "- Durham Coast";

        polyList[4].value = "511";
        polyList[4].text = "- Durham Countryside";          

        polyList[5].value = "291,231,301,151,91";
        polyList[5].text = "NORTHUMBERLAND AREA";

        polyList[6].value = "291";
        polyList[6].text = "- Hadrian's Wall and North Pennines";

        polyList[7].value = "231";
        polyList[7].text = "- Kielder & Redesdale";

        polyList[8].value = "301";
        polyList[8].text = "- Woodhorn,Morpeth & Mid Northumberland";          

        polyList[9].value = "151";
        polyList[9].text = "- Alnwick Coast & Country";          

        polyList[10].value = "91";
        polyList[10].text = "- Berwick Coast & Country";          

        polyList[11].value = "361,411,461,441,431,421,401,451";
        polyList[11].text = "TEES VALLEY AREA";

        polyList[12].value = "361";
        polyList[12].text = "- Darlington";
        
        polyList[13].value = "411";
        polyList[13].text = "- Guisborough";
        
        polyList[14].value = "461";
        polyList[14].text = "- Hartlepool";
        
        polyList[15].value = "541";
        polyList[15].text = "- Middlesbrough";
        
        polyList[16].value = "431";
        polyList[16].text = "- Redcar";
        
        polyList[17].value = "421";
        polyList[17].text = "- Saltburn";
        
        polyList[18].value = "401";
        polyList[18].text = "- Stockton on Tees";

        polyList[19].value = "451";
        polyList[19].text = "- Yarm";
        
        polyList[20].value = "381,331,341,351,371,471";
        polyList[20].text = "TYNE AND WEAR AREA";
        
        polyList[21].value = "381";
        polyList[21].text = "- Gateshead";
        
        polyList[22].value = "331";
        polyList[22].text = "- Newcastle upon Tyne";
        
        polyList[23].value = "341";
        polyList[23].text = "- North Tyneside";
        
        polyList[24].value = "351";
        polyList[24].text = "- South Tyneside";

        polyList[25].value = "371";
        polyList[25].text = "- Sunderland";
        
        polyList[26].value = "471";
        polyList[26].text = "- Tyne & Wear Coast";
		
        for (i=0; i < polyList.length; i++)
        {         

	if (polyList[i].value == PolyID)
                polyList[i].selected = true;		
            else
                polyList[i].selected = false;
        }
		
	}
}

// Hide Irrelevant Special Offer
if (document.getElementById("src_specoff"))
{
	if (location.href.search("attraction") > 0) { thisPage = "attr"; }
	else { thisPage = "accomm"; }
	
	if (location.href.search("things-to-do") > 0) { thisPage = "attr"; }
		
	specfield = document.getElementById("src_specoff");
								
	for (x = 0; x < specfield.options.length; x++)
	{
		chkVal = specfield.options[x].value;
		if (thisPage == "attr")
			{ 
				if (chkVal == 221) { specfield.remove(x); x--; };
				if (chkVal == 241) { specfield.remove(x); x--; };
			}
		else 
			{ if (chkVal == 201) { specfield.remove(x); x--; } }								
	}
}

