function showProducts(which)
{
	document.getElementById(which).style.display == "block" ? document.getElementById(which).style.display = "none" : document.getElementById(which).style.display = "block";
}

var xmlHttp;
var changeTop;
// Show Model Info------------------------------
function showAjaxStart(infoBox,page,modelID,which,attID,whichTop,jrID)
{
		//alert(infoBox)
		if(whichTop == "" || whichTop == undefined)
		{
			changeTop = "keyFeatures";	
		}
		else
		{
			changeTop = whichTop;
		}
		startModID = modelID;
		startAttID = attID;
		startJRID = jrID;
		if(modelID == "90") //Single Axle Trailer
		{
			modelID = "1"
		}
		else if(modelID == "91") //Double Axle Trailer
		{
			modelID = "10"
		}
		if(infoBox == "topInfo")
		{
			document.getElementById("topBoxTab").value = which;
			resetTabs("topBoxTab");
		}
		else if(infoBox == "bottomInfo")
		{
			document.getElementById("bottomBoxTab").value = which;
			resetTabs("bottomBoxTab");
		}
		
		infoBox2 = infoBox;
		if (infoBox.length >= 0)
		{            
			var url
			if(attID != "")
			{
				url=page + "?modid=" + modelID + "&attid=" + attID;
			}
			else
			{
				url=page + "?modid=" + modelID;
			}
			xmlHttp=GetXmlHttpObject(stateChangedStart);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 	
} 
function stateChangedStart(modID)
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
   	document.getElementById(infoBox2).innerHTML=xmlHttp.responseText;
   	showAjax("topInfo","ajax_" + changeTop + ".asp",startModID,changeTop)
		if(startAttID != "")
		{
			if (window.location.href == "http://www.ditchwitch.com/trailers/tandem-axle-trailer" || window.location.href == "http://www.ditchwitch.com/trailers/single-axle-trailer")
			{
				
			}
			else
			{
				var isBottom;
				var getBottom = window.location.href;
				isBottom = getBottom.split("#");
				if(isBottom[1] == "aBottom")
				{
					window.location.href = window.location.href;
				}
				else
				{
					window.location.href = window.location.href + "#aBottom";
				}
			}
			//alert(window.location.href);
		}
		if(startJRID != "")
		{
			//alert(startJRID);
			setTimeout('showJobRelated(startJRID,startModID)',500);
		}
   	}
}
function showAjax(infoBox,page,modelID,which)
{
	//alert("info " + infoBox + " page: " + page + " modelID: " + modelID + " which: " + which);
		if(infoBox == "topInfo")
		{
			document.getElementById("topBoxTab").value = which;
			resetTabs("topBoxTab");
		}
		else if(infoBox == "bottomInfo")
		{
			document.getElementById("bottomBoxTab").value = which;
			resetTabs("bottomBoxTab");
		}
		
		infoBox2 = infoBox;
		if (infoBox.length >= 0)
		{            
			var url=page + "?modid=" + modelID;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
}

function showAtt(attID,modelID,which)
{
		document.getElementById("bottomBoxTab").value = which;
		resetTabs("bottomBoxTab");
		
		infoBox2 = "bottomInfo";
		if (infoBox.length >= 0)
		{            
			var url="ajax_attachments.asp?attid=" + attID + "&modid=" + modelID;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 

function showToolSelector(which,sorter,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,c1,c2,c3,c4,c5,c6,c7,c8,colStatus,rowStatus)
{		
		infoBox = "bottomInfo";
		infoBox2 = infoBox;
		if (infoBox.length >= 0)
		{            
			var url="ajax_toolSelector.asp?which=" + which + "&sort=" + sorter + "&r1=" + r1 + "&r2=" + r2 + "&r3=" + r3 + "&r4=" + r4 + "&r5=" + r5 + "&r6=" + r6 + "&r7=" + r7 + "&r8=" + r8 + "&r9=" + r9 + "&r10=" + r10 + "&r11=" + r11 + "&r12=" + r12 + "&r13=" + r13 + "&r14=" + r14 + "&r15=" + r15 + "&r16=" + r16 + "&r17=" + r17 + "&r18=" + r18 + "&c1=" + c1 + "&c2=" + c2 + "&c3=" + c3 + "&c4=" + c4 + "&c5=" + c5 + "&c6=" + c6 + "&c7=" + c7 + "&c8=" + c8 + "&colStatus=" + colStatus + "&rowStatus=" + rowStatus;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 

function resetTHeight()
{
	document.getElementById("topInfoLeft").style.height = 0;
	document.getElementById("topInfoRight").style.height = 0;
}

function resetBHeight()
{
	document.getElementById("bottomInfoLeft").style.height = 0;
	document.getElementById("bottomInfoRight").style.height = 0;
}

function adjTHeight()
{
	tiHeight = document.getElementById('topInfo').offsetHeight;
	document.getElementById("topInfoLeft").style.height = tiHeight;
	document.getElementById("topInfoRight").style.height = tiHeight;
}


function adjBHeight()
{
	biHeight = document.getElementById('bottomInfo').offsetHeight;
	document.getElementById("bottomInfoLeft").style.height = biHeight;
	document.getElementById("bottomInfoRight").style.height = biHeight;
}

function showAttDet(infoBox,page,attID,modID)
{
			
		infoBox2 = infoBox;
		if (infoBox.length >= 0)
		{            
			var url=page + "?attid=" + attID + "&modid=" + modID;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 

function showVidMod(page,modelID,videoID,which)
{
		infoBox = "topInfo"
		document.getElementById("topBoxTab").value = which;
		resetTabs("topBoxTab");
		
		infoBox2 = infoBox;
		
		if (infoBox.length >= 0)
		{            
			var url2=page + "?modid=" + modelID + "&whichVid=" + videoID;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url2 , true);
	  		xmlHttp.send(null);
			
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 

function showVidAtt(page,attID,modID,which)
{
		infoBox = "bottomInfo"
		////infoBox = "attTemp"
		if(document.getElementById("bottomBoxTab"))
		{
			document.getElementById("bottomBoxTab").value = which;
			resetTabs("bottomBoxTab");
		}
		infoBox2 = infoBox;
		
		if (infoBox.length >= 0)
		{            
			var url2=page + "?attid=" + attID + "&whichVid=true&modid=" + modID;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url2 , true);
	  		xmlHttp.send(null);
			
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 

function showVidAtt_popup(duration,vidPath,attID,modID)
{
		document.getElementById("prevideo").value = document.getElementById("imageVid").innerHTML
		vidData = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="263" height="211" id="player" align="middle">'
		vidData += '<param name="allowScriptAccess" value="sameDomain" />'
		vidData += '<param name="allowFullScreen" value="false" />'
		vidData += '<param name="movie" value="videos/player.swf" /><param name="quality" value="high" /><param name="flashvars" value="getVideoPath=' + vidPath + '&getDuration=' + duration + '&getTab=attachments&getAttID=' + attID + '&getModID=' + modID + '&type=popup" /><param name="bgcolor" value="#ffffff" />	<embed src="videos/player.swf" flashvars="getVideoPath=' + vidPath + '&getDuration=' + duration + '&getTab=attachments&getAttID=' + attID + '&getModID=' + modID + '&type=popup" quality="high" bgcolor="#ffffff" width="263" height="211" name="player" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
		vidData += '</object>'
		
		document.getElementById("imageVid").innerHTML = vidData;
} 

function hideVidAtt_popup()
{
	document.getElementById("imageVid").innerHTML = document.getElementById("prevideo").value;
}

function playVid(whichVid,ranged)
{
			
		infoBox = "vidContent"
		infoBox2 = infoBox;
		if (infoBox.length >= 0)
		{            
			var url="ajax_video.asp?vidID=" + whichVid + "&getRange=" + ranged;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
}

function showVidList(whichCat,whichID,ranged)
{
	if(whichID != "")
	{
		if(document.getElementById("curVidLink").value != "")
		{
			document.getElementById(document.getElementById("curVidLink").value).className = "orangeLinkVideos";
		}
		document.getElementById(whichID).className = "orangeLink";
		document.getElementById("curVidLink").value = whichID;
	}
	infoBox = "vidContent"
	infoBox2 = infoBox;
	if (infoBox.length >= 0)
	{           
		var url="ajax_video.asp?vidCat=" + escape(whichCat) + "&getRange=" + ranged + "&whichID=" + whichID;
		xmlHttp=GetXmlHttpObject(stateChanged);
	  	xmlHttp.open("GET", url , true);
	 		xmlHttp.send(null);
	  	} 
   	else
	{ 
   		document.getElementById(infoBox).innerHTML="";
	} 
}

//------------------------------
// Show PR List------------------------------
function changeCat(which)
{
	document.getElementById("filtering").value = which;
	document.getElementById("azza").value = "DESC"
	showPRList('PostDate')
}
function showPRList(sortby)
{
		azORza = document.getElementById("azza").value;
		
		if(document.getElementById("azza").value == "")
		{
			document.getElementById("azza").value = "DESC";
		}
		else
		{
			document.getElementById("azza").value = "";
		}
		
		infoBox = infoBox2 = "bodyCopy";
		filters = document.getElementById("filtering").value;
		if (infoBox.length >= 0)
		{            
			lnc = document.getElementById("getlnc").value;
			lnp =document.getElementById("getlnp").value;
			var url="ajax_pressReleasesList.asp?sortby=" + sortby + "&azza=" + azORza + "&filter=" + filters + "&lnc=" + lnc + "&lnp=" + lnp;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 
//------------------------------
function showJobRelated(which,modid)
{
			
		infoBox = infoBox2 = "bottomInfo";
		if (infoBox.length >= 0)
		{            
			var url="ajax_jobRelated.asp?jrid=" + which + "&modid=" + modid;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 

// Show Event List------------------------------
function showEventList()
{		
		infoBox = infoBox2 = "eventList";
		if (infoBox.length >= 0)
		{            
			lnc = document.getElementById("getlnc").value;
			lnp =document.getElementById("getlnp").value;
			var url="ajax_eventsList.asp" + "?lnc=" + lnc + "&lnp=" + lnp;;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 
//------------------------------
// Show Image List------------------------------
function showImageList()
{		
		infoBox = infoBox2 = "imageList";
		if (infoBox.length >= 0)
		{            
			var url="ajax_imageGallery.asp";
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 
// Show Image Gal------------------------------
function showImageGal(which)
{		
		infoBox = infoBox2 = "imageList";
		if (infoBox.length >= 0)
		{            
			var url="ajax_imageGallery.asp?whichMod=" + which;
			xmlHttp=GetXmlHttpObject(stateChanged);
		  	xmlHttp.open("GET", url , true);
	  		xmlHttp.send(null);
	   	} 
   		else
		{ 
   			document.getElementById(infoBox).innerHTML="";
		} 
} 
//------------------------------
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById(infoBox2).innerHTML=xmlHttp.responseText;
   //window.open(str)
   }
} 

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
   {
    alert("This example doesn't work in Opera");
    return;  
   }
if (navigator.userAgent.indexOf("MSIE")>=0)
   { 
   var strName="Msxml2.XMLHTTP";
   if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
      {
      strName="Microsoft.XMLHTTP";
      } 
   try
      { 
      objXmlHttp=new ActiveXObject(strName);
      objXmlHttp.onreadystatechange=handler; 
      return objXmlHttp;
      } 
   catch(e)
      { 
      alert("Error. Scripting for ActiveX might be disabled"); 
      return 
      } 
    } 
if (navigator.userAgent.indexOf("Mozilla")>=0)
   {
   objXmlHttp=new XMLHttpRequest();
   objXmlHttp.onload=handler;
   objXmlHttp.onerror=handler; 
   return objXmlHttp;
   }
} 