/* EDGE JAVASCRIPT 
	- POPUPS - Listen, Webcams 
	- BOOKMARKING AND HOMEPAGE 
	- ROUNDED TABS - a js workaround that enables rounded corners on the main nav. Not achievable with CSS with TopMenu Module
*/

/* Simulate clicking the DNN login/register controls */
function simulateLoginClick() {__doPostBack('dnn$TheEdgeHeader$dnnLOGIN$cmdLogin','')} 
function simulateRegisterClick() {window.location = '/Home/Login/tabid/36/language/en-NZ/Default.aspx'}

/* Flash Object JS */
if(typeof com=="undefined"){var com=new Object()}if(typeof com.deconcept=="undefined"){com.deconcept=new Object()}if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object()}if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object()}com.deconcept.FlashObject=function(f,d,n,i,k,m,l,o,a,e){this.DETECT_KEY=e?e:"detectflash";this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(f){this.setAttribute("swf",f)}if(d){this.setAttribute("id",d)}if(n){this.setAttribute("width",n)}if(i){this.setAttribute("height",i)}if(k){this.setAttribute("version",new com.deconcept.PlayerVersion(k.toString().split(".")))}if(m){this.addParam("bgcolor",m)}var b=o?o:"high";this.addParam("quality",b);this.setAttribute("redirectUrl","");if(a){this.setAttribute("redirectUrl",a)}if(l){var g=new com.deconcept.PlayerVersion([6,0,65]);var j=com.deconcept.FlashObjectUtil.getPlayerVersion();if(j.versionIsValid(g)&&!j.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true)}}else{this.setAttribute("doExpressInstall",false)}};com.deconcept.FlashObject.prototype.setAttribute=function(a,b){this.attributes[a]=b};com.deconcept.FlashObject.prototype.getAttribute=function(a){return this.attributes[a]};com.deconcept.FlashObject.prototype.getAttributes=function(){return this.attributes};com.deconcept.FlashObject.prototype.addParam=function(a,b){this.params[a]=b};com.deconcept.FlashObject.prototype.getParams=function(){return this.params};com.deconcept.FlashObject.prototype.getParam=function(a){return this.params[a]};com.deconcept.FlashObject.prototype.addVariable=function(a,b){this.variables[a]=b};com.deconcept.FlashObject.prototype.getVariable=function(a){return this.variables[a]};com.deconcept.FlashObject.prototype.getVariables=function(){return this.variables};com.deconcept.FlashObject.prototype.getParamTags=function(){var b="";var a;var c=this.getParams();for(a in c){b+='<param name="'+a+'" value="'+c[a]+'" />'}return b};com.deconcept.FlashObject.prototype.getVariablePairs=function(){var a=new Array();var b;var c=this.getVariables();for(b in c){a.push(b+"="+c[b])}return a};com.deconcept.FlashObject.prototype.getHTML=function(){var a="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn")}a+='<embed type="application/x-shockwave-flash" src="'+this.getAttribute("swf")+'" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" id="'+this.getAttribute("id")+'" name="'+this.getAttribute("id")+'"';var e=this.getParams();for(var c in e){a+=" "+c+'="'+e[c]+'"'}d=this.getVariablePairs().join("&");if(d.length>0){a+=' flashvars="'+d+'"'}a+="></embed>"}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX")}a+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" id="'+this.getAttribute("id")+'">';a+='<param name="movie" value="'+this.getAttribute("swf")+'" />';var b=this.getParamTags();if(b.length>0){a+=b}var d=this.getVariablePairs().join("&");if(d.length>0){a+='<param name="flashvars" value="'+d+'" />'}a+="</object>"}return a};com.deconcept.FlashObject.prototype.write=function(a){if(this.skipDetect||this.getAttribute("doExpressInstall")||com.deconcept.FlashObjectUtil.getPlayerVersion().versionIsValid(this.getAttribute("version"))){if(document.getElementById){if(this.getAttribute("doExpressInstall")){this.addVariable("MMredirectURL",escape(window.location));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title)}document.getElementById(a).innerHTML=this.getHTML()}}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"))}}};com.deconcept.FlashObjectUtil.getPlayerVersion=function(){var b=new com.deconcept.PlayerVersion(0,0,0);if(navigator.plugins&&navigator.mimeTypes.length){var a=navigator.plugins["Shockwave Flash"];if(a&&a.description){b=new com.deconcept.PlayerVersion(a.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."))}}else{if(window.ActiveXObject){try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");b=new com.deconcept.PlayerVersion(c.GetVariable("$version").split(" ")[1].split(","))}catch(d){}}}return b};com.deconcept.PlayerVersion=function(a){this.major=parseInt(a[0])||0;this.minor=parseInt(a[1])||0;this.rev=parseInt(a[2])||0};com.deconcept.PlayerVersion.prototype.versionIsValid=function(a){if(this.major<a.major){return false}if(this.major>a.major){return true}if(this.minor<a.minor){return false}if(this.minor>a.minor){return true}if(this.rev<a.rev){return false}return true};com.deconcept.util.getRequestParameter=function(d){var b=document.location.search||document.location.href.hash;if(b){var c=b.indexOf(d+"=");var a=(b.indexOf("&",c)>-1)?b.indexOf("&",c):b.length;if(b.length>1&&c>-1){return b.substring(b.indexOf("=",c)+1,a)}}return""};if(Array.prototype.push==null){Array.prototype.push=function(a){this[this.length]=a;return this.length}}var getQueryParamValue=com.deconcept.util.getRequestParameter;var FlashObject=com.deconcept.FlashObject;

/* Popups */
function openListenOnlineWindow() {mywindow = window.open("http://www.theedge.co.nz/Portals/0/media-popup/media-popup_listenonline.html","EdgeMediaPopup","width=470,height=489,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0");} 
function openListenOnlineWindowDuplicate() {mywindow = window.open("http://www.theedge.co.nz/Portals/0/media-popup/media-popup_listenonline.html","EdgeMediaPopupDuplicate","width=470,height=489,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0");} 
function openWebcamWindow() {mywindow = window.open("http://www.theedge.co.nz/Portals/0/media-popup/media-popup_webcam_1.html","EdgeMediaPopup","width=470,height=489,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0");}
function openWebcamWindowDuplicate() {mywindow = window.open("http://www.theedge.co.nz/Portals/0/media-popup/media-popup_webcam_1.html","EdgeMediaPopupDuplicate","width=470,height=489,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0");}
function openMessageStudio(){mywindow = window.open("http://edit.theedge.co.nz/Portals/0/media-popup/media-popup_msgstudio.html","EdgeMediaPopup","width=470,height=489,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0");}
function openMessageStudioDuplicate(){mywindow = window.open("http://edit.theedge.co.nz/Portals/0/media-popup/media-popup_msgstudio.html","EdgeMediaPopupDuplicate","width=470,height=489,toolbar=0,scrollbars=0,location=0,menubar=0,resizeable=0,status=0"); }

//pop up for messageing studio
function popUp(URL, width, height) {return popUp(URL, width, height, '0');}
function popUp(URL, width, height, scrollbar) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars="+scrollbar+",location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ",left=600,top=270');");}

/* Bookmarks and Home page */
function addbookmark() {var locBrow='TheEdge-Home';bookmarkurl=window.location.href;bookmarktitle=locBrow;if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle);else if (window.sidebar) window.sidebar.addPanel(bookmarktitle, bookmarkurl, "")}
function setHome() {document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(window.location.href);}

/* Add Rounded corners to the Active Tab in the main Nav 
 * This is unfortunately not achievable thru CSS due to limitations in the TopMenu module
 * Called below the edgeMenuWrapper div tag
 */
function addRoundedCornersToTabs() {

	var sClassName = 'MainTopMenuItemSel';
	
	/* Create Array of All HTML Tags */
	var allHTMLTags = new Array();
	allHTMLTags = document.getElementsByTagName("*");
	
	/* Loop through all tags using a for loop */
	for (i=0; i<allHTMLTags.length; i++) {
	
		/* Get all tags with the specified class name. */
		if (allHTMLTags[i].className == sClassName) {
		
		
			/*Put right rounded corner in bg of 'MainTopMenuItemSel' class SPAN tag*/
			allHTMLTags[i].style.backgroundColor = 'transparent';
			allHTMLTags[i].style.backgroundImage = "url('/portals/0/images/site/2009/nav/tab_sprite.png')";
			allHTMLTags[i].style.backgroundRepeat = 'no-repeat';
			allHTMLTags[i].style.backgroundPosition = 'top right'
			allHTMLTags[i].style.padding = '4px 8px 4px 0'
			
			
			/*Put left rounded corner in bg of  'MainTopMenuItemSel' SPAN's parent's parent tag (ie the SPAN tag which is the parent of the A tag) */
			allHTMLTags[i].parentNode.parentNode.style.backgroundColor = '#FFFFFF';
			allHTMLTags[i].parentNode.parentNode.style.backgroundImage = "url('/portals/0/images/site/2009/nav/tab_sprite.png')";
			allHTMLTags[i].parentNode.parentNode.style.backgroundRepeat = 'no-repeat';
			allHTMLTags[i].parentNode.parentNode.style.backgroundPosition = 'top left'
			allHTMLTags[i].parentNode.parentNode.style.padding = '0 0 0 8px'

			
			/* There is only one element with the MainTopMenuItemSel class so break for loop */
			break;
		}
	}
}

function addColouredRoundedCornersToTabs(strColorText, strColorHex) {

	var sClassName = 'MainTopMenuItemSel';
	
	/* Create Array of All HTML Tags */
	var allHTMLTags = new Array();
	allHTMLTags = document.getElementsByTagName("*");
	
	/* Loop through all tags using a for loop */
	for (i=0; i<allHTMLTags.length; i++) {
	
		/* Get all tags with the specified class name. */
		if (allHTMLTags[i].className == sClassName) {
		
		
			/*Put left rounded corner in bg of 'MainTopMenuItemSel' class SPAN tag*/
			allHTMLTags[i].style.backgroundColor = 'transparent';
			allHTMLTags[i].style.backgroundImage = "url('/portals/0/images/site/2009/nav/tab_sprite_" + strColorText + ".gif')";
			allHTMLTags[i].style.backgroundRepeat = 'no-repeat';
			allHTMLTags[i].style.backgroundPosition = 'top right'
			allHTMLTags[i].style.padding = '4px 8px 4px 0'
			
			
			/*Put right rounded corner in bg of  'MainTopMenuItemSel' SPAN's parent's parent tag (ie the SPAN tag which is the parent of the A tag) */
			allHTMLTags[i].parentNode.parentNode.style.backgroundColor = strColorHex; //'#000000';
			allHTMLTags[i].parentNode.parentNode.style.backgroundImage = "url('/portals/0/images/site/2009/nav/tab_sprite_" + strColorText + ".gif')";
			allHTMLTags[i].parentNode.parentNode.style.backgroundRepeat = 'no-repeat';
			allHTMLTags[i].parentNode.parentNode.style.backgroundPosition = 'top left'
			allHTMLTags[i].parentNode.parentNode.style.padding = '0 0 0 8px'

			
			/* There is only one element with the MainTopMenuItemSel class so break for loop */
			break;
		}
	}
}

