//Declarations
var cssMouseOver = ""
var cssMouseOut = ""
var subNavId = new Array()
var subNavCount = 0;
var subULCount = 0;


//Insert mouse event function in UL Lists
function menuEvent(id){
	obj = document.getElementById(id);
	objName = document.getElementById(id).id
	if (obj != null){	
	    for (c=0; c < obj.childNodes.length; c++){	    
	    objNode = obj.childNodes[c];	    
		    if(objNode.nodeName == "LI"){
				if(objName =="nav"){
	            	mouseEvent(objNode,id);}
				else{
					mouseEvent1(objNode,id);}
			    if (objNode.childNodes.length > 1){  
			        subMenu(objNode,c);
				
			    }			    
		    }
	    }
	    if (subULCount < subNavCount){	                
            subULCount++;
            menuEvent(subNavId[subULCount-1]);            
	    }
	}	
}



//If sub UL is present, assign an ID.
function subMenu(obj,c){
    subObjNode = obj;    
    for(b=0; b < subObjNode.childNodes.length; b++){
        objSubNode = objNode.childNodes[b];        
        if(objSubNode.nodeName == "UL"){		                            
            subNavId[subNavCount] = "subnav" + (subNavCount + c);
            objSubNode.id = subNavId[subNavCount];              
            subNavCount++;                  
        }
    }        
}

//Mouse event function
function mouseEvent(obj,id){ 
    objNode.onmouseover = function(){

			if(this.className =="noBorderImg" || this.className =="outnoBorderImg"){
				this.className= id == "nav" ? "noBorderOver" : "liOverBG";}
			else{
				this.className= id == "nav" ? "overTop" : "liOverBG";}
	}
    objNode.onmouseout = function(){

			if(this.className =="overTop" || this.className =="out" ){
				this.className= id == "nav" ? "out" : "";}
			else{
				this.className= id == "nav" ? "outnoBorderImg" : "";}
		
	
	}
	

}



function mouseEvent1(obj,id){
	
    objNode.onmouseover = function(){

			if(this.className == "noBorder" || this.className =="outnoBorder")
				{
				this.className= id == "menuElem" ? "noBorder" : "liOverBG"; 
				;
				}
				
			else{
				this.className= id == "menuElem" ? "over" : "liOverBG"; 
				}
	}
    objNode.onmouseout = function(){
			
			if(this.className =="over" || this.className =="out" ){
				this.className= id == "menuElem" ? "out" : "";}
			else{
				this.className= id == "menuElem" ? "noBorder" : "";}
		
	
	}
	

}

/*Begin FLASH APPLICATION*/
function openFlashApp() {
	myLightWindow.activateWindow({href:'http://webservice.sevdotcom.com/JotunApplication.html', title: 'Decorate My Room', width:650, height: 600})

}

function openColourWheelApp(){
	myLightWindow.activateWindow({href:'http://test.sevdotcom.com/CMSTemplates/Jotun/flash/colorWheelflash/main4.swf', title: 'Colour Wheel', height: 600, width:600})
}

function closeFlashApp() {
	myLightWindow.deactivate(); 
}
/*End FLASH APPLICATION*/

/*#Colour Codes#*/
function openImageChic() {
	myLightWindow.activateWindow({href:'/CMSTemplates/Jotun/images/ColourCodes/chic.jpg', title: 'Colour Code', width:600, height:900})
}
function openImageSensual() {
	myLightWindow.activateWindow({href:'/CMSTemplates/Jotun/images/ColourCodes/sensual.jpg', title: 'Colour Code', width:600, height:900})
}
function openImageDynamic() {
	myLightWindow.activateWindow({href:'/CMSTemplates/Jotun/images/ColourCodes/dynamic.jpg', title: 'Colour Code', width:600, height:900})
}
function openImageMysterious() {
	myLightWindow.activateWindow({href:'/CMSTemplates/Jotun/images/ColourCodes/mysterious.jpg', title: 'Colour Code', width:600, height:900})
}

/*Begin PERSONALITY QUIZ*/
function personalityQuiz()
{
	window.location({href:'http://test.sevdotcom.com/CMSTemplates/Jotun/Javascript/quizsp.js'});
}
/*End PERSONALITY QUIZ*/

function signUP($id) {
	if ($id == "signup"){
	myLightWindow.activateWindow({href:'/User-Registration-Pages/Sign-Up.aspx', title: 'Sign-Up', height: 300, width:300}) 
	}
	if ($id == "login" ){
		myLightWindow.activateWindow({href:'/User-Registration-Pages/Log-In.aspx', title: 'Log-In', height: 300, width:300}) 
	}
}


/* BEGIN BOOKMARK PAGE */
function addToFavorites() {
	var urlAddress = window.location; 
	var pageName = "Jotun Lady - With Flying Colours"; 	
	
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) 
  {
  		window.external.AddFavorite(urlAddress,pageName);
  } else if (navigator.appName == "Netscape") {
    	window.sidebar.addPanel(pageName,urlAddress,"");
  } else {
   	 alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }

} 
/* END BOOKMARK PAGE */




/* BEGIN CREATE POPUP WINDOW FOR PRINTER VERSION */

var newWindow;

function makeNewWindow(id) {
    if (!newWindow || newWindow.closed) {
		var windowWidth = 800;
		var windowHeight = 430;
		var centerWidth = (window.screen.width - windowWidth) / 2;
    	var centerHeight = (window.screen.height - windowHeight) / 2;

		
        newWindow = window.open("","","status,height=" + windowHeight + ",width=" + windowWidth + ",top=" + centerHeight + ",left=" + centerWidth);
		
        if (!newWindow.opener) {
        newWindow.opener = window;
        }
        // force small delay for IE to catch up
        setTimeout("writeToWindow('" + id + "')", 50);
    } else {
        // window's already open; bring to front
        newWindow.focus();
    }
}
function writeToWindow(id) {
    // assemble content for new window
	var dataObj = document.getElementById(id);
	var bodyText = dataObj.innerHTML;
    var newContent = "<HTML><HEAD><TITLE>Printer Version</TITLE>"
	newContent += "<link type='text/css' rel='stylesheet' href='/CMSTemplates/Jotun/css/popup.css' />";
	newContent += "</HEAD>";
    newContent += "<BODY>";
	newContent += "<div class='Controls'><a href='javascript:window.print();'>Print</a> &nbsp; | &nbsp; <a href='javascript:window.close();'>Close</a></div>"; 
	newContent += "<div class='" +  id + "'>" + bodyText + "</div>";
    newContent += "</BODY></HTML>";
    // write HTML to new window document
    newWindow.document.write(newContent);
    newWindow.document.close(); // close layout stream
}


/* END CREAATE POPUP WINDOW FOR PRINTER VERSION  */


/* BEGIN VIDEO PLAYER */
function getHostName(){
	var hName = document.host;
	
	return hName;
}

function loadVideo(vWidth, vHeight, url, videoTitle, scrImg, c) {
	
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);

	//alert(navigator.appMinorVersion);
	
	var so = "";
	if(scrImg == "" || scrImg == null) {
	    scrImg=null;
	}else{
	   scrImg = "&scrImg=" + scrImg		
	//	if((navigator.appName == "Microsoft Internet Explorer") && (version <= 4)){
			//alert('ok');
			//alert(navigator.appName);
	//			so = new SWFObject("/CMSTemplates/Jotun/flash/JotunVideoPlayerIE6.html?videourl=" + url + "&title=" + videoTitle + scrImg + "&color=" + c, "videoPlayer", vWidth, vHeight, "9", "");
	
	//	}else{
		
		so = new SWFObject("/CMSTemplates/Jotun/flash/JotunVideoPlayer.swf?videourl=" + url + "&title=" + videoTitle + scrImg + "&color=" + c, "videoPlayer", vWidth, vHeight, "9", "");
	
	//	}
	}

	so.addParam("wmode", "transparent");
	so.addParam("allowFullScreen", "true");
	//so.addParam("allowScriptAccess", "sameDomain"); 
	so.write("videoContainer");
		
}

/* END VIDEO PLAYER */


function CloseWindow() {
  timer=setTimeout("window.close()",5000);
  return true;
}


//Initiate script after page load
window.onload = function() {
	menuEvent("menuElem");
	
	//var QuizObj = document.getElementById("formDiv");	
	//if(QuizObj != null) {
	//	showQuestions();
	//}
}

