var CurrentMenu = null, MenuTimer = null, iCounter=0;

var isIE50 = (document.all && navigator.appVersion.indexOf("MSIE 5.0") != -1) ? 1 : 0;
var isIE55 = (document.all && navigator.appVersion.indexOf("MSIE 5.5") != -1) ? 1 : 0;
var isIE6 = (document.all && navigator.appVersion.indexOf("MSIE 6") != -1) ? 1 : 0;
var isIE7 = (document.all && navigator.appVersion.indexOf("MSIE 7") != -1) ? 1 : 0;
var isMac = navigator.userAgent.toLowerCase().indexOf("safari") + 1;
var isIE  = document.all ? true : false;
var isMoz = !(isIE || isMac);
var viewHeight;
var i=1;

function IsFlashAvailable()
{
	try { if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash") != null) return true; } catch(e){}
	try { if (navigator.plugins && navigator.plugins["Shockwave Flash"]) return true; } catch(e){}
	return false;
}


function openChildren(parentURI){
	var par = document.getElementById(parentURI);
	par.className = par.className == "open" ? "" : "open";
	
	resizeMenuBottom();
}

function FixHeaderSize(){
	var nodes = document.getElementById('car_type').getElementsByTagName('blockquote');
	var mh = 0;
	for( var i = 0; i <nodes.length;i++){
		if(nodes[i].offsetHeight>mh)mh = nodes[i].offsetHeight ;
	}
	
	for( var i = 0; i <nodes.length;i++){
		nodes[i].style.height = (mh-12)+"px";
	}
	
}

function FixAlignment(parent,tagName,className){
	var par = document.getElementById(parent);
	var nodes = par.getElementsByTagName(tagName);
	var max = 0;
	for(var i=0;i<nodes.length;i++){
		if(nodes[i].className==className && 
		 nodes[i].offsetHeight>max)max = nodes[i].offsetHeight;
	}
	
	for(var i=0;i<nodes.length;i++){
		if(nodes[i].className==className)
		{
			nodes[i].style.height = max+"px";		
		}
	}
}

function InitIE(node){
	node.id = "node" + ++iCounter;
	document.body.insertAdjacentHTML("beforeend", "<iframe id='" + node.id + "iframe' name='" + node.id + "iframe' src='' scrolling='no' frameborder='0' ></iframe>");
	var iframe = document.getElementById(node.id + "iframe");
	
	
	var dropdown = node.getElementsByTagName('ul')[0];
	
	iframe.style.left = node.offsetLeft + "px";
	dropdown.style.display = "block";
	iframe.style.height = dropdown.offsetHeight + "px";
	dropdown.style.display = "none";
	var p = dropdown.parentNode;
	dropdown.parentNode.replaceChild(iframe,dropdown);
	iframe.className = "over";
	iframe.className = "";

	var iframe_document = window.frames[node.id + "iframe"].document;
	
                iframe_document.open();
	iframe_document.write(
		"<html><head>"+
		"<base target='_top'/>"+
		"<link type='text/css' href='/fulda_si_si/include/css/home.css' rel='stylesheet' />" +
		"<link type='text/css' href='/fulda_si_si/include/css/content.css' rel='stylesheet' />" +
		"<link type='text/css' href='/fulda_si_si/include/css/sitewide.css' rel='stylesheet' />" +
		"</head><body bgcolor='black'>"+
		"<ul class='iframe_nav'>" + dropdown.innerHTML + "</ul>" + 
		"</body>"
	);
                iframe_document.close();
	
	iframe_document.onmouseover = function(){
		clearTimeout(MenuTimer);
	}
	iframe_document.onmouseout = function(){
		MenuTimer = setTimeout("hideMenu()", 500);
	}
}

startList = function() {
	if(document.all && document.getElementById) {
		navRoot = document.getElementById("topmenu").getElementsByTagName("ul")[0];
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI" && node.getElementsByTagName('ul').length) {
				//if(isIE) InitIE(node);
				node.onmouseover = function() {
					if(CurrentMenu!=this)hideMenu();
					CurrentMenu = this;
					clearTimeout(MenuTimer);
					this.className = "over";
				}
				
				node.onmouseout=function() {
					CurrentMenu = this;
					MenuTimer = setTimeout("hideMenu()", 500);
				}
			}
		}
	}
}

function resizeMenuBottom()
{
	var nEl = document.getElementById("nav_bottom");	
	nEl.style.height = Math.max(0, viewHeight - (document.all ? nEl.parentNode.offsetTop : 0) - nEl.offsetTop - 35) + "px";
	
}

function initNavMenu(){
	var nav = document.getElementById("nav");
	var nodes = nav.getElementsByTagName("li");
	for(var i=0;i<nodes.length;i++){
		if(!nodes[i].getElementsByTagName("ul").length){
			nodes[i].onclick = function(e){
				if (!e)e=event; e.cancelBubble = true;
				this.className = this.className == "select" ? "" : "select";
				resizeMenuBottom();
			}
		}
		else{
			nodes[i].onclick = function(e){
				if (!e)e=event; e.cancelBubble = true;
				this.className = this.className == "open" ? "" : "open";
				resizeMenuBottom();
			}
		}
	}
}

function hideMenu(){
	if(CurrentMenu)CurrentMenu.className = CurrentMenu.className.replace("over", "");
	CurrentMenu=null;
}

function getClientHeight(){

   if(isIE){ 
      return parseInt(document.all?document.documentElement.clientHeight:window.innerHeight);
   } else {
      return parseInt(window.innerHeight);
   }	
//alert(myHeight);
   return parseInt(myHeight);

   //return parseInt(document.all?document.documentElement.clientHeight:window.innerHeight);
}

function setResize(){
	window.onresize = function()
	{
                                i=i+1;		
                                var blnRightColumn = (document.getElementById("content_center")) != null;
		
		if (blnRightColumn)
		{
			var cEl = document.getElementById("content_center");
			var nEl = document.getElementById("nav_bottom");
			var sEl = document.getElementById("sel_spacerpic2");
			var sView = document.getElementById("scrollview");
var nnEl = document.getElementById("nav");


			var CH = 750;
			if(isIE50 || isIE55 || isIE6 || isIE7){ 
                                                   CH = document.body.offsetHeight-8;
			}else{
                                                   CH = getClientHeight()-58;
                                                }
var heightmax=Math.max(Math.max(cEl.offsetHeight,nnEl.offsetHeight),cEl.offsetHeight);
var ElSz = heightmax+cEl.offsetTop+35;
//var ElSz = cEl.offsetHeight+cEl.offsetTop+35;


			
                                                if(ElSz<650)ElSz=650;
			if(CH<ElSz)CH=ElSz;

			if(isMoz && sView)
			{
				CH = sView.offsetHeight + sView.offsetTop+cEl.offsetTop-80;	 
			}
			viewHeight = CH;

if(i<3){
 if (sEl != null){
    sEl.parentNode.style.position = "relative";
    sEl.style.height = Math.max(0, CH - ((sEl != null) ? sEl.parentNode.offsetTop : 0) - sEl.offsetTop - 35) + "px";
 }   
 if (cEl != null){
     cEl.style.height = Math.max(0, CH - cEl.offsetTop - 35) + "px";
 }	
 if (nEl != null){
    nEl.style.height = Math.max(0, CH - ((nEl != null) ? nEl.parentNode.offsetTop : 0) - nEl.offsetTop - 35) + "px";
 }		
}	

//if ((sEl != null) && (cEl != null) && (nEl != null)){
//   sEl.parentNode.style.position = "relative";
//   cEl.style.height = Math.max(0, CH - cEl.offsetTop - 35) + "px";
//   nEl.style.height = Math.max(0, CH - ((nEl != null) ? nEl.parentNode.offsetTop : 0) - nEl.offsetTop - 35) + "px";
//   sEl.style.height = Math.max(0, CH - ((sEl != null) ? sEl.parentNode.offsetTop : 0) - sEl.offsetTop - 35) + "px";
//}			
                                                //if(document.all) sEl.parentNode.style.position = "absolute";
			//cEl.style.height = Math.max(0, CH - cEl.offsetTop - 35) + "px";
			//nEl.style.height = Math.max(0, CH - (document.all ? nEl.parentNode.offsetTop : 0) - nEl.offsetTop - 35) + "px";
			//sEl.style.height = Math.max(0, CH - (document.all ? sEl.parentNode.offsetTop : 0) - sEl.offsetTop - 35) + "px";
		}
		else
		{
			var cEl = document.getElementById("content_center_wide");
			var nEl = document.getElementById("nav_bottom");
var nnEl = document.getElementById("nav");
			var CH = 750;

			if(isIE50 || isIE55 || isIE6 || isIE7) {
                                                    CH = document.body.offsetHeight-8;
			}else{
                                                    CH = getClientHeight()-58;
                                                }
var heightmax=Math.max(Math.max(cEl.offsetHeight,nnEl.offsetHeight),cEl.offsetHeight);
var ElSz = heightmax+cEl.offsetTop+35;
//var ElSz = cEl.offsetHeight+cEl.offsetTop+35;




			if(ElSz<650)ElSz=650;
			if(CH<ElSz)CH=ElSz;

			if(isMoz && sView)
			{
				CH = sView.offsetHeight + sView.offsetTop+cEl.offsetTop-80;	 
			}
			viewHeight = CH;

			//if(document.all) sEl.parentNode.style.position = "absolute";
			cEl.style.height = Math.max(0, CH - cEl.offsetTop - 35) + "px";
			nEl.style.height = Math.max(0, CH - ((nEl != null) ? nEl.parentNode.offsetTop : 0) - nEl.offsetTop - 35) + "px";
			//sEl.style.height = Math.max(0, CH - (document.all ? sEl.parentNode.offsetTop : 0) - sEl.offsetTop - 35) + "px";
		}
	}
	window.onresize(); 
}

function mainSetTabFonts()
{		
		
	// fontsize code
	var ids=Array("tireselector","tireintro","dealerselector_home"	);
	var small = false; var h2s=Array();
	for(i in ids){
		ido = document.getElementById(ids[i]);
		if(ido)
		{
			h2s[i]=ido.getElementsByTagName("h2")[0];
			if(h2s[i])
			{
				h2s[i].style.textIndent = "0px";
				if (h2s[i].scrollHeight > 26)small = true;	
			}
		}		
	}
	for(i in h2s)if(h2s[i]){
		if(small)h2s[i].className = "tab_smallfont";
		else h2s[i].className = "tab_bigfont";
	}
}

	function checkhs(strErrorMsg) 
	{ 
		var tmpplz = document.forms.dealerselectionform.zip.value; 
		var tmport = document.forms.dealerselectionform.city.value;
		
		if (tmpplz == '' && tmport == '')
		{ 
			alert(strErrorMsg);
		} 
		else 
		{ 
			document.dealerselectionform.submit();
		}
	} 

	function openImagePopup(strImageURL)
	{
		var popupWindow = window.open("", "imagepopup","height=492,width=626");
		popupWindow.document.write("<center><a href='javascript:self.close()' target='_self'><img src='" + strImageURL + "' border='0'></a><center>");
	}

