﻿//surpress ie errors window
window.onerror = function(){
    return true;
}
function submitMe(val)
{
	form = document.forms.regionSelectForm;
	form.submit();
}
//below function is used inconjunction with rotating image flash movie /inc/balances.php
//a flash movie products2.swf/fla when view image button is pushed function in flash movie
//calls function below which creates a cookie of the image name wanted for enlarging
//the cookie created below is ued by php in balances.php to render image
//howvever as a cookie is being used so the page needs to be reloaed so cookie is updated
//I have had to use two different methods to achieve this as both main browsers would only
//work on one or the other method
//IE used soft reload method go(0) where as firefox gets sent to get_images.php then returned back
//to balances.php
function openNewWindow(URLtoOpen, windowName, windowFeatures) 
{
 	var the_cookie = "smallImg="+ URLtoOpen;
 	document.cookie= the_cookie
	
	if(navigator.appVersion.indexOf("MSIE") != -1)
	{
		history.go(0);
	}
	else
	{
		location.href = "/inc/get_image.php";
	}
}

function init()
{
  toggleDetails(1); 
}
function symbolExplain(name, action, lang)
{
	if(lang == "de")
	{
	 	sentence = "Fahren Sie mit der Maus über die Symbole für nähere Beschreibung";
	}
	else if(lang == "fr")
	{
		sentence = "Déplacer votre souris au-dessus des symboles pour une explication";
	}
	else if(lang == "es")
	{
		sentence = "para mas información mueva el ratón sobre los símbolos";
	}
	else if(lang == "cn")
	{
		sentence = "鼠标移动到图标上显示提示说明";
	}
	else
	{
		sentence = "Move mouse over a symbol for an explanation";
	}
	if(action == "over")
	{
		document.getElementById("symbolKeyExplain").innerHTML = name;
	}
	else
	{
		document.getElementById("symbolKeyExplain").innerHTML = sentence;
	}
}
function changeLanguage(lang)
{
	var the_language_cookie = "lang=" + lang;
	document.cookie=the_language_cookie 
 //location = 'index.php';
}
function valSearch(myForm) 
{
    	if (myForm.cap.value == 'Capacity' && myForm.read.value == 'Readability') 
	{
        	window.alert("Please select a value for capacity and/or readablility");
        	return false;
    	}
	else  if (myForm.cap.value == 'Kapazität' && myForm.read.value == 'Ablesbarkeit') 
	{
        	window.alert("Bitte wählen Sie einen Wert für Kapazität und/oder Ablesbarkeit");
        	return false;
    	}
	else  if (myForm.cap.value == 'Capacidad' && myForm.read.value == 'Legibilidad') 
	{
        	window.alert("Por favor seleccione un valor de capacidad y/o resolución");
        	return false;
    	}
	else  if (myForm.cap.value == '最大称量值' && myForm.read.value == '可读值') 
	{
        	window.alert("请选择量程或者可读性的值");
        	return false;
    	}
	else  if (myForm.cap.value == 'Capacité' && myForm.read.value == 'Précision') 
	{
        	window.alert("Veuillez sélectionner une valeur pour la capacité et/ou la précision");
        	return false;
    	}
   
    return true;
}
function valSearchAdv(myForm, lang) {
    if (myForm.cap.value == 'e.g. 1500' && myForm.read.value == 'e.g. 0.1') 
	{
        
		if(lang == "de")
		{
	 		window.alert("Bitte wählen Sie einen Wert für Kapazität und/oder Ablesbarkeit");
		}
		else if(lang == "fr")
		{
			window.alert("Veuillez sélectionner une valeur pour la capacité et/ou la précision");
		}
		else if(lang == "es")
		{
			window.alert("Por favor seleccione un valor de capacidad y/o resolución");
		}
		else if(lang == "cn")
		{
			window.alert("请选择量程或者可读性的值");
		}
		else
		{
			window.alert("Please select a value for capacity and/or readablility");
		}
		
        return false;
    }
    return true;
}
function emptyKWBox(myBox) {
    if (myBox.value == 'Keywords...') {
        myBox.value = '';
    }
}
function valKWSearch(myForm) 
{
    	if ((myForm.kwquery.value == 'keywords') || (myForm.kwquery.value == '')) 
	{
	 	window.alert("Please enter a keyword/s");
        	return false;
    	}
	else if ((myForm.kwquery.value == 'Stichwörter') || (myForm.kwquery.value == '')) 
	{
	 	window.alert("Please enter a keyword/s");
        	return false;
    	}
	else if ((myForm.kwquery.value == 'Palabras clave') || (myForm.kwquery.value == '')) 
	{
		 window.alert("Please enter a keyword/s");
        	return false;
    	}
	else if ((myForm.kwquery.value == '关键字') || (myForm.kwquery.value == '')) 
	{
		 window.alert("请输入关键字/词");
        	return false;
    	}
	else if ((myForm.kwquery.value == 'Mots clés') || (myForm.kwquery.value == '')) 
	{
	 	window.alert("Please enter a keyword/s");
        	return false;
    	}
    return true;
}
function valMarkets(myForm, lang) 
{
    if (myForm.marketTypes.value == '') 
	{
		if(lang == "en")
		{
			window.alert("Please select a market type from the drop down list");
        	return false;
		}
		else if(lang == "fr")
		{
			window.alert("Veuillez sélectionner un type de marché de la liste déroulante");
        	return false;
		}
		else if(lang == "de")
		{
			window.alert("Bitte wählen Sie einen Branchentyp aus der Drop-down-Liste");
        	return false;
		}
		else if(lang == "cn")
		{
			window.alert("请在下拉列表中选择型号");
        		return false;
		}
		else if(lang == "es")
		{
			window.alert("Por favor seleccione un mercado de la lista de abajo");
        	return false;
		}
    }
    return true;
}
function valpanSquare(myForm, lang) 
{
    if (myForm.panSizeSquare.value == '') 
	{
		if(lang == "en")
		{
			window.alert("Please select a pan size from the drop down list");
        	return false;
		}
		else if(lang == "fr")
		{
			window.alert("Veuillez sélectionner une taille de plateau dans la liste déroulante");
        	return false;
		}
		else if(lang == "de")
		{
			window.alert("Bitte wählen Sie eine Größe für die Wägeplatte aus der Drop-Down-Liste");
        	return false;
		}
		else if(lang == "cn")
		{
			window.alert("请在下拉列表中选择秤盘尺寸");
        	return false;
		}
		else if(lang == "es")
		{
			window.alert("Por favor seleccione un tamaño de plataforma de la lista de abajo");
        	return false;
		}
    }
    return true;
}
function valUnits(myForm, lang) 
{
    if (myForm.unitTypes.value == '') 
	{
		if(lang == "en")
		{
			window.alert("Please select a unit from the drop down list");
        	return false;
		}
		else if(lang == "fr")
		{
			window.alert("Veuillez sélectionner un type de marché de la liste déroulante");
        	return false;
		}
		else if(lang == "de")
		{
			window.alert("Bitte wählen Sie einen Branchentyp aus der Drop-Down-Liste");
        	return false;
		}
		else if(lang == "cn")
		{
			window.alert("请在下拉列表中选择单位");
        	return false;
		}
		else if(lang == "es")
		{
			window.alert("Por favor seleccione una unidad de la lista de abajo");
        	return false;
		}
    }
    return true;
}
function valPanRound(myForm, lang) 
{
    if (myForm.panSizeRound.value == '') 
	{
		if(lang == "en")
		{
			window.alert("Please select a pan size from the drop down list");
        	return false;
		}
		else if(lang == "fr")
		{
			window.alert("Veuillez sélectionner une taille de plateau dans la liste déroulante");
        	return false;
		}
		else if(lang == "de")
		{
			window.alert("Bitte wählen Sie eine Größe für die Wägeplatte aus der Drop-Down-Liste");
        	return false;
		}
		else if(lang == "cn")
		{
			window.alert("请在下拉列表中选择秤盘尺寸");
        	return false;
		}
		else if(lang == "es")
		{
			window.alert("Por favor seleccione un tamaño de plataforma de la lista de abajo");
        	return false;
		}
    }
    return true;
}
//open close search and dealer zone login tabs on lefthand menu bar
function viewLayer(openLayer, closeLayer, closeLayer2)
{
	document.getElementById(closeLayer).style.display = 'none';
	document.getElementById(openLayer).style.display = 'block';
	document.getElementById(closeLayer2).style.display = 'none';
}

var tsx=0;
function tsinit(x)
{
	tsx=x;
	s = document.cookie + ";";
	i = s.indexOf("P14TS");
	if (i < 0)
	{
		if (i == "") document.getElementById("ts1").style.borderColor='#547FBD'; else document.getElementById("ts1").style.borderColor='#547FBD';
	 	return;
	}
	j = s.indexOf(";", i);
	if (j < 0) return;
	n = parseFloat(s.substr(i+6, j-i-6));
	if (n < 1 || n > 4) return;
	tschange(n);
}
//increase/decrease font size
function tschange(n)
{
	e = document.getElementById("tscontent");
	//alert(e)
	if (e == null) return;
	document.cookie = "P14TS=" + n + "; expires=Sun, 01 Dec 2030 23:59:59 GMT; path=/; domain=adamequipment.com.cn;";
	if (document.getElementById("ts1"))
	{
		if (n == 1) document.getElementById("ts1").style.borderColor='#547FBD'; else document.getElementById("ts1").style.borderColor='#ccc';
		if (n == 2) document.getElementById("ts2").style.borderColor='#547FBD'; else document.getElementById("ts2").style.borderColor='#ccc';
		if (n == 3) document.getElementById("ts3").style.borderColor='#547FBD'; else document.getElementById("ts3").style.borderColor='#ccc';
		if (n == 4) document.getElementById("ts4").style.borderColor='#547FBD'; else document.getElementById("ts4").style.borderColor='#ccc';
	}
	if (n == 4)
	{
		n = 130;
		h = "300px"
		g = "260px"
		k = "230px";
		j = "200px";
		m = "200px";
		o = "110px";
	}
	else if(n == 1)
	{
		n = 100
		h = "200px";
		g = "200px";
		k = "170px";
		j = "150px";
		m = "200px";
		o = "95px";
	}
	else if(n == 2)
	{
		n = 90 + n * 10;
		h = "240px";
		g = "220px";
		k = "190px";
		j = "160px";
		m = "220px";
		o = "95px";
	}
	else
	{
		n = 90 + n * 10;
		h = "270px";
		g = "240px";
		k = "210px";
		j = "180px";
		m = "200px";
		o = "105px";
	}
	e.style.fontSize = n + "%";
	
	for (i=1 ; i <= tsx ; i++)
	{
		e = document.getElementById("tsx" + i);
		if (e) e.style.fontSize = n + "%";
	}
	e = document.getElementById("lower_columns");
	if (e) e.style.height = h;
	e = document.getElementById("homepageBox");
	if (e) e.style.height = g;
	e = document.getElementById("homepageBox2");
	if (e) e.style.height = g;
	e = document.getElementById("homepageBox3");
	if (e) e.style.height = g;
	e = document.getElementById("homepageFindOutMore");
	if (e) e.style.top = k;
	e = document.getElementById("homepageFindOutMore2");
	if (e) e.style.top = k;
	e = document.getElementById("quick_link_columns");
	if (e) e.style.height = j;
	e = document.getElementById("greenLineBottomBalances");
	if (e) e.style.height = '13px';
	e = document.getElementById("quick_link_fourth");
	if (e) e.style.height = o;
	e = document.getElementById("tsheader");
	if (e) e.style.fontSize = n + "%";
	e = document.getElementById("tsfooter");
	if (e) e.style.fontSize = n + "%";
}





/**
	Frédéric Saunier
	http://www.tekool.net/javascript/backtothehtml

	This program is part of a free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
**/
/*****************************************************************************
* BackToTheHtml Command
*///**************************************************************************
function BackToTheHtml(node)
{
	if(node == null)
		this.node = document; 
	else
		this.node = node; 
};
BackToTheHtml.prototype.node = null;

BackToTheHtml.prototype.execute = function()
{
	this.activateObject();
}
BackToTheHtml.prototype.activateObject = function(domObject)
{
	var aDomObject = this.node.getElementsByTagName('object');
	var activationObject;
	for(var i=0; i<aDomObject.length; i++)
		if
		(
			aDomObject[i].getAttributeNode('BackToTheHtml') == null
			&&
			(activationObject = this.getActivationObject(aDomObject[i])) != null
		)
			activationObject.execute();
};
BackToTheHtml.prototype.getActivationObject = function(domObject)
{
	var classid = domObject.classid.toUpperCase().substr('clsid:'.length);
	var mimeType = domObject.type.toLowerCase();

	switch(true)
	{
		case 
			classid == 'D27CDB6E-AE6D-11CF-96B8-444553540000' 
			||
			mimeType == 'application/x-shockwave-flash'
		:
			return new ActivateObjectFlash(domObject);

		default :
			return null;
	}
};
BackToTheHtml.uniqueID = function(prefix)
{
	var sPrefix;
	if(prefix == null)
		sPrefix = 'uniqueId';
	else
		sPrefix = prefix;
		
	var i=0;
	while(document.getElementById(sPrefix + (i++)))
		;
	return sPrefix + (i-1);
};
BackToTheHtml.isParentOf = function(parent,child)
{
	var found = false;
	for(var i=0; i<parent.childNodes.length; i++)
		if(parent.childNodes[i] == child)
			return true;
		else
			found = arguments.callee(parent.childNodes[i],child);

	return found;
}
/*****************************************************************************
* ActivateObject Command
*///**************************************************************************
function ActivateObject(domObject)
{
	this.domObject = domObject;
}

ActivateObject.prototype.domObject = null;
ActivateObject.prototype.classid = null;
ActivateObject.prototype.aHtmlAttribute = ['accessKey','align','alt','archive','border','code','codeBase','codeType','declare','dir','height','hideFocus','hspace','lang','language','name','standby','tabIndex','title','useMap','vspace','width'];
ActivateObject.prototype.aObjectProperty = null;

ActivateObject.prototype.execute = function()
{
	this.xndObjectId = BackToTheHtml.uniqueID();
	this.setTextHtml();
	this.writeObject();

	this.xndObject = document.getElementById(this.xndObjectId);
	this.setSpecialProperties();
	this.removeOriginalObject();
}

ActivateObject.prototype.setTextHtml = function()
{
	var str = '';
	str += '<object BackToTheHtml ' + '\n';
	str += ' classid="clsid:' + this.classid + '" ' + '\n';

	//Add HTML attributes to the <object> tag
	for(var i=0; i<this.aHtmlAttribute.length; i++)
	{
		var name = this.aHtmlAttribute[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '')
			str += '\t' + name + '="' + this.domObject[name].toString() + '" ' + '\n';
	}

	str += 'id="' + this.xndObjectId + '" ' + '\n';
	str += '>';

	for(var i=0; i<this.aObjectProperty.length; i++)
	{
		var name = this.aObjectProperty[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '' )
			str += '\t<param name="' + name + '" value="' + this.domObject[name].toString() + '"></param>' + '\n';
	}
	str += '</object>';

	this.textHtml = str;
};

ActivateObject.prototype.writeObject = function()
{
	this.domObject.insertAdjacentHTML("afterEnd",this.textHtml);
};

ActivateObject.prototype.setSpecialProperties = function()
{
	if(typeof this.domObject.className != 'undefined' && this.domObject.className.toString() != '')
		this.xndObject.className = this.domObject.className

	if(typeof this.domObject.style.cssText != 'undefined' && this.domObject.style.cssText.toString() != '')
		this.xndObject.style.cssText = this.domObject.style.cssText;

	if(typeof this.domObject.SWRemote != 'undefined' && this.domObject.SWRemote.toString() != '')
		this.xndObject.FlashVars = this.domObject.SWRemote;

	if(typeof this.domObject.codebase == 'undefined' || this.domObject.codebase.toString() == '')
		this.xndObject.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0';

	if(typeof this.domObject.id != 'undefined' && this.domObject.id.toString() != '')
		this.xndObject.id = this.domObject.id;

};

ActivateObject.prototype.removeOriginalObject = function()
{
	this.domObject.parentNode.removeChild(this.domObject);
};

/*****************************************************************************
* ActivateObjectFlash Command
*///**************************************************************************
function ActivateObjectFlash(domObject)
{
	ActivateObject.call(this,domObject);
}
ActivateObjectFlash.prototype = new ActivateObject;
ActivateObjectFlash.prototype.aObjectProperty = ['FrameNum','Playing','Quality','Quality2','Scalemode','Scale','AlignMode','SAlign','BackgroundColor','BGColor','Loop','Movie','WMode','Base','DeviceFont','EmbedMovie','SWRemote','FlashVars','AllowScriptAccess'];
ActivateObjectFlash.prototype.classid = 'D27CDB6E-AE6D-11CF-96B8-444553540000';
/*****************************************************************************
* Script initialisation
*///**************************************************************************
if(typeof ActiveXObject != 'undefined' && typeof Function.call != 'undefined')
{
	var styleId = BackToTheHtml.uniqueID();
	document.write('<style id="' + styleId + '" ></style>');
	var domStyle = document.getElementById(styleId);

	var isHead = false;
	var aHead = document.getElementsByTagName('head');
	for(var i=0; i<aHead.length; i++)
		if(BackToTheHtml.isParentOf(aHead[i],domStyle))
			isHead = true;

	if(isHead)
	{
		document.write('<style type="text/css">OBJECT{visibility:hidden;}</style>');
		document.onreadystatechange = function()
		{
			if(document.readyState == 'complete')
			{
				new BackToTheHtml().execute();
				document.styleSheets[document.styleSheets.length-1].addRule("OBJECT","visibility:visible;");
				//alert('head');
				//alert(document.body.innerHTML);
			}
		}
	}
	else
	{
		new BackToTheHtml().execute();
		//alert('body');
		//alert(document.body.innerHTML);
	}
	
	domStyle.parentNode.removeChild(domStyle);
}

function toggleBasket(idVal,img) 
{
  if(idVal == "start")//set all hide/show menu items to 'none' 
  {
	var allElements = new Array("hotels","bed"); 
	for (i = 0; i < allElements.length; i++)
	{
		ells = document.getElementById(allElements[i])
	 	ells.style.display = 'none'
	}	
  }
  if (document.getElementById(idVal))
  {
	var basket
    var img
    basket = document.getElementById(idVal)
    img = document.getElementById(img)
    if (basket.style.display == "none")
    {
      basket.style.display = 'inline'
      img.src =  '../img/homepage/red_arrow_down.gif'
    } 
	else 
	{
      
	   basket.style.display = 'none'
      img.src =  '../img/homepage/red_arrow.gif'
    }
  }
}

function ControlVersion()
{
	var version;
	var hasFlash = false;
	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");
		hasFlash = true;
	} 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");
			hasFlash = true;

		} 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");
			hasFlash = true;
		} 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";
			hasFlash = false
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
			hasFlash = false
		} catch (e) {
			version = -1;
			hasFlash = false
		}
	}
	
	return hasFlash;
	
}

function checkForFlash()
{
	
	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;
	var isMozilla = (navigator.userAgent.indexOf("Mozilla") != -1) ? true : false;
	
	var MM_contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	
	if (isIE && isWin && !isOpera ) 
	{
		MM_FlashCanPlay = ControlVersion();
		
	}	
	
	else if (isMozilla) 
	{
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i)
		{
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i]; 
		}
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	
	if (MM_FlashCanPlay) 
	{
		return true;
	}
	 else
	 {
		return false;
	}
}

function toggleBoxes(chkd) {
    myArrayLength = document.models_to_show.elements.length - 3;
    for (i = 0; i < myArrayLength; i++) {
        document.models_to_show.elements[i].checked = chkd
    }
}
function subSpecs(myform, lang) 
{
    if (valCheckBoxes(lang)) 
	{
	    myform.submit();
        return false;
    } 
	  return false;
}
function valCheckBoxes(lang) {

    myArrayLength = document.models_to_show.elements.length - 3;
    var atLeastOneChecked = 0;
	var total = 0;
    for (i = 0; i < myArrayLength; i++) {
        if (document.models_to_show.elements[i].checked) 
		{
            atLeastOneChecked = 1;
			total += 1; 
        }
    }
	if(total > 11)
	{
		if(lang == "de")
		{
	 		alert("Bitte nicht mehr als 11 Modelle auswählen")
		}
		else if(lang == "fr")
		{
			alert("Veuillez ne pas sélectionner plus de 11 modèles")
		}
		else if(lang == "es")
		{
			alert("Please do not select more than 11 models")
		}
		else if(lang == "cn")
		{
			alert("选择的型号不能超过11个")
		}
		else
		{
			alert("Please do not select more than 11 models")
		}
		
		return false;
	}
    if (atLeastOneChecked != 1) {
		if(lang == "de")
		{
	 		window.alert("Please select one  or more models from the list.");
		}
		else if(lang == "fr")
		{
			window.alert("Please select one or more models from the list.");
		}
		else if(lang == "es")
		{
			window.alert("Please select one or more models from the list.");
		}
		else if(lang == "cn")
		{
			window.alert("请在列表中选择一个或多个型号.");
		}
		else
		{
			window.alert("Please select one or more models from the list.");
		}
        
        return false;
    }
	else
	{
    	return true;
	}
	
}
