function writeSWFtag (strSWFFile, intWidth, intHeight) {
    document.write('<object type="application/x-shockwave-flash" data="' + strSWFFile + '" ');
    document.write('width="' + intWidth + '" height="' + intHeight + '">');
    document.write('<param name="movie" value="' + strSWFFile + '"></object>');
}

var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);

var globalMouseX;
var globalMouseY;
var workingElement;
function showMessage(myElement)
{
    eval("document.getElementById('divProductPackaging').style.display = 'none'");
    eval("document.getElementById('divTellafriend').style.display = 'none'");
    eval("document.getElementById('divproductQuestions').style.display = 'none'");

    var packagingProductPlacement = 0;
    if (myElement == 'divProductPackaging')
    {
        packagingProductPlacement = 252;
    }    
    var browserCheck = (document.all) ? 1 : 0; // vi checker for IE...
    
      if( browserCheck > 0 )  // 1 hvis MSIE
    {
        eval("document.getElementById('" + myElement + "').style.top =" + ( 85));
	    eval("document.getElementById('" + myElement + "').style.left=" + (-510+packagingProductPlacement));
        if (myElement == 'divTellafriend')
        {
	        eval("document.getElementById('" + myElement + "').style.top ='" + (45) + "px'");
	        eval("document.getElementById('" + myElement + "').style.left='" + (-540)+ "px'");
        }

        eval("document.getElementById('" + myElement + "').style.display = 'inline'");
        eval("document.getElementById('" + myElement + "').style.zindex = '200'");

	    //workingElement = myElement;
    }
    else
    {
    var ischrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
//	    eval("document.getElementById('" + myElement + "').style.top ='" + (globalMouseY - 50) + "px'");
//	    eval("document.getElementById('" + myElement + "').style.left='" + (globalMouseX-530+packagingProductPlacement)+ "px'");
        
        if (myElement == 'divProductPackaging')
        {
	        eval("document.getElementById('" + myElement + "').style.top ='" + (globalMouseY + 37) + "px'");
	    }
	    else {
	        eval("document.getElementById('" + myElement + "').style.top ='" + (globalMouseY + 70) + "px'");
        }
	    eval("document.getElementById('" + myElement + "').style.left='" + (globalMouseX-565+packagingProductPlacement)+ "px'");
        if (ischrome) {
	            eval("document.getElementById('" + myElement + "').style.top ='" + (86) + "px'");
	            eval("document.getElementById('" + myElement + "').style.left='" + (-510+packagingProductPlacement)+ "px'");
        }
        if (myElement == 'divTellafriend')
        {
	        eval("document.getElementById('" + myElement + "').style.top ='" + (47) + "px'");
	        eval("document.getElementById('" + myElement + "').style.left='" + (-540)+ "px'");
        }
        eval("document.getElementById('" + myElement + "').style.display = 'inline'");
        eval("document.getElementById('" + myElement + "').style.zindex = '200'");

	}
}

function resetElement(myElement)
{
    e = document.getElementById(myElement);
    if (e.type == 'text')
    {
        e.value = ''
    }
    else if(e.type == 'select-one')
    {
       e.selectedIndex=0;
    }
}
function closeWindow(myElement)
{
	eval("document.getElementById('" + myElement + "').style.display = 'none'");
}

function captureMouseXY(evt)
{	
		var e = (window.event) ? window.event : evt;
		globalMouseX = mouseX(e);
		globalMouseY = mouseY(e);
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
return evt.clientX + (document.documentElement.scrollLeft ?
document.documentElement.scrollLeft :
document.body.scrollLeft);
else return null;
}

function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
return evt.clientY + (document.documentElement.scrollTop ?
document.documentElement.scrollTop :
document.body.scrollTop);
else return null;
}

function PageQuery(q) 
{
    if(q.length > 1) this.q = q.substring(1, q.length);
    else this.q = null;
    this.keyValuePairs = new Array();
    if(q) 
    {
        for(var i=0; i < this.q.split("&").length; i++) 
        {
            this.keyValuePairs[i] = this.q.split("&")[i];
        }
    }
    
    this.getKeyValuePairs = function() 
    { 
        return this.keyValuePairs; 
    }
    
    this.getValue = function(s) 
    {
        for(var j=0; j < this.keyValuePairs.length; j++) 
        {
            if(this.keyValuePairs[j].split("=")[0] == s)
                return this.keyValuePairs[j].split("=")[1];
        }
        return false;
    }
    
    this.getParameters = function() 
    {
        var a = new Array(this.getLength());
        for(var j=0; j < this.keyValuePairs.length; j++) 
        {
            a[j] = this.keyValuePairs[j].split("=")[0];
        }
        return a;
    }
    
    this.getLength = function() 
    { 
        return this.keyValuePairs.length; 
    } 
}

var __isIE =  navigator.appVersion.match(/MSIE/);
var __userAgent = navigator.userAgent;
var __isFireFox = __userAgent.match(/firefox/i);
var __isFireFoxOld = __isFireFox && 
   (__userAgent.match(/firefox\/2./i) || __userAgent.match(/firefox\/1./i));
var __isFireFoxNew = __isFireFox && !__isFireFoxOld;

function __parseBorderWidth(width) {
    var res = 0;
    if (typeof(width) == "string" && width != null 
                && width != "" ) {
        var p = width.indexOf("px");
        if (p >= 0) {
            res = parseInt(width.substring(0, p));
        }
        else {
             //do not know how to calculate other 
             //values (such as 0.5em or 0.1cm) correctly now
             //so just set the width to 1 pixel
            res = 1; 
        }
    }
    return res;
}

//returns border width for some element
function __getBorderWidth(element) {
    var res = new Object();
    res.left = 0; res.top = 0; res.right = 0; res.bottom = 0;
    if (window.getComputedStyle) {
        //for Firefox
        var elStyle = window.getComputedStyle(element, null);
        res.left = parseInt(elStyle.borderLeftWidth.slice(0, -2));  
        res.top = parseInt(elStyle.borderTopWidth.slice(0, -2));  
        res.right = parseInt(elStyle.borderRightWidth.slice(0, -2));  
        res.bottom = parseInt(elStyle.borderBottomWidth.slice(0, -2));  
    }
    else {
        //for other browsers
        res.left = __parseBorderWidth(element.style.borderLeftWidth);
        res.top = __parseBorderWidth(element.style.borderTopWidth);
        res.right = __parseBorderWidth(element.style.borderRightWidth);
        res.bottom = __parseBorderWidth(element.style.borderBottomWidth);
    }
   
    return res;
}

//returns absolute position of some element within document
function getElementAbsolutePos(element) {
    var res = new Object();
    res.x = 0; res.y = 0;
    if (element !== null) {
        res.x = element.offsetLeft;
        res.y = element.offsetTop;
        
        var offsetParent = element.offsetParent;
        var parentNode = element.parentNode;
        var borderWidth = null;

        while (offsetParent != null) {
            res.x += offsetParent.offsetLeft;
            res.y += offsetParent.offsetTop;
            
            var parentTagName = offsetParent.tagName.toLowerCase();    

            if ((__isIE && parentTagName != "table") || 
                (__isFireFoxNew && parentTagName == "td")) {            
                borderWidth = __getBorderWidth(offsetParent);
                res.x += borderWidth.left;
                res.y += borderWidth.top;
            }
            
            if (offsetParent != document.body && 
                offsetParent != document.documentElement) {
                res.x -= offsetParent.scrollLeft;
                res.y -= offsetParent.scrollTop;
            }

            //next lines are necessary to support FireFox problem with offsetParent
               if (!__isIE) {
                while (offsetParent != parentNode && parentNode !== null) {
                    res.x -= parentNode.scrollLeft;
                    res.y -= parentNode.scrollTop;
                    
                    if (__isFireFoxOld) {
                        borderWidth = __getBorderWidth(parentNode);
                        res.x += borderWidth.left;
                        res.y += borderWidth.top;
                    }
                    parentNode = parentNode.parentNode;
                }    
            }

            parentNode = offsetParent.parentNode;
            offsetParent = offsetParent.offsetParent;
        }
    }
    return res;
}

function setElementPositionRelativeTo(target, referenceElement, offsetTop, offsetLeft)
{
    if (document.getElementById(target).style.visibility=="hidden")
        return;
    
    var pos = getElementAbsolutePos(document.getElementById(referenceElement));
    //window.alert(pos.y);    
    document.getElementById(target).style.top=pos.y + offsetTop + 'px';
    document.getElementById(target).style.left=pos.x + offsetLeft + 'px';
    //setTimeout('setElementPositionRelativeTo(\'' + target + '\', \'' + o + '\', ' + offsetTop + ', ' + offsetLeft + ')', 300);
    //window.alert('setElementPositionRelativeTo(\'' + target + '\', \'' + o + '\', \'' + offsetTop + '\', \'' + offsetLeft + '\')');
}

/* HOK Specialized DropDown list emulation */
    var hokDdlOptionlistTimerArray = new Array();
    function hokDdl_show_dropdown(optionsListId){
		document.getElementById(optionsListId).style.visibility="visible";
		document.getElementById(optionsListId).style.display="block";
		if (hokDdlOptionlistTimerArray[optionsListId] && hokDdlOptionlistTimerArray[optionsListId]>0) {
		    clearTimeout(hokDdlOptionlistTimerArray[optionsListId]);
		    hokDdlOptionlistTimer=0;
        }
	}
	function hokDdl_downkey(){
	
	}
	
	function hokDdl_Select(txt, val, optionsListId, targetId, shadowedSelectElement){
		document.getElementById(targetId).value=txt;
		document.getElementById(shadowedSelectElement).value=val;

		setTimeout('hokDdl_doHide(\'' + optionsListId + '\')', 300);
		
	}
	function hokDdl_doHide(optionsListId){
		document.getElementById(optionsListId).style.visibility="hidden";
		document.getElementById(optionsListId).style.display="none";
	}
	
	function hokDdl_hide_list(optionsListId){
		if (hokDdlOptionlistTimerArray[optionsListId] && hokDdlOptionlistTimerArray[optionsListId]>0)  
		{
		    clearTimeout(hokDdlOptionlistTimerArray[optionsListId]);
		}
	    hokDdlOptionlistTimerArray[optionsListId]=setTimeout('hokDdl_conditional_hide_list(\'' + optionsListId + '\')', 1000);
	}
	
	function hokDdl_conditional_hide_list(optionsListId){
	    hokDdl_doHide(optionsListId);
	    hokDdlOptionlistTimerArray[optionsListId]=0;
	}
	
//function TrapCR(event, target) {
//        if (event.keyCode == 13) {
//        var src = event.srcElement || event.target;
//        if (!src || (src.tagName.toLowerCase() != "textarea")) {
//            var defaultButton;
//            if (__nonMSDOMBrowser) {
//               defaultButton = document.getElementById(target);
//            }
//            else {
//                defaultButton = document.all[target];
//            }
//            if (defaultButton && typeof(defaultButton.click) != "undefined") {
//                defaultButton.click();
//                event.cancelBubble = true;
//                if (event.stopPropagation) event.stopPropagation();
//                return false;
//            }
//        }
//    }
//    return true;
//}