
/*****************************
	MENU DISPLAY Function
*****************************/

var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){ c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible';}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

/*
EASY TABS 1.2 Produced and Copyright by Koller Juergen
www.kollermedia.at | www.austria-media.at
Need Help? http:/www.kollermedia.at/archive/2007/07/10/easy-tabs-12-now-with-autochange
You can use this Script for private and commercial Projects, but just leave the two credit lines, thank you.
*/

//EASY TABS 1.2 - MENU SETTINGS
//Set the id names of your tablink (without a number at the end)
var tablink_idname = new Array("tablink")
//Set the id name of your tabcontentarea (without a number at the end)
var tabcontent_idname = new Array("tabcontent") 
//Set the number of your tabs
var tabcount = new Array("3")
//Set the Tab wich should load at start (In this Example:Tab 2 visible on load)
var loadtabs = new Array("1")  
//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = 1;
//the speed in seconds when the tabs should change
var changespeed = 3;
//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 0;
//END MENU SETTINGS

/*Swich EasyTabs Functions - no need to edit something here*/
function easytabs(menunr, active) {
	if (menunr == autochangemenu) {
		currenttab=active;
	}
	if ((menunr == autochangemenu)&&(stoponhover==1)) {
		stop_autochange()
	}
	else if ((menunr == autochangemenu)&&(stoponhover==0)) {
		counter=0;
	}
	menunr = menunr-1;
	for (i=1; i <= tabcount[menunr]; i++) {
		document.getElementById(tablink_idname[menunr]+i).className='tab'+i;
		document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';
	}
	document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';
	document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';
}
var timer;
counter=0;
var totaltabs=tabcount[autochangemenu-1];
var currenttab=loadtabs[autochangemenu-1];

function start_autochange() {
	counter=counter+1;
	timer=setTimeout("start_autochange()",1000);
	if (counter == changespeed+1) {
		currenttab++;
		if (currenttab>totaltabs) {
			currenttab=1
		}
		easytabs(autochangemenu,currenttab);
		restart_autochange();
	}
}

function restart_autochange(){
	clearTimeout(timer);
	counter=0;
	start_autochange();
}

function stop_autochange() {
	clearTimeout(timer);counter=0;
}

window.onload=function() {
	locPath = location.pathname
	//alert(locPath.indexOf("/"))
	//if (path == '/' || path == 
	initProd();
}

function initProd() {
	document.getElementById("CONV").style.display = "block";
	document.getElementById("STRAP").style.display = "block";
	document.getElementById("WRAP").style.display = "block";
	var menucount=loadtabs.length;
	var a = 0;
	var b = 1;
	do {
		easytabs(b, loadtabs[a]);
		a++;
		b++;
	}
	while (b<=menucount);
	if (autochangemenu!=0) {
		start_autochange();
	}
}

function changeText(field)
{
	var inputString = document.getElementById(field) // The input text field
	var outputString = document.getElementById(field) // The output text field
	var tmpStr, tmpChar, preString, postString, strlen;
	tmpStr = inputString.value.toLowerCase();
	tmpStr = tmpStr.replace(/^\s+|\s+$/g,"");
	stringLen = tmpStr.length;
	if (stringLen > 0)
	{
		for (i = 0; i < stringLen; i++)
		{
			if (i == 0)
			{
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,stringLen);
				tmpStr = tmpChar + postString;
			}
			else
			{
				tmpChar = tmpStr.substring(i,i+1);
				if (tmpChar == " " && i < (stringLen-1))
				{
					tmpChar = tmpStr.substring(i+1,i+2).toUpperCase();
					preString = tmpStr.substring(0,i+1);
					postString = tmpStr.substring(i+2,stringLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	if (field.indexOf("Email") > 0) {
		tmpStr = tmpStr.toLowerCase(); }
	outputString.value = tmpStr;
}

function formHandler(form) 
{
	var URL = document.form.site.options[document.form.site.selectedIndex].value;
	return URL
}

function currLocation()
{
	var strLoc = location.pathname
	//var Loc = 
	//location = strLoc.search('francais')
	if (strLoc.search("francais")>0)
	{
		pos = 2
		url = "/francais/industry/"
		ext = ".html"
	}
	else
	{
		if (strLoc.search("espanol")>0)
		{
			pos = 3
			url = "/espanol/industry/"
			ext = ".html"
		}
		else
		{
			if (strLoc.search("distributors")>0)
			{
				pos = 1
				url = "/distributors/industry/"
				ext = ".asp"
			}
			else
			{
				pos = 1
				url = "/industry/"
				ext = ".html"
			}
		}
	}
}



function loadList()
{
	/* Special cases dropdown	*/
	currLocation()
	var selSpecial = document.getElementById("selSpecial");
	var arrList = 
		new Array(
			new Array("auto", "Automotive","Automobile", "Automotor"),
			new Array("food", "Beverages & Food", "Alimentaire et Breuvages", "Bebidas y Alimentos"),
			new Array("blocks", "Blocks, Bricks & Mulch", "Blocs, briques et paillis", "Bloques y ladrillos"),
			new Array("construction", "Construction", "Construction", "Construcción"),
			new Array("hardgoods", "Const. Hard Goods", "Biens durables de const.", "Bienes de la construcción"),
			new Array("dist", "Distribution Center", "Centres de distribution", "Centros de distribución"),
			new Array("electrical", "Electricals", "Produits électriques", "Eléctrica"),
			new Array("furniture", "Furniture", "Meubles", "Muebles"),
			new Array("horticultural", "Horticultural", "Horticulture", "Horticultura"),
			new Array("industrial", "Industrial Materials", "Matériaux industriels", "Materiales industriales"),
			new Array("packaging", "Packaging", "Emballage", "Embalaje"),
			new Array("paint", "Paint", "Peinture", "Pintura"),
			new Array("paper", "Paper", "Papier", "Papel"),
			new Array("pharma", "Pharmaceutical", "Pharmaceutique", "Farmacéutica"),						
			new Array("printing", "Printing", "Imprimerie", "Imprenta"),
			new Array("steel", "Steel", "Acier", "Acero"),			
			new Array("textile", "Textile", "Textile", "Textil"),
			new Array("all", "Other Industries", "Autres industries", "Otras industrias")
		);
	for (var i = 0; i < arrList.length; i++) 
	{
		selSpecial.options[i] = new Option(arrList[i][pos],url + arrList[i][0] + ext);
	}
	//selSpecial=selSpecial.sort();

}

lunch_javascript = function ()
{
		loadList();
}

function newWindow(options, hauteur) {
	if (options=="smartfeat.asp?option=panel" || options=="wrwafeat.asp?option=carriage" || options=="smartfeat.asp?option=tower")
	{
		optWindow = window.open(options,"optWin", "width=900,height="+hauteur+",location=no,menubar=0,resizable=0,scrollbars=1,status=no,titlebar=0,toolbar=0,left=10,top=10");
	}
	else 
	{
		optWindow = window.open(options,"optWin", "width=860,height="+hauteur+",location=no,menubar=0,resizable=1,scrollbars=1,status=no,titlebar=0,toolbar=0,left=10,top=10");
	}
	optWindow.focus();
}


function popUpVideo(URL) {
	//VideoWin = window.open(URL, id," toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=344,left = 587.5,top = 428");
	VideoWin = window.open(URL,"optWin", "width=425,height=344,location='no',menubar='no',resizable='yes',scrollbars='no',status='no',titlebar='no',toolbar='no',left=10,top=10");
	VideoWin.focus();
}

function ValidateEmail()
{
	if (document.frmEmail.txtEmail.value == "") 
	{
		alert("Please enter a value in the Email address field");
		document.frmEmail.txtEmail.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function createFormAndSubmit(SW_type) {
	 var submitForm = document.createElement("FORM");
	 document.body.appendChild(submitForm);
	 submitForm.method = "POST";
	 //return submitForm;
	
	if (navigator.appName == "Microsoft Internet Explorer") {
		var newElement = document.createElement("<INPUT TYPE='HIDDEN' NAME='SW_type' ID='SW_type' VALUE='" + SW_type + "'>");
	}
	else {	
		var newElement = document.createElement("INPUT");
		newElement.type = "hidden";
		newElement.name = 'SW_type';
		newElement.id = 'SW_type';
		newElement.value = SW_type;
	}
	submitForm.appendChild(newElement);
	submitForm.action= "stretch_wrappers.asp";
	submitForm.submit();
}


function ValidateLitShipmentForm()
{
	if (document.frmLitShipment.txtFullname.value == "")
	{
		alert("Please enter a value for the field: Full Name");
		document.frmLitShipment.txtFullname.focus();
		return false;
	}
	else if (document.frmLitShipment.txtCompany.value == "") 
	{
		alert("Please enter a value for the field: Company Name");
		document.frmLitShipment.txtCompany.focus();
		return false;
	}	
	else if (document.frmLitShipment.txtAddress.value == "") 
	{
		alert("Please enter a value for the field: Address");
		document.frmLitShipment.txtAddress.focus();
		return false;
	}
	else if (document.frmLitShipment.txtCity.value == "") 
	{
		alert("Please enter a value for the field: City");
		document.frmLitShipment.txtCity.focus();
		return false;
	}
	else if (document.frmLitShipment.txtState.value == "") 
	{
		alert("Please enter a value for the field: State");
		document.frmLitShipment.txtState.focus();
		return false;
	}	
	else if (document.frmLitShipment.txtCountry.value == "") 
	{
		alert("Please enter a value for the field: Country");
		document.frmLitShipment.txtCountry.focus();
		return false;
	}	
	else if (document.frmLitShipment.txtZip.value == "") 
	{
		alert("Please enter a value for the field: Zip");
		document.frmLitShipment.txtZip.focus();
		return false;
	}	
	else if (document.frmLitShipment.txtPhone.value == "") 
	{
		alert("Please enter a value for the field: Phone");
		document.frmLitShipment.txtPhone.focus();
		return false;
	}	
	else
	{
		return true;
	}
}
