function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function switch_topics(topic_code)
{
//var arrTopics = new Array('METADATA', 'PASSENGER_OVERVIEW', 'PASSENGER_EQUIPMENT', 'PASSENGER_SPECS', 'PASSENGER_PRICE')
//var arrTopics = new Array('METADATA', 'COMPANY')
	//alert(topic_code)
	for (i=0;i<arrTopics.length;i++)
	{
		document.images['img_' + arrTopics[i]].src = '/images/admin/arrow_right.gif'
		document.all[arrTopics[i]].style.display = 'none'
		document.all['tab_' + arrTopics[i]].className = 'tabLow'
	}	
	
	document.all[topic_code].style.display = ''
	document.all['tab_' + topic_code].className = 'tabHigh'
	document.images['img_' + topic_code].src = '/images/admin/arrow_right_on.gif'
	//document.images['rightTab_' + topic_code].src = '/images/optionTabrightHigh.gif'
	document.all['current_topic'].value = topic_code
	//document.all['topic_' + topic_code].focus()
	
		
}

function GalleryPopup(imgSource)
{
	//alert('hello');
	window.open("/includes/gallerypopup.asp?image="+imgSource,"GalleryPopup","height=300,width=400");
}


function checkRegisterFields() 
{
	missinginfo = "";
	if (document.form.name.value == "") 
	{
		missinginfo += "\n     - Name";
	}

	if(document.form.address1.value == "") 
	{
		missinginfo += "\n     - Address";
	}

	if (document.form.county.selectedIndex <= 0) 
	{
	missinginfo += "\n     - County";
	}
	
	if (missinginfo != "") 
	{
		missinginfo ="\n" +
		"Please fill out the following:\n" +
		missinginfo + "\n" +
		"\n";
		alert(missinginfo);
		return false;
	}
	else 
		return true;
}

function checkBrochureFields() 
{
	missinginfo = "";
	if (document.form.name.value == "") 
	{
		missinginfo += "\n     - Name";
	}

	if(document.form.address1.value == "") 
	{
		missinginfo += "\n     - Address";
	}

	if (document.form.brochure.selectedIndex <= 0) 
	{
		missinginfo += "\n     - Brochure";
	}
	
	if (missinginfo != "") 
	{
		missinginfo ="\n" + "Please fill out the following:\n" + missinginfo + "\n" + "\n";
		alert(missinginfo);
		return false;
	}
	else
	{ 
		return true;
	}
}

function checkServiceFields() 
{
	missinginfo = "";
	if (document.form.name.value == "") 
	{
		missinginfo += "\n     - Name";
	}

	if(document.form.address1.value == "") 
	{
		missinginfo += "\n     -  Address";
	}
	
	if(document.form.telephone.value == "") 
	{
		missinginfo += "\n     -  Telephone Number";
	}
	
	if (document.form.model.selectedIndex <= 0) 
	{
		missinginfo += "\n     -  Model";
	}
	
	if (missinginfo != "") 
	{
		missinginfo ="\n" +
		"Please fill out the following:\n" + missinginfo + "\n" + "\n";
		alert(missinginfo);
		return false;
	}
	else 
	{
		return true;
	}
}

function checkContactUsFields() 
{
	missinginfo = "";
	if (document.form.name.value == "") 
	{
		missinginfo += "\n     - Name";
	}

	if ((document.form.email.value == "") || (document.form.email.value.indexOf('@') == -1) || (document.form.email.value.indexOf('.') == -1)) 
	{
		missinginfo += "\n     -  Email address";
	}

	if(document.form.address.value == "") 
	{
		missinginfo += "\n     - Address";
	}

	if(document.form.query.value == "") 
	{
		missinginfo += "\n     - Query";
	}

	if (missinginfo != "") 
	{
		missinginfo ="\n" +	"Please fill out the following:\n" + missinginfo + "\n" + "\n";
		alert(missinginfo);
		return false;
	}
	else 
		return true;
}

function nav_rollOn(item)
{
	if (menuTimeout) clearTimeout(menuTimeout);
	document.images['img_' + item.id].src='/images/navigation/dropDownNav/nav_arrowRoll.gif';
	item.style.color = '#C71444';
}
function nav_rollOff(item)
{
	menuOff(currentMenu);
	document.images['img_' + item.id].src='/images/navigation/dropDownNav/nav_arrow.gif';
	item.style.color = '#666666';
	
}

function SubmitForm(strFormName, strAction)
{
	document.all['action'].value = strAction
	document.forms[strFormName].submit();
}

function SideNav(divName, strClass, url)
{
var prev_nav;

	prev_nav = document.all['current_nav'].value;
	//alert(prev_nav);
	if (prev_nav != divName)
	{	
		E = eval(document.all['div_' + divName])
		while (E.tagName!="TD")
			{E=E.parentElement;}
		E.className = strClass;
		if(prev_nav != '')
		{
			E = eval(document.all['div_' + prev_nav])
			while (E.tagName!="TD")
				{E=E.parentElement;}
			E.className = 'tabLow';
		}
		document.all['current_nav'].value = divName
		document.all['main_body'].src = url;
	}
}

function previewContent(strURL)
{
	window.open(strURL)
	//window.showModalDialog('/admin/preview.asp?url=' + strURL,"","dialogHeight: 680px; dialogWidth: 800px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No;");
}

function setPreviewImage()
{
	//alert(document.all['ContentImage'].value);
	document.images['preview_image'].src = '/images/sideImages/' + document.all['ContentImage'].value
}

function navigate(strPath, image)
{
	
	document.all['main_body'].src = strPath;
}

function mOvr(id, css_class, strImage){

	if(id != document.all['current_topic'].value)
	{
		//alert(id + " " + document.all['current_topic'].value)
		document.all['tab_'+id].className = css_class;
		if(strImage != '')
		{
			document.images['img_'+id].src = strImage;
		}
	}

}

function scrollPage(intPageNumber)
{
	document.forms['page_results'].action = document.forms['page_results'].action + "&page=" + intPageNumber;
	document.forms['page_results'].submit();
}


function phaseMenus()
{
	
	var arrMenus = new Array("ourCompanyDiv","productDiv", "clientsDiv", "infoDiv");
	var offsetWidth;
	var site_width = 795
	var ourCompanyDivLeft = 278
	var productDivLeft = 318
	var clientsDivLeft = 396
	var infoDivLeft = 511
	var menu_name;
	
	if (parseInt(navigator.appVersion) > 3) 
	{
		if (navigator.appName=="Netscape") 
		{
			offsetWidth = window.innerWidth;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			offsetWidth = document.body.offsetWidth;
		}
	}
	offsetWidth = (offsetWidth / 2) - (site_width / 2)
	for(i=0;i<arrMenus.length;i++)
	{
		menu_name = arrMenus[i]
		document.getElementById(menu_name).style.pixelLeft = offsetWidth + eval(menu_name + 'Left')
	}
}
