// JavaScript Document
// Filename: menu.js
// Author: Matt Frazee
// Title: Classic Auto Radio Service menu and other functions
// Version: 1.0

function fixedSize(url,name,features) {
	win = window.open(url,name,features);
}

//search validation function
function search(){
  if(this.document.getElementById("searchbox").value != ""){
    location.href = "http://www.classicautoradioservice.com/search.asp?zoom_query="+this.document.getElementById("searchbox").value+"&zoom_per_page=10&zoom_and=0&zoom_sort=0";
  } else {
    alert("Please enter a keyword to search.");
  }
}

//pop up code
// Set the horizontal and vertical position for the popup
PositionX = 50;
PositionY = 50;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 50;
defaultHeight = 50;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = false;
// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','test',optNN);}
if (isIE){imgWin=window.open('about:blank','test',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE;');
writeln('var AutoClose='+AutoClose+';');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');
writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height)+32;');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["my_image"].width;');
writeln('window.innerHeight=document.images["my_image"].height+32;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('function doPrint(){bypass=true;this.window.print();}');
writeln('var bypass=false;');
writeln('function bypassClose(){if(AutoClose){if(bypass){bypass=false;}else{self.close();}}}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('<link href="css/cars_styles.css" rel="stylesheet" type="text/css" /></head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" style="background-color:#ffffff">')
else writeln('<link href="css/cars_styles.css" rel="stylesheet" type="text/css" /></head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="bypassClose();" style="background-color:#ffffff">');
writeln('<a href="javascript:self.close();"><img name="my_image" src='+imageURL+' style="display:block" border="0" alt="Close Window"></a><div align="center" style="padding-top:5px"><a href="#" onMouseDown="doPrint();"><img src="images/button_print.gif" border="0" alt="Print Image"></a>&nbsp;<a href="javascript:self.close();"><img src="images/button_close.gif" border="0" alt="Close Window"</a></div></body></html>');
close();		
}}

function createMenu() {
	document.write('<ul id="MenuBar1" class="MenuBarHorizontal"><li><a href="index.html">Home</a></li><li><a href="services.html" class="MenuBarItemSubmenu">Our Services</a><ul><li><a href="chassis_restoration.html">Chassis Restoration</a></li><li><a href="stereo_conversions.html">FM Stereo Conversions</a></li><li><a href="radio_repair.html">Radio Repair</a></li><li><a href="speaker_reconing.html">Speaker Reconing</a></li></ul></li><li><a class="MenuBarItemSubmenu" href="catalog.html">Our Catalog</a><ul><li><a href="catalog_inverters.html">Inverters</a></li><li><a href="catalog_radios.html">Radios</a></li><li><a href="catalog_speakers.html">Speakers</a></li><li><a href="catalog_vibrators.html">Vibrators</a></li><li><a href="catalog_voltage.html">Voltage Boosters</a></li><li><a href="catalog_other.html">Other</a></li></ul></li><li><a href="customer_service.html" class="MenuBarItemSubmenu">Customer Service</a><ul><li><a href="faqs.html">Frequently Asked Questions</a></li><li><a href="shipping.html">Shipping Information</a></li><li><a href="support.html">Troubleshooting &amp; Support</a></li><li><a href="downloads.html">Downloads</a></li></ul></li><li><a href="search.asp">Search</a></li><li><a href="contact_us.html">Contact Us</a></li></ul>');
	var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
}

function submitForm(name){
	//validate required items
	var theform = document.getElementById(name);
	if(!Spry.Widget.Form.validate(theform)){
		alert('Please fix all of the red highlighted fields and re-submit.');
	} else {
		theform.submit();
	}
}