DropDownObj.prototype.showChildNodes = DropDownShowChildNodes;
DropDownObj.prototype.hideChildNodes = DropDownHideChildNodes;
// -----------
function DropDownObj(strObjName, strId, strChildNodesContainerId){
	this.strObjName = strObjName;
	this.oElm = getElm(strId);	
	this.oElm.setAttribute("objName", this.strObjName);
	this.oChildNodesContainer = getElm(strChildNodesContainerId);
	this.oElm.onclick = function (oEvent){		
		eval(this.getAttribute("objName") + ".showChildNodes()");
		oEvent = (oEvent)? oEvent : event;
		oEvent.cancelBubble = true;
	}
	this.oChildNodesContainer.onclick = function (oEvent){
		oEvent = (oEvent)? oEvent : event;
		oEvent.cancelBubble = true;
	}
}
// -----------
function DropDownShowChildNodes(){
	this.oChildNodesContainer.style.visibility = (this.oChildNodesContainer.style.visibility == "visible")? "hidden" : "visible";	
}
// -----------
function DropDownHideChildNodes(){
	this.oChildNodesContainer.style.visibility = "hidden";
}
// -----------
var oDropDown;
var oElmToDrag = null;
var intDragOffsetX = 0;	
var intDragOffsetY = 0;
var isKampanj;
window.onload = function (){
	// Campaign-Specific code for making line height 100%;
	if(isKampanj==true){
		if(is.ie5){
			getElm("fullHeightLine").style.height = (document.body.offsetHeight - 70) + "px";
		}
		else if (is.ie55){
			getElm("fullHeightLine").style.height = (document.body.offsetHeight - 70) + "px";
		}	
		else{	
			getElm("fullHeightLine").style.height = (document.body.offsetHeight - 66) + "px";
		}
		if(is.safari){
			var oRightColumnContentDiv = getElm("rightColumnContent");
			if(oRightColumnContentDiv){
				if(oRightColumnContentDiv.offsetHeight < 512){
					getCSSObj("oRightColumnContentDiv").height = "512px";
				}	
			}
		}		
	}	
	if(getElm("dropDownImg")){
		oDropDown = new DropDownObj("oDropDown", "dropDownImg", "dropDownChildNodesContainerDiv");
		document.onclick = function (){			
			oDropDown.hideChildNodes();			
		}
	}
	if(getElm("dropDownImg")){
		oDropDown = new DropDownObj("oDropDown", "dropDownImg", "dropDownChildNodesContainerDiv");
		document.onclick = function (){			
			oDropDown.hideChildNodes();			
		}
	}
	if(is.safari){
		var oMainColumnDiv = getElm("mainColumnDiv");
		if(oMainColumnDiv){
			if(oMainColumnDiv.offsetHeight < 474){
				getCSSObj("mainColumnDiv").height = "474px";
			}	
		}
	}
	document.onmousedown = function (oEvent){
		var oEvent = (oEvent)? oEvent : event;
		var oEventTarget = (oEvent.target)? oEvent.target : oEvent.srcElement;
		intDragOffsetX = (oEvent.layerX)? oEvent.layerX : oEvent.offsetX;
		intDragOffsetY = (oEvent.layerY)? oEvent.layerY : oEvent.offsetY;
		if(oEventTarget.getAttribute("dragEnabled") == "true"){
			oElmToDrag = oEventTarget.parentNode;
			return false;
		}
	}
	document.onmousemove = function (oEvent){		
		if(oElmToDrag){
			var oEvent = (oEvent)? oEvent : event;			
			var oBodyElm = (is.ie && is.intV >= 6)? document.documentElement : document.body;
			var intScrollLeft = (is.safari || (is.bMac && is.ie && is.intV < 6))? 0 : (typeof window.pageXOffset != "undefined")? window.pageXOffset : oBodyElm.scrollLeft;
			var intScrollTop = (is.safari || (is.bMac && is.ie && is.intV < 6))? 0 : (typeof window.pageYOffset != "undefined")? window.pageYOffset : oBodyElm.scrollTop;			
			oElmToDrag.style.left = ((oEvent.clientX + intScrollLeft) - intDragOffsetX) + "px";
			oElmToDrag.style.top = ((oEvent.clientY + intScrollTop) - intDragOffsetY) + "px";
			document.ondragstart = function (){
				event.returnValue = false;      
			}
			document.onselectstart = function (){
				event.returnValue = false;      
			}			
			return false;
		}
	}
	document.onmouseup = function (oEvent){
		var oEvent = (oEvent)? oEvent : event;
		if(oElmToDrag){
			oElmToDrag = null;
			document.ondragstart = function (){
				event.returnValue = true;
			}
			document.onselectstart = function (){
				event.returnValue = true;
			}
		}
		else{			
			hidePopup(oEvent, false);
		}
	}	
}
// -----------
function selectSearchOption(oElm, intButtonIndex){
	if(!oElm.disabled && !oElm.parentNode.getElementsByTagName("input")[intButtonIndex].disabled){
		oElm.parentNode.getElementsByTagName("input")[intButtonIndex].checked = true;
	}	
}

// ----------- !!!!!! NEW VERSION AVAILABLE

/*
function saveSelectedPublications(NoPublicationsMessage){
	var arrAllCheckboxes = getElm("selectPublicationsDiv").getElementsByTagName("input");	
	//var arrAllPublicationsName = getElm("selectPublicationsDiv").getElementsByTagName("");
	var oHiddenField = ""; 
	//getElm("selectedPublicationsInput");	
	for(var i=0; i<arrAllCheckboxes.length; i++){
		if(arrAllCheckboxes[i].checked){		
			oHiddenField += arrAllCheckboxes[i].value + ";";			
		}
	}
	
	//Remove illegal characters
	oHiddenField = escape(oHiddenField);
	
	oHiddenField = String(oHiddenField).replace(/;$/, "");
	if (oHiddenField.length < 1){
		alert(NoPublicationsMessage);
	}
	else if(typeof strOrderFormID != "undefined"){		
		document.forms[0].action = "main.aspx?id=" + strOrderFormID +"&Publications=" + oHiddenField + "&objectWithOrder=" + strObjectWithOrder;
		document.forms[0].submit();
	}
}
*/

// -----------
function checkAndSubmit(oEvent){
	var bReturn = true;
	if(oEvent){
		if(String(oTextBoxSearch.value).search(/(\d|\w)+/) == -1){
			
			if((oEvent.type == "keydown" && oEvent.keyCode == 13) || oEvent.type == "click"){
				

				showHideError("block");				
				if(oEvent.preventDefault){
					oEvent.preventDefault();
				}
				if(oEvent.stopPropagation){
					oEvent.stopPropagation();	
				}
				oEvent.cancelBubble = true;
				oEvent.returnValue = false;
				bReturn = false;
				
				
			} 
		}  else {
			if((oEvent.type == "keydown" && oEvent.keyCode == 13) || oEvent.type == "click"){
				thedomainStr = document.location.href;
				if ((thedomainStr.indexOf(".com/") > 0) || (thedomainStr.indexOf(".se/") > 0) || (thedomainStr.indexOf(".ee/") > 0)) {
					pageTracker._trackEvent('Search', 'phrase: ' + oTextBoxSearch.value, 'from:' + breadCrumb);
				}
			}
			
		}
	}

	return bReturn;
}


function checkAndSubmitLogin(oEvent){
	var bReturn = true;
	if(oEvent){
			if((oEvent.type == "keydown" && oEvent.keyCode == 13)){	
			oButtonLogin.click();
			}
	}
	return bReturn;
}

// -----------
function customFormSubmission(oEvent, strButtonID, bValidateForm){
	if(oEvent){
		if(oEvent.keyCode == 13){
			if(oTopBarSearchButton){
				oTopBarSearchButton.disabled = true;
			}
			if(oEvent.preventDefault){
				oEvent.preventDefault();
			}
			if(oEvent.stopPropagation){
				oEvent.stopPropagation();	
			}
			oEvent.cancelBubble = true;
			oEvent.returnValue = false;
			var bSubmitForm = true;
			if(bValidateForm){
				bSubmitForm = isValidFormInterest();
			}
			if(bSubmitForm){
				__doPostBack(strButtonID, "");
			}	
		}
	}	
	return false;	
}
// -----------	
function showHideError(strDisplay){
	oSearchErrorDiv.display = strDisplay;
}
// -----------
function isValidFormInterest(){
	var bReturn = true;
	var oValidation = new Validation();
	var arrElementsToCheckForContent = getElm("OrderFormDiv").getElementsByTagName("input");
	var oElement;
	for(var i=0; i<arrElementsToCheckForContent.length; i++){
		oElement = arrElementsToCheckForContent[i];		
		if(oElement.getAttribute("type") == "text" && oElement.getAttribute("mandatory") == "true"){			
			if(oValidation.isEmpty(oElement.value)){
				oElement.className += ((String(oElement.className).length > 0)? " " : "") + "incorrectInput";
				alert(strYouHaveToFillInSomething);
				bReturn = false;				
				oElement.focus();
				break;
			}
			else if(String(oElement.className).length > 0 && String(oElement.className).search(/incorrectInput/i) != -1){
				oElement.className = String(oElement.className).replace(/\s?incorrectInput\s?/gi, "");				
			}
		}	
	}	
	if(bReturn){
		var oEmail = getElm(strEmailFieldID);
		if(!oValidation.isEmail(oEmail.value) && !oValidation.isEmpty(oEmail.value)){
			oEmail.className += ((String(oEmail.className).length > 0)? " " : "") + "incorrectInput";
			alert(strIncorrectEmailAddress);			
			oEmail.focus();
			bReturn = false;
		}
		else if(String(oElement.className).length > 0 && String(oElement.className).search(/incorrectInput/i) != -1){
			oEmail.className = String(oEmail.className).replace(/\s?incorrectInput\s?/gi, "");				
		}
	}
	return bReturn;
}
// -----------
Validation.prototype.isEmail = validationIsEmail;
Validation.prototype.isEmpty = validationIsEmpty;
Validation.prototype.hasWhiteSpace = validationHasWhiteSpace;
function Validation(){
	this.valid = false;
}
// -----------
function validationIsEmail(strEmail){
	var bReturn = true;
	if(strEmail.search(/^[\w-]+(\.?[\w-]+)*@([\w-]+\.)+[a-zA-z]{2,4}$/) == -1){
		bReturn = false;
	}
	return bReturn;
}
// -----------
function validationIsEmpty(strToValidate){
	return (strToValidate.search(/^\s*$/) != -1) ? true : false;
}
// -----------
function validationHasWhiteSpace(s){
	if(s.indexOf(" ") > 0 ){
		return true;
	}else{
		return false;
	}
}
// -----------

// Campaign-Specific code for making line height 100%;
window.onresize = function correctHeight(){
	if(isKampanj==true){
		if(is.ie5){
			getElm("fullHeightLine").style.height = (document.body.offsetHeight - 70) + "px";
		}
		else if (is.ie55){
			getElm("fullHeightLine").style.height = (document.body.offsetHeight - 70) + "px";
		}	
		else{	
			getElm("fullHeightLine").style.height = (document.body.offsetHeight - 66) + "px";
		}
		if(is.safari){
			var oRightColumnContentDiv = getElm("rightColumnContent");
			if(oRightColumnContentDiv){
				if(oRightColumnContentDiv.offsetHeight < 512){
					getCSSObj("oRightColumnContentDiv").height = "512px";
				}	
			}
		}			
	}
}
// Campaign-Specific code for scrolling iframe
var myScrollTimer;
function pageScrollLeft() {
   	wideScreen.scrollBy(-50,0);
  	myScrollTimer = setTimeout('pageScrollLeft()',100);				
}		
function pageScrollRight() {
   	wideScreen.scrollBy(50,0);
  	myScrollTimer = setTimeout('pageScrollRight()',100);				
}			
function stopScroll() {
	clearTimeout(myScrollTimer);
}














// added by Holmen

function ReplaceSpace(string,text,by) { 
// Replaces text with by in string 
    var strLength = string.length, txtLength = text.length; 
    if ((strLength == 0) || (txtLength == 0)) return string; 

    var i = string.indexOf(text); 
    if ((!i) && (text != string.substring(0,txtLength))) return string; 
    if (i == -1) return string; 

    var newstr = string.substring(0,i) + by; 
    if (i+txtLength < strLength) 
        newstr += ReplaceSpace(string.substring(i+txtLength,strLength),text,by); 
    return newstr; 
} 



function saveSelectedPublications(NoPublicationsMessage){ 
        var arrAllCheckboxes = getElm("selectPublicationsDiv").getElementsByTagName("input");   
        //var arrAllPublicationsName = getElm("selectPublicationsDiv").getElementsByTagName(""); 
        var oHiddenField = ""; 
        //getElm("selectedPublicationsInput");  
        for(var i=0; i<arrAllCheckboxes.length; i++){ 
                if(arrAllCheckboxes[i].checked){                
                        oHiddenField += arrAllCheckboxes[i].value + ";";                        
                } 
        } 
        
        //Remove illegal characters 
        oHiddenField = ReplaceSpace(oHiddenField,'&nbsp;',unescape(' ')); 
        oHiddenField = escape(oHiddenField); 
        
        oHiddenField = String(oHiddenField).replace(/;$/, ""); 
        if (oHiddenField.length < 1){ 
                alert(NoPublicationsMessage); 
        } 
        else if(typeof strOrderFormID != "undefined"){          
                document.forms[0].action = "main.aspx?id=" + strOrderFormID +"&Publications=" + oHiddenField + "&objectWithOrder=" + strObjectWithOrder;

                document.forms[0].submit(); 
        } 
} 




