var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

var breakurl
var ccollect

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	} else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
	if(VALUE.charAt(iTemp) == w_space){
	} else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
	}
	iTemp = iTemp-1;
} //End While
return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		} else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


function clear_form(udform) {
	udform.reset();
	udform.email.focus();
}

function checkbox_checker(thisform) {
	if (thisform.annual.checked) {
		thisform.submit();
	} else {
		alert("Please select")
		return (false);
	}
}

function radio_checker(thisform) {
	// set var radio_choice to false
	var radio_choice_quarterly = false;
	var radio_choice_annual = false;
	var radio_choice_press = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < thisform.quarterly.length; counter++) {
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (thisform.quarterly[counter].checked)
			radio_choice_quarterly = true; 
	}
	for (incr = 0; incr < thisform.annual.length; incr++) {
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (thisform.annual[incr].checked)
			radio_choice_annual = true; 
	}
	for (ladder = 0; ladder < thisform.press.length; ladder++) {
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (thisform.press[ladder].checked)
			radio_choice_press = true; 
	}

	if ((!radio_choice_quarterly) && (!radio_choice_annual) && (!radio_choice_press)) {
		// If there were no selections made display an alert box 
		alert("Please select atleast one to continue")
		return (false);
	/* } else if (!radio_choice_annual)	{
		// If there were no selections made display an alert box 
		alert("Please select")
		return (false);
	} else if (!radio_choice_press)	{
		// If there were no selections made display an alert box 
		alert("Please select")
		return (false); */
	} else {
		// else submit the form
		thisform.submit();
	}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function validate_form(udform) {
	if(Trim(udform.email.value)==""){ 
		alert("Please fill in the 'Email-Address' box."); 
		udform.email.focus();
		return (false); 
	}
	if(Trim(udform.fn.value)==""){ 
		alert("Please fill in the 'First Name' box.");
		udform.fn.focus();
		return (false); 
	}

	if(Trim(udform.country.value)==""){ 
		alert("Please fill in the 'Country' box.");
		udform.country.focus();
		return (false); 
	}
	if ( udform.email.value == "" ) {
        alert ( "Please fill in the 'Email-Address' box." );
		udform.email.focus();
        return (false);
    } else {
		if (!isValidEmail(udform.email.value)) {
			alert ( "'Email-Address' not valid." );
			udform.email.focus();
			return (false);
		}
	}

	if (udform.name == "ordering") {
		if(Trim(udform.address.value)==""){ 
			alert("Please fill in the 'Address' box."); 
			udform.address.focus();
			return (false); 
		}
		if (udform.address.value == "") {
			alert ( "Please fill in the 'Address' box." );
			udform.address.focus();
			return (false);
		}
	}

	if (udform.fn.value == "") {
        alert ( "Please fill in the 'First Name' box." );
		udform.fn.focus();
        return (false);
    } else if (udform.country.value == "") {
        alert ( "Please fill in the 'Country' box." );
		udform.country.focus();
        return (false);
    } else {
		// else submit the form
		udform.submit();
	}
}

function printableVersion(){
	var now = new Date();
	printWin = window.open() 
	var newContent = ''; 
	newContent += "<html><he"+"ad>"; 
	newContent+="<title>Print Version</title>\n"; 
	newContent+="<link rel='stylesheet' href='/wps/wcm/autoliv/css/style_print.css' type='text/css'>";
	newContent+="</head>\n"; 
	newContent+="<table width='613' border='0' align='left' cellpadding='0' cellspacing='0'>\n";
	newContent+="<tr><td width='5%'>&nbsp;</td>\n";
	newContent+="<td background='/wps/wcm/autoliv/images/header/headerblend.jpg'>\n";
	newContent+="<table width='100%'  border='0' cellspacing='0' cellpadding='0'>\n";
	newContent+="<tr>\n";
	newContent+="<td width='54'><img border='0' src='/wps/wcm/autoliv/images/header/logo.gif'></td>\n";
	/* AH: Changed slogan 26/06/06
	newContent+="<td><img height='31' src='/wps/wcm/autoliv/images/header/slogan.gif' width='138'/></td>\n"; */
	newContent+="<td><img height='31' src='/wps/wcm/autoliv/images/header/autoliv_slogan.gif' width='138'/></td>\n";
    newContent+="</tr></table></td>\n";
	newContent+="<tr><td colspan='2'>&nbsp;</td></tr>";
	newContent+="<tr><td width='5%'>&nbsp;</td>";
	newContent+="<td><div>";
	newContent+=document.getElementById("printable").innerHTML 
	newContent+="</div>\n";
	newContent+="</td></tr>";
	newContent+="<tr><td colspan='2'>&nbsp;</td></tr>";
	newContent+="<tr><td width='5%'>&nbsp</td>";
	newContent+="<td align='center'>Copyright "+now.getYear()+" Autoliv Inc . All rights reserved</td></tr>";	
	newContent+="</table>\n";
	newContent+="</html>\n"; 
	printWin.document.write(newContent);
	printWin.focus();
} 

function addtofav()  {
   if (document.all) {
      window.external.AddFavorite(document.URL)
   }
}

if (document.getElementById){
	document.write('<style type="text/css">')
	document.write('.switchcontent{display:none;}')
	document.write('</style>')
}

function getElementbyClass(classname){
	ccollect=new Array()
	var inc=0
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (i=0; i<alltags.length; i++){
		if (alltags[i].className==classname)
		ccollect[inc++]=alltags[i]
	}
}

function contractcontent(omit) {
	var inc=0
	if (typeof ccollect!="undefined"){
	while (ccollect[inc]){
		if (ccollect[inc].id!=omit)
		ccollect[inc].style.display="none"
		document.all[ccollect[inc].id+1].style.display = "block"
		document.all[ccollect[inc].id+2].style.display = "none"
		inc++
	} }
}

function expandcontent(cid){
		var inc=0;
        cid = cid.substr(0, 1).toUpperCase() + cid.substr(1);
        var cid1 = "";
		var temp= new Array();
	//This code is to make first char of String capital for the cid values  
		//alert("here2");
           temp=cid.split(" ");
          for(var i=0;i<temp.length;i++){
          temp[i].toString();
		  temp[i]=temp[i].substr(0, 1).toUpperCase() + temp[i].substr(1);
		  //alert(temp[i]);
		  cid1=cid1+temp[i]+" ";
		  //alert("cid1--"+cid1);
		}
		cid = cid1.replace(/^\s+|\s+$/g,"");
		//alert("CID is-- "+cid);
		
		if (typeof ccollect!="undefined"){
		if (collapseprevious=="no") {
			while (ccollect[inc]){
			
				if (ccollect[inc].id==cid && ccollect[inc].className=="switchcontent") {
				
					if (ccollect[inc].style.display=="block") {
						ccollect[inc].style.display="none"
						document.all[cid+1].style.display = "block"
						document.all[cid+2].style.display = "none"
					} else 
						{	
						ccollect[inc].style.display="block";
						document.all[cid+1].style.display = "none";
						document.all[cid+2].style.display = "block";
						}
				} else {
					
				} // end if-else
				inc++;
				//alert(inc)
			}// end while loop
		} //end if
	}// end if
} // end function

function changestyle(cid) {
	if (document.getElementByID){
		document.getElementById(cid+"A").className = "bgleftlinks1"
		document.getElementById(cid+"B").className = "txtactive"
		document.getElementById(cid+"C").className = "txtactive"
		document.getElementById(cid+"D").className = "txtactive"
	}
}
function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );
    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }
    return str;
}

function do_onload(){
	uniqueidn=window.location.pathname+"firsttimeload"
	getElementbyClass("switchcontent")
	var siteurl=document.URL;
	siteurl = replaceAll(siteurl, "+", " ");
	breakurl=siteurl.split("/");
	
	//if(typeof breakurl[7]!="undefined"){
	//	expandcontent(unescape(breakurl[7]))
	//}

//	if(typeof breakurl[8]!="undefined"){
		//alert ("inside 8")
//		changestyle(unescape(breakurl[8]))
//		expandcontent(unescape(breakurl[7]))
//	} else if(typeof breakurl[7]!="undefined") {
		//alert ("inside 7")
//		changestyle(unescape(breakurl[7]))
//		expandcontent(unescape(breakurl[7]))
//	}
//}

if(typeof breakurl[9]!="undefined"){
				changestyle(unescape(breakurl[9]))
		expandcontent(unescape(breakurl[9]))
	} else if(typeof breakurl[8]!="undefined") {
			changestyle(unescape(breakurl[8]))
		expandcontent(unescape(breakurl[8]))
	}
}

if (window.addEventListener)
	window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
	window.attachEvent("onload", do_onload)
else if (document.getElementById)
	window.onload=do_onload

// start world map scripting  ***** old *****
/*
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		map_01_NorthAmerica_over = newImage("/wps/wcm/autoliv/images/contact/map_01-North-America_over.gif");
		map_01_Samerica_over = newImage("/wps/wcm/autoliv/images/contact/map_01-Samerica_over.gif");
		map_02_Europe_over = newImage("/wps/wcm/autoliv/images/contact/map_02-Europe_over.gif");
		map_02_NorthAmerica_over = newImage("/wps/wcm/autoliv/images/contact/map_02-North-America_over.gif");
		map_02_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_02-asia_over.gif");
		map_03_Europe_over = newImage("/wps/wcm/autoliv/images/contact/map_03-Europe_over.gif");
		map_03_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_03-asia_over.gif");
		map_04_Samerica_over = newImage("/wps/wcm/autoliv/images/contact/map_04-Samerica_over.gif");
		map_05_Europe_over = newImage("/wps/wcm/autoliv/images/contact/map_05-Europe_over.gif");
		map_05_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_05-asia_over.gif");
		map_05_Africa_over = newImage("/wps/wcm/autoliv/images/contact/map_05-Africa_over.gif");
		map_06_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_06-asia_over.gif");
		map_07_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_07-asia_over.gif");
		map_07_Australia_over = newImage("/wps/wcm/autoliv/images/contact/map_07-Australia_over.gif");
		map_07_Australasia_over = newImage("/wps/wcm/autoliv/images/contact/map_07-Australasia_over.gif");
		map_08_NorthAmerica_over = newImage("/wps/wcm/autoliv/images/contact/map_08-North-America_over.gif");
		map_08_Samerica_over = newImage("/wps/wcm/autoliv/images/contact/map_08-Samerica_over.gif");
		preloadFlag = true;
	}
}
*/


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		map_01_NorthAmerica_over = newImage("/wps/wcm/autoliv/images/contact/map_01-North-America_over.gif");
		map_01_Samerica_over = newImage("/wps/wcm/autoliv/images/contact/map_01-Samerica_over.gif");
		map_02_Europe_over = newImage("/wps/wcm/autoliv/images/contact/map_02-Europe_over.gif");
		map_02_NorthAmerica_over = newImage("/wps/wcm/autoliv/images/contact/map_02-North-America_over.gif");
		map_02_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_02-asia_over.gif");
		map_03_Europe_over = newImage("/wps/wcm/autoliv/images/contact/map_03-Europe_over.gif");
		map_03_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_03-asia_over.gif");
		map_04_Samerica_over = newImage("/wps/wcm/autoliv/images/contact/map_04-Samerica_over.gif");
		map_05_Europe_over = newImage("/wps/wcm/autoliv/images/contact/map_05-Europe_over.gif");
		map_05_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_05-asia_over.gif");
		map_05_Africa_over = newImage("/wps/wcm/autoliv/images/contact/map_05-Africa_over.gif");
		map_06_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_06-asia_over.gif");
		map_07_asia_over = newImage("/wps/wcm/autoliv/images/contact/map_07-asia_over.gif");
		map_07_Australia_over = newImage("/wps/wcm/autoliv/images/contact/map_07-Australia_over.gif");
		map_07_Australasia_over = newImage("/wps/wcm/autoliv/images/contact/map_07-Australasia_over.gif");
		map_08_NorthAmerica_over = newImage("/wps/wcm/autoliv/images/contact/map_08-North-America_over.gif");
		map_08_Samerica_over = newImage("/wps/wcm/autoliv/images/contact/map_08-Samerica_over.gif");
		preloadFlag = true;
	}
}

