function setlogoCookie(logono) {
        var d = "logoimg=" + logono + "; " + "expires=Thu, 31 Dec 2099 23:59:59 GMT;path=/;"
        document.cookie = d;
		// fireToPage(logono)
    }
	function setPageCookie(logono) {
        var d = "page=" + logono + "; " + "expires=Thu, 31 Dec 2099 23:59:59 GMT;path=/;"
        document.cookie = d;
		// fireToPage(logono)
    }
    function submitThis(){ 
         // window.location='/SetRegion/tabid/55/Default.aspx';	
	 window.location.reload(); 

    } 
	 function setWeatherCookie(logono) {
        var d = "weather=" + logono + "; " + "expires=Thu, 31 Dec 2099 23:59:59 GMT;path=/;"
        document.cookie = d;
		updateRegion(logono);
		}

function submitWeather(){
//window.location = "http://www.3news.co.nz/News/WeatherNews/WeatherMap/tabid/197/Default.aspx";
}
		function getcookie(logoimg) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(logoimg);
 if (index1==-1 || logoimg=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+logoimg.length+1,index2));
alert(logoimg)

}
/* 		  Page ID |  onairCat ID  | Base Portal | Weather 
Auckland:		76			2			0			2
Christchurch:	78			7			2			4
Dunedin:		136			142			4			7
Central Otago:	108			141			3			38
N/A-Gisborne:	150			143			23			8
Hawkes Bay:		87			144			5			20
N/A-Horowhenua:	165			146			6			17
Kapiti:			91			151			7			17
Manawatu: 		96			152			8			26
Marlborough:	100			153			1			3
Nelson:			104			154			9			21
N/A- Northland:	189			155			10			43
Queenstown:		112			156			11			28
Rotorua:		132			157			12			30
Southland:		116			158			13			14
Taranaki:		120			159			14			22
N/A-Taupo:		220			160			15			32
Tauranga:		124			161			16			33
Waikato:		128			162			17			13
N/A-Wairarapa:	232			163			19			18
N/A-Wanganui:	238			164			20			39
Wellington: 	82			165			21			40
*/
function fireToPage(region){

	var base="/Regions/";
	if (region==99){setPageCookie(38);setWeatherCookie(2);window.location=base+"Home/tabid/38/Default.aspx";}//generic
	if (region==0){setPageCookie(76);setWeatherCookie(2);window.location=base+"Auckland/Home/tabid/76/Default.aspx";}//auckland
	if (region==1){setPageCookie(100);setWeatherCookie(3);window.location=base+"Marlborough/Home/tabid/100/Default.aspx";}//Marlborough
	if (region==2){setPageCookie(78);setWeatherCookie(4);window.location=base+"Christchurch/Home/tabid/78/Default.aspx";}//christchurch
	if (region==3){setPageCookie(108);setWeatherCookie(0);window.location=base+"CentralOtago/Home/tabid/108/Default.aspx";}//central otago
	if (region==4){setPageCookie(136);setWeatherCookie(7);window.location=base+"Dunedin/Home/tabid/136/Default.aspx";}//dunedin
	if (region==5){setPageCookie(87);setWeatherCookie(20);window.location=base+"HawkesBay/Home/tabid/87/Default.aspx";}//Hawkes Bay
	if (region==7){setPageCookie(62);setWeatherCookie(17);window.location=base+"Kapiti/Home/tabid/91/Default.aspx";}//Kapiti
	if (region==8){setPageCookie(96);setWeatherCookie(26);window.location=base+"Manawatu/Home/tabid/96/Default.aspx";}//Manawatu
	if (region==9){setPageCookie(104);setWeatherCookie(21);window.location=base+"Nelson/Home/tabid/104/Default.aspx";}//Nelson
	if (region==11){setPageCookie(112);setWeatherCookie(28);window.location=base+"Queenstown/Home/tabid/112/Default.aspx";}//Queenstown
	if (region==12){setPageCookie(132);setWeatherCookie(30);window.location=base+"Rotorua/Home/tabid/132/Default.aspx";}//Rotorua
	if (region==13){setPageCookie(116);setWeatherCookie(14);window.location=base+"Southland/Home/tabid/116/Default.aspx";}//Southland
	if (region==14){setPageCookie(120);setWeatherCookie(22);window.location=base+"Taranaki/Home/tabid/120/Default.aspx";}//Taranaki
	if (region==16){setPageCookie(124);setWeatherCookie(33);window.location=base+"Tauranga/Home/tabid/124/Default.aspx";}//Tauranga
	if (region==17){setPageCookie(128);setWeatherCookie(13);window.location=base+"Waikato/Home/tabid/128/Default.aspx";}//Waikato
	if (region==21){setPageCookie(82);setWeatherCookie(40);window.location=base+"Wellington/Home/tabid/82/Default.aspx";}//Wellington
	if (region==10){setPageCookie(208);setWeatherCookie(43);window.location=base+"MercuryBay/Home/tabid/208/Default.aspx";}//Mercury Bay
	if (region==19){setPageCookie(346);setWeatherCookie(18);window.location=base+"/Wairarapa/Home/tabid/346/Default.aspx";}//Wairarapa
/*	if (region==6){setPageCookie(165);setWeatherCookie(17);window.location=base+"165";}//Horowhenua
	if (region==15){setPageCookie(220);setWeatherCookie(32);window.location=base+"220";}//Taupo
	
	if (region==20){setPageCookie(238);setWeatherCookie(39);window.location=base+"238";}//Wanganui
	if (region==23){setPageCookie(150);setWeatherCookie(8);window.location=base+"150";}//gisborne
*/
	}
	
function showRegion(myRegion){
	
		 if(myRegion=="") {dispRegion = "not set";}
	else if(myRegion=="99"){dispRegion = "generic";}
	else if(myRegion=="0"){dispRegion = "Auckland";}
	else if(myRegion=="1"){dispRegion = "Marlborough";}
	else if(myRegion=="2"){dispRegion = "Christchurch";}
	else if(myRegion=="3"){dispRegion = "Central Otago";}
	else if(myRegion=="4"){dispRegion = "Dunedin";}
	else if(myRegion=="5"){dispRegion = "Hawkes Bay";}
	else if(myRegion=="6"){dispRegion = "Horowhenua";}
	else if(myRegion=="7"){dispRegion = "Kapiti";}
	else if(myRegion=="8"){dispRegion = "Manawatu";}
	else if(myRegion=="9"){dispRegion = "Nelson";}
	else if(myRegion=="10"){dispRegion = "Northland";}
	else if(myRegion=="11"){dispRegion = "Queenstown";}
	else if(myRegion=="12"){dispRegion = "Rotorua";}
	else if(myRegion=="13"){dispRegion = "Southland";}
	else if(myRegion=="14"){dispRegion = "Taranaki";}
	else if(myRegion=="15"){dispRegion = "Taupo";}
	else if(myRegion=="16"){dispRegion = "Tauranga";}
	else if(myRegion=="17"){dispRegion = "Waikato";}
	//else if(myRegion=="18"){dispRegion = "Masterton";}
	else if(myRegion=="19"){dispRegion = "Wairarapa";}
	else if(myRegion=="20"){dispRegion = "Wanganui";}
	else if(myRegion=="21"){dispRegion = "Wellington";}
		else if(myRegion=="23"){dispRegion = "Gisborne";}
  else{dispRegion = "not set";}
return dispRegion;

	}
	
function updateRegion(id) {
if(window.myweathersm) window.document["myweathersm"].SetVariable("where", id);
if(document.myweathersm) document.myweathersm.SetVariable("where", id);


}

 function findCatRegion(catRegion){
	      if (catRegion =="99"){catRetrieve = "163";}//generic
		  if (catRegion ==""){catRetrieve = "163";}//generic
	else if (catRegion =="0"){catRetrieve = "79";}//auckland
	else if (catRegion =="1"){catRetrieve = "114";}//marl
	else if (catRegion =="2"){catRetrieve = "89";}//chch
	else if (catRegion =="3"){catRetrieve = "84";}//central otago
	else if (catRegion =="4"){catRetrieve = "94";}//dunedin
	else if (catRegion =="5"){catRetrieve = "99";}//hawkes bay
	else if (catRegion =="6"){catRetrieve = "146";}//horowhenua
	else if (catRegion =="7"){catRetrieve = "104";}//Kapiti
	else if (catRegion =="8"){catRetrieve = "109";}//manawatu
	else if (catRegion =="9"){catRetrieve = "119";}//nelson
	else if (catRegion =="10"){catRetrieve = "123";}//Mercury Bay
	else if (catRegion =="11"){catRetrieve = "129";}//queenstown
	else if (catRegion =="12"){catRetrieve = "134";}//rotorua
	else if (catRegion =="13"){catRetrieve = "139";}//southland
	else if (catRegion =="14"){catRetrieve = "144";}//taranaki
	else if (catRegion =="15"){catRetrieve = "160";}//taupo
	else if (catRegion =="16"){catRetrieve = "149";}//tauranga
	else if (catRegion =="17"){catRetrieve = "154";}//waikato
	else if (catRegion =="18"){catRetrieve = "";}//UNKNOWN
	else if (catRegion =="19"){catRetrieve = "201";}//wairapapa
	else if (catRegion =="20"){catRetrieve = "164";}//wanganui
	else if (catRegion =="21"){catRetrieve = "159";}//wellington
	else if (catRegion =="23"){catRetrieve = "143";}//gisborne
//alert(catRetrieve)
		 return catRetrieve;
	 }

function addbookmark() {
var locBrow=wheret;
bookmarkurl=window.location.href;
bookmarktitle=locBrow;

if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle);

else if (window.sidebar)
window.sidebar.addPanel(bookmarktitle, bookmarkurl, "")
}

/* set homepage */
	function setHome(siteURL) {
  if (document.all)
{
    document.body.style.behavior = "url(#default#homepage)";
    document.body.setHomePage(siteURL);
}
else
    alert("only works in IE 4.0 or higher! \n \nto add MoreFM as your homepage from other browsers simply go: \n1) tools \n2) options \nand add it here");
}

function openListenWindow(which) { 
mywindow = window.open(which,"ListenOnline","width=470,height=400,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0"); 
} 


      //----------

      function addEvent(obj ,evt, fnc)
      {
        if (obj.addEventListener)
          obj.addEventListener(evt,fnc,false);
        else if (obj.attachEvent)
          obj.attachEvent('on'+evt,fnc);
        else
          return false;
        return true;
      }

      function removeEvent(obj ,evt, fnc)
      {
        if (obj.removeEventListener)
          obj.removeEventListener(evt,fnc,false);
        else if (obj.detachEvent)
          obj.detachEvent('on'+evt,fnc);
        else
          return false;
        return true;
      }

      //----------

      function appendElement(node,tag,id,htm)
      {
        var ne = document.createElement(tag);
        if(id) ne.id = id;
        if(htm) ne.innerHTML = htm;
        node.appendChild(ne);
      }

      //----------

      function showPopup(p)
      {
        greyout(true);
        document.getElementById(p).style.display = 'block';
      }

      function hidePopup(p)
      {
        greyout(false);
        document.getElementById(p).style.display = 'none';
      }

      //----------

      function greyout(d,z)
      {
        var obj = document.getElementById('greyout');
        if(!obj)
        {
          appendElement(document.body,'div','greyout');
          obj = document.getElementById('greyout');
          obj.style.position = 'absolute';
          obj.style.top = '0px';
          obj.style.left = '0px';
          obj.style.background = '#111';
          obj.style.opacity = '.5';
          obj.style.filter = 'alpha(opacity=50)';
        }
        if(d)
        {
          if(!z){ z - 50;}
          obj.style.zIndex = z;
          obj.style.height = Math.max(document.body.scrollHeight,document.body.clientHeight)+'px';
          obj.style.width  = Math.max(document.body.scrollWidth,document.body.clientWidth)+'px';
          obj.style.display = 'block';
          addEvent(window,'resize',greyoutResize);
        }
        else
        {
          obj.style.display = 'none';   
          removeEvent(window,'resize',greyoutResize);
        }
      }
     
      function greyoutResize()
      {
        var obj = document.getElementById('greyout');
        obj.style.height = document.body.clientHeight+'px';
        obj.style.width  = document.body.clientWidth+'px';
        obj.style.height = Math.max(document.body.scrollHeight,document.body.clientHeight)+'px';
        obj.style.width  = Math.max(document.body.scrollWidth,document.body.clientWidth)+'px';
      }

      //----------
	function  checkMyRegion(){
	  var myRegion = getcookie('logoimg');
	  	  if((myRegion=="")||(myRegion=="undefined")){
		  window.onload=function(){
			  
			  showPopup('popup');

		//setTimeout("showPopup('popup')",2000) ;
		  }
		}
	else {//this bit fires the user to thei regino home page if they somehow comeback to the main home
			v1 = "http://www.thebreeze.co.nz/Home/tabid/38/language/en-US/Default.aspx";
		v2 = "http://www.thebreeze.co.nz/";
		v3 = "http://www.thebreeze/Home/tabid/38/Default.aspx";
		v4 = "http://www.thebreeze/Home/tabid/38/language/en-US/Default.aspx";
		v5 = "http://www.thebreeze/";
		v6 = "http://www.thebreeze/Home/tabid/38/Default.aspx";
if((location.href==v1)||(location.href==v2)||(location.href==v3)||(location.href==v4)||(location.href==v5)||(location.href==v6)){
	fireToPage(myRegion);
	}
}}

function  checkMyPage(){
	document.getElementById('headerLogo').innerHTML="";
	
var myPage = getcookie('page');


var myRegionURL = getcookie('logoimg');

if(myPage!=""){
	document.getElementById('headerLogo').innerHTML+='<a href="javascript:void(0)" title="'+myRegionURL+'" onclick="fireToPage('+myRegionURL+')"><img src="/Portals/0/images/site/logos/logo_'+myPage+'.gif" align="left" alt="home"/><\/a>';
}
else{
	document.getElementById('headerLogo').innerHTML+='<a href="/"><img src="/Portals/0/images/site/logos/logo.gif" align="left" alt="home"/><\/a>';

}
}

 function openWindow(where,name) { 
 newWindow=window.open(where,name,"width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no") } 
 

		function openPlayerWindow(site) {
			newWindow=window.open("/Portals/0/nowplaying/player.htm?site="+site+"","blitz","width=530,height=550,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		}
		
		function launchPlayer(reg){
			//onclick="openWindow('/portals/0/player/akl-playerControl07.htm','akl')";
			if(reg=="2"){//auckland
			newWindow=window.open("/Portals/0/player/akl-playerControl07.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
			}
			else if(reg=="13"){//waikato
			newWindow=window.open("/Portals/0/player/wai-playerControl07.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		
				
				}
			/*else if(reg=="20"){//hawkes bay
			newWindow=window.open("/Portals/0/player/haw-playerControl07.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		
				
				}*/
			
			else if(reg=="40"){//wellington
			newWindow=window.open("/Portals/0/player/well-playerControl07.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		
				
				}
			else if(reg=="4"){//caterbury
			newWindow=window.open("/Portals/0/player/can-playerControl07.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		
				
				}
			
				
				else if(reg=="33"){//tauranga
			newWindow=window.open("/Portals/0/player/trg-playerControl07.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		
				
				}
			
			
			else{
				newWindow=window.open("/Portals/0/player/listenOnline.htm","blitz","width=470,height=400,toolbar=no,scrollbars=no, location=no,menubar=no,noresizeable=no,status=no");
		

				}
			
			}
			
			function getcookie(logoimg) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(logoimg);
 if (index1==-1 || logoimg=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+logoimg.length+1,index2));
 }

flash= getcookie("fontsize");
if(flash=="0")
{logo0();}
else if(flash=="")
{logo0();}
else if(flash=="1")
{logo1();}
else if(flash=="2")
{logo2();}
else if(flash=="3")
{logo3();}

random_num2 = (Math.round((Math.random()*9)+1)) 
function logo0(){
document.write("<style type='text/css'>@import url('/Portals/0/skins/09_TheBreeze/fontnormal.css?rnd=+');</style>");
}
function logo1(){
document.write("<style type='text/css'>@import url('/Portals/0/skins/09_TheBreeze/fontnormal.css?');</style>");
}
function logo2(){
document.write("<style type='text/css'>@import url('/Portals/0/skins/09_TheBreeze/fontlarge.css?');</style>");
}
function logo3(){
document.write("<style type='text/css'>@import url('/Portals/0/skins/09_TheBreeze/fontsmall.css?');</style>");
}
  function setBGCookie(imgno) {
        var c = "fontsize=" + imgno + ";path=/; expires=Thu, 31 Dec 2099 23:59:59 GMT";
        document.cookie = c;
    }
	function submitThis(){ 
          window.location.reload(); 
    } 

function addbookmark() {
var locBrow=wheret;
bookmarkurl=window.location.href;
bookmarktitle=locBrow;

if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle);

else if (window.sidebar)
window.sidebar.addPanel(bookmarktitle, bookmarkurl, "")
}

function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);

/* pop up video */

	
	
	/* homepage */
	function setHomePage(siteURL) {
  if (document.all)
  {
    document.body.style.behavior = "url(#default#homepage)";
    document.body.setHomePage(siteURL);
  }
  else
    alert("only works in IE 4.0 or higher! \n to Add tv3 as you home page from other browsers simply go \n1) tools \n 2) options and add it here");
	
	
	
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

	var fontSize = GetCookie('fonttextsize');
	if(fontSize != null) {
		setActiveStyleSheet(fontSize, 1);
	}
		


