if ( jQuery.browser.msie && jQuery.browser.version >= 9 )
        {
            jQuery.support.noCloneEvent = true
        }



//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var selectTags;

	(function($){
		$.fn.vCenter = function(options) {
			var pos = {
				sTop : function() {
					return window.pageYOffset || $.boxModel && document.documentElement.scrollTop || document.body.scrollTop;
				},
				
				wHeight : function() {
				if (is_chrome ) {
						return  window.innerHeight -100;
					}else
					if ( $.browser.opera) {
						return  window.innerHeight - (($(document).height() > window.innerHeight) ? getScrollbarWidth() : 0);
					} else if ($.browser.safari ) {
						return window.innerHeight;
					} else  {
						return $.boxModel && document.documentElement.clientHeight || document.body.clientHeight;
					}
				}
			};
			return this.each(function(index) {
				if (index == 0) {
					var $this = $(this);
					var elHeight = $this.height();
					$this.css({
						position: 'absolute',
						marginTop: '0',
						top: pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2)
					});
				}
			});
		};	
	})(jQuery);

	(function($){
		$.fn.hCenter = function(options) {
			var pos = {
				sLeft : function() {
					return window.pageXOffset || $.boxModel && document.documentElement.scrollLeft || document.body.scrollLeft;
				},
				wWidth : function() {
				if (is_chrome ) {
						return  window.innerHeight -100;
					}else
					if ( $.browser.opera || ($.browser.safari && parseInt($.browser.version) > 520) ) {
						return window.innerWidth - (($(document).width() > window.innerWidth) ? getScrollbarHeight() : 0);
					} else if ( $.browser.safari ) {
						return window.innerWidth;
					} else{
						return $.boxModel && document.documentElement.clientWidth || document.body.clientWidth;
					}
				}
			};
			return this.each(function(index) {
				if (index == 0) {
					var $this = $(this);
					var elWidth = $this.width();
					$this.css({
						position: 'absolute',
						marginLeft: '0',
						left: pos.sLeft() + (pos.wWidth() / 2) - (elWidth / 2)
					});
				}
			});
		};	
	})(jQuery);




//loading popup with jQuery magic!
function loadPopup(name,src){
	//loads popup only if it is disabled
	if(popupStatus==0){
		//$("#popupIframe").src=src;
		/*if(src.toLowerCase().indexOf(name)>0)
		{
		   document.getElementById("popupContact").style.backgroundColor='#FFFFFF';
	       document.getElementById("popupContact").style.height="384px";
	       document.getElementById("popupContact").style.width="450px";
		}*/
		iframe='';
		popupdiv='';

		jQuery('select').addClass('hideMe');
		
		if(name=='contacts')
		{
			iframe='popupIframe';
			popupdiv='#popupContact';
		}
		if(name=='tell')
		{
			iframe='popuptellIframe';
			popupdiv='#popuptell';
		}
		//alert(name+"  "+src);
		document.getElementById(iframe).src=src;
		centerPopup(popupdiv);
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$(popupdiv).fadeIn("slow");
		popupStatus = 1;
		
	}
}

//disabling popup with jQuery magic!
function disablePopup(name){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$(name).fadeOut("slow");
		jQuery('select').removeClass('hideMe');
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(name){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	$(name).vCenter();
	$(name).hCenter();

	//only need force for IE6
	$("#backgroundPopup").css("height", windowHeight + 'px');
}


function TellAFriend(name,src) {
  	//document.getElementById("popupIframe").src=src;
	/*document.getElementById("popupContact").style.backgroundColor='#CBD8DF';
	document.getElementById("popupContact").style.height="500px";
	document.getElementById("popupContact").style.width="650px";
	*/
	//document.getElementById("popupContactCloseButton").style.display='none';
		$("#popuptell").vCenter();
		$("#popuptell").hCenter();
		centerPopup("#popuptell");
		//load popup
		loadPopup(name,src);
		return false;
}



//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#contactPop").click(function(){
		//centering with css
		//alert(document.getElementById("contactPop").href);
		//load popup
		src = this.href;
		loadPopup(src);
		return false;
	});
	$('ul.topMenuBar>li').hover(
		function() {
			$(this).addClass('sfhover');
			$(this).css('z-index', '100000');
		},
		function() {
			$(this).removeClass('sfhover');
		}
	);

	
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup("#popupContact");
	});
	$("#popupContactCloseButton").click(function(){
		disablePopup("#popupContact");
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup("#popupContact");
	});

	$("#popuptellClose").click(function(){
		disablePopup("#popuptell");
	});
	$("#popupContactCloseButton").click(function(){
		disablePopup("#popuptell");
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup("#popuptell");
	});
	
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup("#popupContact");
			disablePopup("#popuptellContact");
		}
	});

	/*redesign frontpage carousel*/
	/*$('.carousel ul').cycle({
		fx:     'fade',
		speed:  'fast',
		timeout: 3000,
		pager:  '#nav'
	});*/

});// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


window.name = 'Nilfisk-Advance';
function resetForms() {
	for (i=0; i < document.forms.length; i++) {
		document.forms[i].reset();
	}
}

function openProductComparison(){
	window.open('/Functions/ProductComparison.aspx','productComparator', 'width=890,height=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes');
}


/*
Bookmark script
*/
var url = window.location; 
var who = document.title; 
function bookMark(){
	var ver = navigator.appName 
	var num = parseInt(navigator.appVersion) 
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) { 
		document.write('<td>')
		document.write('<a href="javascript:window.external.AddFavorite(url,who);" class="tools">');
		document.write('<img src="/images/icons/bookmark.gif" style="width:20; height:20; border:0px;" alt="'+txt+'" /></a>')
		document.write('</td>')
		document.write('<td>')
		document.write('<a href="javascript:window.external.AddFavorite(url,who);" class="tools">'); 
		document.write(txt + '</a>')
		document.write('</td>')
	}else{ 
		txt += "  (Ctrl+D)" 
		document.write('<td>')
		document.write('<img src="/images/icons/bookmark.gif" style="width:20; height:20; border:0px;" alt="" />')
		document.write('</td>')
		document.write('<td class="tools">')
		document.write(txt) 
		document.write('</td>')
	} 
}


/*
Change Picture (Product Introduction page)
*/

function changePicture(src){
	var path = src;
	var image = '<div class="productMedia"><img id="productPicture" src='+path+' alt="" class="" /></div>';
	document.getElementById('productMedia').innerHTML = image;
}

/*
Adobe Flash detector 
*/
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------
// Version check based upon the values entered above in "Globals"
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
// -----------------------------------------------------------------------------
/*
/ Adobe Flash detector 
*/

function changeVideo(src,duration){
	var totalTime	= duration;
	var path		= src;
	if (hasReqestedVersion) {
	var video = '&#160;<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"  width="266" height="280" id="flashvideo" align="middle" VIEWASTEXT><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/images/video.swf?video='+src+'&duration='+totalTime+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/images/video.swf?video='+src+'&duration='+totalTime+'" quality="high" bgcolor="#ffffff"  width="266" height="280" name="flashvideo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	}
	else{
	
	var video = '<div style="width:240px; height:240px; text-align:center;"><a href="http://www.adobe.com/go/getflashplayer"><img src="/images/get_flash_player.gif" border="0" alt="" /></a></div>';
	}

	document.getElementById('productMedia').innerHTML = video;
	
}




/*
Cookies for countrySelector
*/
	
var expDays = 100;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");

}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function productFinderStep(obj) {  
	if(mainform.productfinderurl != null){
		mainform.productfinderurl.value = obj.value;
	}
	mainform.productfindersubmit.disabled = "";
}



// Product overview comparator

function frmCompareSubmit(id)
	{
	l=(screen.availWidth-890)/2
	t=(screen.availHeight-500)/2
	a=window.open('/Functions/ProductComparison.aspx?hid='+id+'&pg='+document.getElementById("productGroups").value+'&p1='+document.getElementById("products1").value+'&p2='+document.getElementById("products2").value+'&p3='+document.getElementById("products3").value,'productComparator','width=890,height=500, resizable=1, left='+l+',top='+t);
	//document.getElementById("comparator").target = 'productComparator';
	//document.getElementById("comparator").action = '/Functions/ProductComparison.aspx';
	//mainform.__VIEWSTATE.name = 'NOVIEWSTATE';
	//document.getElementById("comparator").submit();
  ///	a.document.getElementById("productGroups").value=document.getElementById("productGroups").value;
	
}
// for product comparator on left menu
function fntCompareSubmit(id)
	{
	
	l=(screen.availWidth-890)/2
	t=(screen.availHeight-500)/2
	a=window.open('/Functions/ProductComparison.aspx?hid='+id,'productComparator','width=890,height=500,scrollbars=yes,resizable=yes,left='+l+',top='+t);
	//if(document.getElementById("fntComparator")){
	//document.getElementById("fntComparator").target = 'productComparator';
	//document.getElementById("fntComparator").submit();
	
	//}
	
	
}
function frmTickToCompare(id){
	var prod1 = document.getElementById("products1");
	var prod2 = document.getElementById("products2");
	var prod3 = document.getElementById("products3");
	// empty fields
	if (prod1.value == id){
		prod1.value = prod2.value;
		prod2.value = prod3.value;
		return false
	}
	if (prod2.value == id){
		prod2.value = prod3.value;
		prod3.value = "";
		return false
	}
	if (prod3.value == id){
		prod3.value = "";
		handleUncheckedCheckboxes(false);
		return false
	}
	
	// fill fields
	if (prod1.value == ""){
		prod1.value = id;
	}
	
	else if (prod2.value == ""){
		prod2.value = id;
	}
	else{
		prod3.value = id;
		handleUncheckedCheckboxes(true);
// for (var i = 1; i <= form.count; i++) {
	}
	
}

function handleUncheckedCheckboxes(state){
var formelement = comparator;
var allInputs = formelement.getElementsByTagName("input");
var checkboxcount = 0
for (var i = 0; i < allInputs.length; i++) {
if (allInputs[i].type == 'checkbox' && allInputs[i].checked == false) {
	checkboxcount++
	allInputs[i].disabled = state;
	}
}
}








/*
Extra menu for se,dk,no
*/
function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}


function setCookie2 (name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	document.cookie = curCookie;
}


function checkEnter(e,caller) //e is event object passed from function invocation
{
	var characterCode //literal character code will be stored in this variable

	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
	{ 
		document.getElementById(caller).onclick();
		return false
	}
	else
	{
		return true
	}
}

 
 


/*Marketing Zone*/

function mzImagePreview(url){
if(document.getElementById('mzImagePreview')){
var previewDiv = document.getElementById('mzImagePreview');
var l= getWindowPosition("width")-250;
var t= getWindowPosition("height")-150;	

	html ='<img src="'+url+'" onclick="mzImagePreviewClose();" style="cursor:pointer; padding:10px;"/><br/>';

	previewDiv.style.left = l+"px";
	previewDiv.style.top = t+"px";
	previewDiv.innerHTML = html;
	previewDiv.style.display = "block";
	previewDiv.style.zIndex=100;
	
return false
}
}

function mzImagePreviewClose(){
	document.getElementById('mzImagePreview').style.display = "none";
}


function getWindowPosition(dim){
  var myWidth = 0, myHeight = 0;
// a little check cos IE doens't support window innerWidth

  if(typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
 
    theTop = document.documentElement.scrollTop;
    theHeight = window.innerHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = window.innerWidth/2;
    
    myWidth = theLeft+theWidth;
    myHeight = theTop+theHeight;

  }
  else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) {
    //IE 6+ in 'standards compliant mode'
    theTop = document.documentElement.scrollTop;
    theHeight = document.documentElement.clientHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = document.documentElement.clientWidth/2;
       
    myWidth = theLeft+theWidth;
    myHeight = theHeight+theTop;

  } else if( document.body && (document.body.clientWidth || document.body.clientHeight )) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  if(dim == 'width'){
	return myWidth;
  }
  else{
	return myHeight;
  }

}

function AddItem(path)
{
  var width = Math.min(750, screen.availWidth);
  var height = Math.min(550, screen.availHeight);
  var left = Math.floor((screen.availWidth-width)/2);
  var top = Math.floor((screen.availHeight-height)/2);

  //contentdot_win = window.open("/sitecore/client/editors/content.aspx?path=" + sItemID + "&revision=" + sRevision, "contentdot_editor", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",resizable=yes");
  contentdot_win = window.open("/sitecore modules/addition/marketingzone/catalog/marketingzone.item.add.aspx?Path=" + path, "contentdot_editor", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",resizable=yes,status=yes");
  
  contentdot_win.focus();

}


// MZ

/*
string NextButtonURL = "mainform.action='" + SitecoreHelper.GetFullUrl() + ".aspx';";
NextButton.Attributes.Add("onclick",NextButtonURL);
*/
function gotoMZPage(nextProductToShow, url){

	document.forms[0].general_content_marketingzone0_MarketingZone_Catalog_Products3_txtNextProductToShow.value = nextProductToShow;
	document.forms[0].action = url+".aspx";
	document.forms[0].submit();
}


function postSearch(searchStr,site){
if(searchStr != ""){    
	//document.forms[0].__VIEWSTATE.value = "";
	document.mainform.searchMain.value = searchStr;
	document.mainform.method="post";
	//document.mainform.action="/functions/search.aspx?search="+searchStr+"&site="+site;
	document.mainform.action="/search.aspx?q="+encodeURI(searchStr);//+"&site="+site;
	document.mainform.submit();
}
else{
	return false
}
}


function postSearchIdleSurf(searchStr,site){
if(searchStr != ""){
    if(document.forms[0].__VIEWSTATE){
	    document.forms[0].__VIEWSTATE.enabled = false;

	}
	
	document.mainform.searchMain.value = searchStr;
	document.mainform.method="post";
	//document.mainform.action="/functions/search2.aspx?search="+searchStr+"&site="+site;
	document.mainform.action="/search.aspx?q="+encodeURI(searchStr);//+"&site="+site;
	document.mainform.submit();
}
else{
	return false
}
}



// function calls moved from init to jquery below
function init(){}

/* 
jp@addition.dk new menu with jquery
- with jQuery methods added, of course
*/

$(document).ready(function(){
	resetForms();
/*    $("#NavigationContainer li").hover(
		function(){ $("ul", this).slideDown("fast"); }, 
		function() { } 
    );
*/	

	
	/*
    if (document.all) {
        $("#NavigationContainer li").hoverClass ("sfHover");
    }*/
});

$(document).ready(function(){
						   
	$("#NavigationContainer>li").hover(function() {
			$(this).addClass("sfHover");
			$(this).css('z-index', '100000');
		},function() {
			$(this).removeClass("sfHover");
//			alert("mouse out");
		}
	);					   
						   
						   
						   
    $("#header_mini_nav li").hover(
		function(){ $("ul", this).slideDown("fast"); }, 
		function() { } 
    );
    if (document.all) {
        $("#header_mini_nav li").hoverClass ("sfHover");
    }    
});

$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};

function go(loc) {
// the function is used when submitting the Variants on the product techspec and Accessories pages
window.location.href = loc;
}

function doSearch(){

    document.forms[0].__VIEWSTATE.disabled = true;
    document.forms[0].quickSearchBtn.disabled = true;
    document.forms[0].btnG.disabled = true;
    document.mainform.method="get";

    
    var q = '?q=';
    if(qBox != null){
        q += encodeURI(qBox.value);
    }
    var url = '';
    
    // check if it's advanced search or not
    var el = document.getElementById("advancedSearch");
    var display = el.style.display;
    
    // simple search
    if(display == "none"){
        // the query words
        var qBox = document.getElementById('q');
        
        if(qBox != null){
            q += encodeURI(qBox.value);
        }
       
        url += q;
        // HACK, dont show files in normal search
       //url += '&as_filetype=pdf&as_filetype=doc&as_filetype=ps&as_filetype=ppt&as_filetype=xls&as_filetype=rtf'
        
        document.location = url;
        return;
    }
    
    // advanced search takes search words from as_q
    var as_q = document.getElementById('as_q');
    
    q += encodeURI(as_q.value);
    url += q;    
    
    // exact words
    var as_epq = document.getElementById('as_epq');
    if(as_epq != null && as_epq.value != ''){
        url += '&as_epq=' + encodeURI(as_epq.value);
    }
    
    // one of the words at least
    var as_oq = document.getElementById('as_oq');  
    if(as_oq != null && as_oq.value != ''){
        url += '&as_oq=' + encodeURI(as_oq.value);
        
    }
    // and without the words
    var as_eq = document.getElementById('as_eq');
    if(as_eq != null && as_eq.value != ''){
        url += '&as_eq=' + encodeURI(as_eq.value);
    }
    // filetype filtering
    var as_ft = document.getElementById('as_ft');
    if(as_ft != null && as_ft.value != ''){
        url += '&as_ft=' + encodeURI(as_ft.value);
    }
    
    var as_filetype = document.getElementById('as_filetype');
    if(as_filetype != null && as_filetype.value != ''){
        url += '&as_filetype=' + encodeURI(as_filetype.value);
    }
  
    
    // the number of results in page
    var num = document.getElementById('num');
    if(num != null){
        url += '&num=' + num.value;
    }
   
    
    document.location = url;
    
//    document.mainform.submit();
}

function gotoURL(pUrl,indexNum) {
		if (pUrl != '') { 
			url = new String(pUrl);
			window.location.href = url;
	}
}


function changeMZProductsByBrand(ddlID,customerBrand) 
{

	var select = document.getElementById(ddlID);
	
	if (select != null) 
	{
		for (i=0; i<3; i++) 
		{
			if (i == select.selectedIndex) 
			{
				document.getElementById(customerBrand + i).style.display = "inline";
				document.getElementById(customerBrand + i).selected = "selected";	
						
			}
			else 
			{
				document.getElementById(customerBrand + i).style.display = "none";
			}
			
		}
	}

}


function changeMZDiscountPrice(selectID, productSitecoreID) 
{
	var select = document.getElementById(selectID);
	if (select != null) 
	{
		for (i=0; i<6; i++) 
		{
			if (i == select.selectedIndex) 
			{
				document.getElementById(productSitecoreID + i).style.display = "inline";
			}
			else 
			{
        document.getElementById(productSitecoreID + i).style.display = "none";
			}
			
		}
	}
}

function productsLoading(){
	document.getElementById('load').style.display = 'block';
}


/* teasers height fix */
$(document).ready(function() {
  var items =  $('.sectionPage .contentBox');

  var maxHeight;
  var i;
  
  for(i = 0; i < items.length; i = i + 2) {
    if($(items[i+1]).length > 0) {
      maxHeight = Math.max($(items[i]).height(), $(items[i+1]).height());
      $(items[i]).css('height', maxHeight + 'px');
      $(items[i+1]).css('height', maxHeight + 'px');
     }
  }
  
	/*
  $('.link-area .link a:first-child').each(function(index, item) {
    var top = Math.floor((52 - $(item).height()) );
    $(item).wrap('<div style="float: left; padding-top: ' + top + 'px;"></div>');
  });
	*/

	$('.link-area .link').each(function(index, item) {
	   
			var fchild = $('a:first-child', item);
			fchild.css('width', 'auto');
			var width = fchild.outerWidth();
			if(width > 210) width = 210;
			var p_left = 210 - width;
			if(p_left > 10) {
				p_left -= 10;
			}
			var div = $('<div style="float: left; text-align: left; width: ' + width + 'px; padding-left: ' + p_left + 'px; "></div>');
			fchild.wrap(div);
			var top = (104 - fchild.outerHeight())/2;
			$('div', item).css('padding-top', top + 'px');
			
		}); 

});


/*exhibitions*/
$(window).load(function () {
    $('.exhibition').each(function (index, item) {

     
       var padding_top = ($(item).height() - $('.ex_image', item).height()) / 2;

        if (padding_top > 0) {
            $('.ex_image', item).css('padding-top', padding_top + 'px');
        }
    });
});
/*end exhibitions*/

/* content links repositioning */
 $(document).ready(function() {
	var login = $('.roundTblWhite');
	 if(window.location.hostname.indexOf('nilfisk.')>=0 && window.location.hostname.indexOf('consumer.')<0  && window.location.href.toLowerCase().indexOf('/products/')<0)
		{
	if(login.size() == 0) {
		
		var top = 20;
		
		var title = $('#mainContent .documentTitle');
		if(title.size() == 1) {
			top += title.outerHeight();
		}
		
		var p = $('#mainContent p');
		if(p.size() > 0) {
			top += parseInt(p.css('margin-top'));
			top += parseInt(p.css('padding-top'));
		}
		
		var date = $('#mainContent .dateLeft');
		if(date.size() > 0) {
			top += date.outerHeight();
		}
		
		$('#contents').css('position', 'relative');
		$('.toolsTbl')
			.css('position', 'absolute')
			.css('top', top + 'px')
			.css('right', '50px');
	}
	}
});
