/* ------------------- Start: Global Javascripts -- any theme can use these functions ------------------- */
	function GetObjRef (objId) {
		var returnObj = null;
		if (document.getElementById) {
			returnObj = document.getElementById(objId);
		}
		else if (document.all) {
			returnObj = document.all[objId];
		}
		return returnObj;
	}

	function GetTarget (e) {
		if (!e) {e = window.event;}
		if (!e) {return null;}
		var target;
		if (e.target) {
			target = e.target;
		}
		else if (e.srcElement) {
			target = e.srcElement;
		}
		return target;
	}
	function ReturnTarget (e, returnValue) {
		if (!e) {e = window.event;}
		if (!e) {return null;}
		var target;
		if (e.preventDefault && returnValue == false) {
			e.preventDefault ();
		}
		else if (e.returnValue) {
			e.returnValue = returnValue;
		}
		else {
			return returnValue;
		}
	}

	
	function GetBodyWidth () {
		if (document.body.clientWidth) {
			return document.body.clientWidth;
		}
		else if (document.width) {
			return document.width;
		}
		return null;
	}
	function GetBodyHeight () {
		if (document.body.clientHeight) {
			return document.body.clientHeight;
		}
		else if (document.height) {
			return document.height;
		}
		return null;
	}
	
	
	
	
	





	function SyncProp (prop, thisObjIds, targetObjIds, offsets, minValue, noresize) {
		if (offsets == null) {offsets = 0;}
		if (minValue == null) {minValue = -1;}
		if (noresize == null) {noresize = false;}
		var propL = prop.toLowerCase();

		var objPropValue = -1;
		var offset = 0;
		for (var i=0; i<thisObjIds.length; i++) {
			var thisObj = GetObjRef(thisObjIds[i]);
			if (thisObj && thisObj["offset" + prop]) {
				var tempOffset = 0;
				if (offsets[i]) {
					tempOffset = offsets[i];
				}
				else {
					tempOffset = offsets;
				}
				if (thisObj["offset" + prop] + tempOffset > objPropValue) {
					objPropValue = thisObj["offset" + prop] + tempOffset;
					offset = tempOffset;
				}
			}
		}
		if (objPropValue > -1) {
			if (objPropValue < minValue) {
				objPropValue = minValue;
			}
			for (var i=0; i<targetObjIds.length; i++) {
				var targetObj = GetObjRef(targetObjIds[i]);
				if (targetObj && targetObj.style) {
					var targetValue = objPropValue;
					targetObj.style[propL] = targetValue + "px";
				}
			}
		}
	}
	function SyncWidth (thisObjIds, targetObjIds, offsets, noresize) {
		return SyncProp ("Width", thisObjIds, targetObjIds, offsets, noresize);
	}
	function SyncHeight (thisObjIds, targetObjIds, offsets, noresize) {
		return SyncProp ("Height", thisObjIds, targetObjIds, offsets, noresize);
	}










	
	
	
	function SetMinForPosition (objId, prop1, prop2, minValue, defaultValue) {
		var obj = GetObjRef(objId);
		var offsetPropName = "offset" + prop1.charAt(0).toUpperCase() + prop1.substring(1, prop1.length);
		if (obj && obj.style) {
			obj.style[prop1] = "auto";
			obj.style[prop2] = defaultValue + "px";
			if (!obj[offsetPropName]) {
				trackingProp = obj.style[prop1];
			}
			if (obj[offsetPropName] < minValue) {
				obj.style[prop1] = minValue + "px";
				obj.style[prop2] = "auto";
				//GetObjRef("StatusH1").innerHTML = obj.style[prop1] + ";" + obj.style[prop2] ;
			}
		}
	}
	function SetMinLeftForRight (objId, minValue, defaultValue) {
		SetMinForPosition (objId, "left", "right", minValue, defaultValue)
	}
	function SetMinTopForBottom (objId, minValue, defaultValue) {
		SetMinForPosition (objId, "top", "bottom", minValue, defaultValue)
	}






	function SetWidthByRelativeObjects (objId, relativeObjIdArray, offset, left, minValue) {
		if (offset == null) { offset = 0;}
		if (minValue == null) { minValue = 0;}
		var thisObj = GetObjRef (objId);
		if (!thisObj) {
			return null;
		}
		var value2 = 0;
		for (var i=0; i<relativeObjIdArray.length; i++) {
			var tempObj = GetObjRef (relativeObjIdArray[i]);
			if (tempObj && tempObj.offsetWidth && value2 < (tempObj.offsetLeft + tempObj.offsetWidth)) {
				value2 = tempObj.offsetLeft + tempObj.offsetWidth;
			}
		}
		if (value2 < minValue) {
			value2 = minValue;
		}
		if (value2 != 0 || value2 < thisObj.offsetWidth) {
			if (thisObj.style) {
				thisObj.style.left = left + "px";
				thisObj.style.width = value2 + offset + "px";
			}
		}
	}
	function SetHeightByRelativeObjects (objId, relativeObjIdArray, offset, left, minValue) {
		if (offset == null) { offset = 0;}
		if (minValue == null) { minValue = 0;}
		var thisObj = GetObjRef (objId);
		if (!thisObj) {
			return null;
		}
		var value2 = 0;
		for (var i=0; i<relativeObjIdArray.length; i++) {
			var tempObj = GetObjRef (relativeObjIdArray[i]);
			if (tempObj && tempObj.offsetWidth && value2 < (tempObj.offsetTop + tempObj.offsetHeight)) {
				value2 = tempObj.offsetTop + tempObj.offsetHeight;
			}
		}
		if (value2 < minValue) {
			value2 = minValue;
		}
		if (value2 != 0 || value2 < thisObj.offsetHeight) {
			if (thisObj.style) {
				thisObj.style.top = left + "px";
				thisObj.style.height = value2 + offset + "px";
			}
		}
	}







	function SetWidthByPercentage (thisObjId, width, offset, parentObjId) {
		var thisObj = GetObjRef (thisObjId);
		if (offset == null) { offset = 0;}
		if (thisObj) {
			if (parentObjId == null) {
				if (document.body.clientWidth) {
					thisObj.style.width = Math.floor(document.body.clientWidth * width/100) + offset + "px";
				}
				else if (document.width) {
					thisObj.style.width = Math.floor(document.width * width/100) + offset + "px";
				}
			}
			else {
				var parentObj = GetObjRef (parentObjId);
				if (parentObj) {
					if (parentObj.offsetWidth) {
						thisObj.style.width = Math.floor(parentObj.offsetWidth * width/100) + offset + "px";
					}
				}
			}
		}
	}
	function SetHeightByPercentage (thisObjId, height, offset, parentObjId) {
		var thisObj = GetObjRef (thisObjId);
		if (offset == null) { offset = 0;}
		if (thisObj) {
			if (parentObjId == null) {
				if (document.body.clientHeight) {
					thisObj.style.height = Math.floor(document.body.clientHeight * height/100) + offset + "px";
				}
				else if (document.height) {
					thisObj.style.height = Math.floor(document.height * height/100) + offset + "px";
				}
			}
			else {
				var parentObj = GetObjRef (parentObjId);
				if (parentObj) {
					if (parentObj.offsetHeight) {
						thisObj.style.height = Math.floor(parentObj.offsetHeight * height/100) + offset + "px";
					}
				}
			}
		}
	}


	var pageName = "";
	/* START: Order Center */
		function OrderCenter_InitCountryStateDropDown (stateContainerId, countrySelectName) {
			if (document.forms["orderForm"] && pageName == "OrderCenter") {
				if (document.forms["orderForm"][countrySelectName]) {
					var stateContainer = GetObjRef (stateContainerId);
					if (stateContainer) {
						if (document.forms["orderForm"][countrySelectName].value.indexOf (",US,") > -1) {
							stateContainer.style.display = '';
						}
						else {
							stateContainer.style.display = "none";
						}
					}
				}
			}
		}
		function OrderCenter_SetStateByCountry (thisCountry, stateContainerId) {
			var stateContainer = GetObjRef (stateContainerId);
			if (stateContainer) {
				if (thisCountry.value.indexOf (",US,") > -1) {
					stateContainer.style.display = '';
				}
				else {
					stateContainer.style.display = "none";
				}
			}
		}
	/* END: Order Center */

/* ------------------- End: Global Javascripts -- any theme can use these functions ------------------- */
