﻿
var is = new Object()
is.ie = (document.all) ? 1:0
is.ns4 = (document.layers) ? 1:0
is.w3c = (document.getElementById && !is.ie) ? 1:0
is.win = (navigator.userAgent.toLowerCase().indexOf("win") > 0) ? 1:0
is.mac = (navigator.userAgent.toLowerCase().indexOf("mac") > 0) ? 1:0
is.firefox = (navigator.userAgent.toLowerCase().indexOf("firefox") > 0) ? 1:0

var xPos = 0;
var yPos = 0;

var strWindow = null;
var strNumber = null;

// Capturing Mouse Position
if(!is.ie) {document.captureEvents(Event.MOUSEMOVE)}

document.onmousemove = getMouseXY;


function openPopUp(argUrl, argWidth, argHeight, argTitle, argScroll ) {
	//for win ie, add extra width to accomodate scrollbar on pop07
	// if(is.ie && !is.mac  && argScroll=="1" && ( argTitle == "pop07" || argTitle == "pop08") ){
	//  argWidth = parseInt(argWidth) + 26;
	//}
    
	if(argScroll=="1" && !is.mac){
    argWidth = parseInt(argWidth) + 26;
  }
		if(argScroll=="1" && is.mac){
    argWidth = parseInt(argWidth) + 10;
  }
    
		
  var x = (screen.availWidth - argWidth ) / 2;
  var y = (screen.availHeight - argHeight ) / 2;
  
  var sFeatures = "width=" + argWidth + "," + 
                  "height=" + argHeight + "," + 
									"toolbar=no," + 
                  "status=no," + 
									"scrollbars=" + argScroll + "," + 
									"resizable=yes," + 
                  
                  "left=" + x + ", top="+ y;
  
  window.open(argUrl, argTitle, sFeatures, false);
}



//Function added to launch the Artificial Assistant (en_BG, en_US, de_DE)
self.name='IKEA';

//That's the target wished name of the IKEA window to make possible that the
//Assistant opens the links in the proper window. If the window actually has
//another name, please, tell us and we will change the target in the
//Assistant's links!!!!

function popUpAnna(URL,popW,popH) {
	var w = 480, h = 340;

	if (document.all || document.layers) {

		w = self.screen.availWidth;
		h = self.screen.availHeight;
	}

	var topPos = (h-popH)-(4*h/100), leftPos = (w-popW)-(1*w/100);
	
	
	day = new Date();
	id = day.getTime();

	eval("page" + id + " =window.open(URL,'popup','resizable=no, toolbar=no, location=no, status=no, scrollbars=no, menubar=no, titlebar=no, width=' + popW + ',height=' + popH + ',left=' + leftPos + ',top=' + topPos + ',screenX=' + leftPos + ',screenY=' + topPos);");
	
	/******************************************
	//	Close the window if it is already open
	if (strWindow) {
		strWindow.close();
	}
	strWindow = window.open(URL,'popup','resizable=no, toolbar=no, location=no, status=no, scrollbars=no, menubar=no, titlebar=no, width=' + popW + ',height=' + popH + ',left=' + leftPos + ',top=' + topPos + ',screenX=' + leftPos + ',screenY=' + topPos);
	*******************************************/
}

function popUpNumber(){
	if (strNumber) {
		strNumber.close();
	}
	strNumber=window.open('images/whatsthis.jpg','popup','resizable=no, toolbar=no, location=no, status=no, scrollbars=no, menubar=no, titlebar=no, width=640, height=240');
}

 function getObj(id){
    if (document.getElementById)
    {
        this.obj = document.getElementById(id);
        this.style = document.getElementById(id).style;
    }
    
    else if (document.all)
    {
        this.obj = document.all[id];
        this.style = document.all[id].style;
    }
    
    else if (document.layers)
    {
        this.obj = document.layers[id];
        this.style = document.layers[id];
    }
}         

function toggleQuestionDisplay() {

/* triggered by 'Click here to send email'   
 if dropdown selected was Online & phone orders, 
 display extended form with more order info fields */

/*	old vars:

		var objTopic=new getObj("_topic");
		var objGeneralInfo=new getObj("_generalInfo");
		var objOnlineInfo=new getObj("_onlineInfo");
*/

		var objTopic=new getObj(ddlTopics);
		var objGeneralInfo=new getObj(divGeneralInfo);
		var objOnlineInfo=new getObj(divOnlineInfo);
		
		if (objTopic.obj.options[objTopic.obj.selectedIndex].value.toLowerCase() == 'online and phone orders') {
			objGeneralInfo.style.display = "block";
			objOnlineInfo.style.display = "block";
		}
		else {
			objGeneralInfo.style.display = "block";
			objOnlineInfo.style.display = "none";
		}	
		
		document.body.scrollTop = yPos;	
}		
	




function getMouseXY(e) {
	if (is.ie) { // grab the x-y pososition
		xPos = event.clientX + document.body.scrollLeft;
		yPos = event.clientY + document.body.scrollTop;
	 } 
	else {  // grab the x-y pos.s if browser is NS
		xPos = e.pageX;
		yPos = e.pageY;
	}  
	// catch possible negative values in NS4
	if (xPos < 0){xPos = 0}
	if (yPos < 0){yPos = 0}

	//var objYPos=new getObj("_yPos");
	//objYPos.obj.value = yPos;
}


function toggleItem() {
	
		var objProblem = document.Form1._rdoProblem;
		//var objProblem = document.getElementsByName("_rdoProblem");
		//alert(objProblem.length);
		var objItem = new getObj("_item");
		
		if (objProblem[0].checked || objProblem[1].checked || objProblem[2].checked) {
			objItem.style.display = "block";
		}
		else {
			objItem.style.display = "none";
		}	
}			

function togglePhone() {
	
		var objContact = document.Form1._rdoContact;
		var objPhone = new getObj("_askPhone");
		
		if (objContact[1].checked) {
			objPhone.style.display = "block";
		}
		else {
			objPhone.style.display = "none";
		}	
}		


var defaultClass ="";

//global button rollover control
function setButtonState(obj,state){
	if(state == "on"){
	defaultClass = obj.className;
	obj.className = defaultClass +"Over";
	}else if(state=="off"){
	obj.className = defaultClass;
	}
}