/*
--------------------------------------------------------
Search
--------------------------------------------------------
*/

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 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).click();
		return false
	}
	else
	{
		return true
	}
}


//window.attachEvent('onload', resizeContent);

function changeProdImg(group){
	group = "/images/spacer.gif";
	document.getElementById("productGroupImg").src = group;
	document.getElementById("productGroupImg").className = "productSmall";
	document.getElementById("productGroupImg").align = "right";
	}

/*
Change Picture (Product Introduction page)
*/

function changePicture(src){
	var path = src;
	var image = '<img src='+path+' alt="" class="" />';
	document.getElementById('productImage').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 = '<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="235" height="240" 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="240" height="320" name="flashvideo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	var video = '<embed src="/images/video.swf?video='+src+'&duration='+totalTime+'" quality="high" bgcolor="#FFFFFF" name="detectionExample" allowscriptaccess="sameDomain" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" align="middle" width="260" height="260">';
	}
	else{
	
	var video = '<div style="width:260px; height:260px; 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('productImage').innerHTML = video;
	
}

function isDefined(property) {
  return (typeof property != 'undefined');
}





// country dropdown
sfHover = function() {
if(document.getElementById("navlist")){
	var sfEls = document.getElementById("navlist").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function openProductComparison(){
	window.open('/Modules/Product Comparison/ProductComparison.aspx','productComparator', 'width=890,height=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes');
}

/*
	The Worldmap
*/

function showContinent(continent) {
	document.getElementById(continent).style.visibility = "visible";
	hideOthers(continent);
}
function hideOthers(continent) {
	elem = document.getElementById('pics');	
	elems = elem.getElementsByTagName('div');	
	for (var i = 0; i < elems.length; i++) {
		if (elems[i].id != continent && elems[i].id != 'pics' && elems[i].id != 'world') {
			//alert(elems[i].id);
			elems[i].style.visibility = "hidden";
		}
	}
}

function showMapList(list) {	
	elem = document.getElementById('maplists');
	elems = elems = elem.getElementsByTagName('div');
	for (var i = 0; i < elems.length; i++) {
		if (elems[i].id != 'maplists') {
			elems[i].style.display = "none";
		}
	}
	theelem = document.getElementById(list);
	if (theelem) {
		theelem.style.display = "block";
	}	
}

/*
/	The Worldmap
*/


/*Product comparator*/

function checkAndCompare(itm){
	
	
	//var showCol document.getElementById(itm);
	
	if(document.forms[0].comparator){
	var max = document.forms[0].comparator.length;
	var totalChecked = 0;
	var areaWidth = 440;
	
	// loop through checkboxes
	for (var idx = 0; idx < max; idx++) {
		
		document.forms[0].comparator[idx].disabled = false;
		document.getElementById("label"+document.forms[0].comparator[idx].value).style.color = "Black";
		
		var tdID = document.getElementById("col"+document.forms[0].comparator[idx].value);
		
		
		// count actives
		if (eval("document.forms[0].comparator[" + idx + "].checked") == true) {
			totalChecked += 1;
			if(document.all){
			tdID.style.display = "block";
			}
			else{
			tdID.style.display = "table-cell";
			}
			
			
		}
		else{
		
			tdID.style.display = "none";
		
		}
		
	}
	
	
	}
	// loop again and put nice width for td's
	for (var idx = 0; idx < max; idx++) {
	var tdID = document.getElementById("col"+document.forms[0].comparator[idx].value);
		var tdID = document.getElementById("col"+document.forms[0].comparator[idx].value);
		var tblID = document.getElementById("tbl"+document.forms[0].comparator[idx].value);
		if(tdID.style.width){
			tdID.style.width = (areaWidth/totalChecked)-2+"px";
			tblID.style.width = (areaWidth/totalChecked)-2+"px";
		}
	}
	
	if(totalChecked > 2){
		disableUnChecked();
	}
}
function disableUnChecked(){
var max = document.forms[0].comparator.length;

	for (var idx = 0; idx < max; idx++) {
	if (eval("document.forms[0].comparator[" + idx + "].checked") != true) {
		document.forms[0].comparator[idx].disabled = true;
		document.getElementById("label"+document.forms[0].comparator[idx].value).style.color = "Gray";
	}
	
	}

}

function openTechSpecPrint(path){
	
	var max = document.forms[0].comparator.length;
	var products = "";
	for (var idx = 0; idx < max; idx++) {
	if (eval("document.forms[0].comparator[" + idx + "].checked") == true) {
			
		products = products + document.forms[0].comparator[idx].value+"|";
	}
	
	}
	window.open(path+'&selected='+products, 'PopupPage','scrollbars=yes, resizable=yes', height='100%', width='100%');
	//alert(path+"&selected="+products)
}

/**

 {
	window.onload = init;

}

function init() {

	// Resize yellow left column to fill at least height of left menu
	var leftMenuH = document.getElementById("leftcol").offsetHeight;
	var contentH = document.getElementById("contentWide").offsetHeight;
	var leftContent = document.getElementById("contentLeft");

	if(leftMenuH>contentH){

		leftContent.style.height = leftMenuH+"px";
	}
	window.onload = init; {
	
	}
}

**/
function productsLoading(){
	document.getElementById('load').style.display = 'block';
}


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 GoToMYNilfisk()
{
	window.open('http://my.nilfisk-Alto.com/nilfisk-alto.asp');
}

function gotoURL(pUrl,indexNum) {
		if (pUrl != '') { 
			url = new String(pUrl);
			window.location.href = url;
	}
}

/*
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 = "";
}


