///////////////////////////////////////////
//NAVIGATION: rollsovers
///////////////////////////////////////////
/*
Author: Michele
Date: 03/21/2007
Description: navigation rollovers
*/
if (document.images) {
	var emboff = new Image();
	emboff.src = "images/homeoff.gif";
	var emb1off = new Image();
	emb1off.src = "images/aboutoff.gif";
	var emb2off = new Image();
	emb2off.src = "images/consolesoff.gif";
	var emb3off = new Image();
	emb3off.src = "images/servicesoff.gif";	
	var emb4off = new Image();
	emb4off.src = "images/resourcecenteroff.gif";	
	var emb5off = new Image();
	emb5off.src = "images/clientsoff.gif";
	var emb6off = new Image();
	emb6off.src = "images/contactoff.gif";

	var embon = new Image();
	embon.src = "images/homeon.gif";
	var emb1on = new Image();
	emb1on.src = "images/abouton.gif";
	var emb2on = new Image();
	emb2on.src = "images/consoleson.gif";
	var emb3on = new Image();
	emb3on.src = "images/serviceson.gif";	
	var emb4on = new Image();
	emb4on.src = "images/resourcecenteron.gif";	
	var emb5on = new Image();
	emb5on.src = "images/clientson.gif";
	var emb6on = new Image();
	emb6on.src = "images/contacton.gif";

	

function img_act(imgName) {
	if (document.images) {
		document.images[imgName].src = eval(imgName + "on.src");
	}
}

function img_inact(imgName) {
	if (document.images) {
		document.images[imgName].src = eval(imgName + "off.src");
	}
}

}

/*
Author: Michele
Date: 04/21/2007
Description: validates forms
*/
function ValidateForm () {

	number = new RegExp ("[^0-9]","i");
	
	f = document.theForm;
	
	error = false;
	error_message = "The following error(s) must be corrected before the form can be submitted:\n\n";
		
	if (f.email.value == '') {
	
		error_message = error_message + "* Please enter your email to continue.\n";
		error = true;
	}
	
	validAreaCode = f.areacode.value.search(eval(number));
	if (f.areacode.value && validAreaCode != -1) {
		error_message = error_message + "* Phone Area Code is not a valid number.\n";
		error = true;	
	}

	validPhone1 = f.phone1.value.search(eval(number));
	if (f.phone1.value && validPhone1 != -1) {
		error_message = error_message + "* Phone number prefix is not a valid number.\n";
		error = true;	
	}	
	
	validPhone2 = f.phone2.value.search(eval(number));
	if (f.phone2.value && validPhone2 != -1) {
		error_message = error_message + "* Phone number suffix is not a valid number.\n";
		error = true;	
	}
	
	validPhone3 = f.phone3.value.search(eval(number));
	if (f.phone3.value && validPhone3 != -1) {
		error_message = error_message + "* Phone number extension is not a valid number.\n";
		error = true;	
	}
	
	// ALERT AND RETURN FALSE IF ERROR

	if (error == true) {
		alert (error_message);
		return false;
	} 
		
	return true;
	
}

/*
Author: Michele
Date: 04/21/2007
Description: validates forms
*/
function ValidateFormConsole () {

	f = document.theForm;
	
	error = false;
	error_message = "The following error(s) must be corrected before the form can be submitted:\n\n";
		
	if (f.manufacturer.value == '') {
	
		error_message = error_message + "* Please select a manufacturer to continue.\n";
		error = true;
	}

	if (f.console.value == '') {
	
		error_message = error_message + "* Please select a console to continue.\n";
		error = true;
	}	
	
	// ALERT AND RETURN FALSE IF ERROR

	if (error == true) {
		alert (error_message);
		return false;
	} 
		
	return true;
	
}

 /////////////////////////////////////////
 //FORMS/AUTOTAB: Auto Tab with phone numbers
 /////////////////////////////////////////
 var isNN = (navigator.appName.indexOf("Netscape")!=-1);
 function autoTab(input,len, e) {
 var keyCode = (isNN) ? e.which : e.keyCode;
 var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
 if(input.value.length >= len && !containsElement(filter,keyCode)) {
 input.value = input.value.slice(0, len);
 input.form[(getIndex(input)+1) % input.form.length].focus();
 }
 function containsElement(arr, ele) {
 var found = false, index = 0;
 while(!found && index < arr.length)
 if(arr[index] == ele)
 found = true;
 else
 index++;
 return found;
 }
 function getIndex(input) {
 var index = -1, i = 0, found = false;
 while (i < input.form.length && index == -1)
 if (input.form[i] == input)index = i;
 else i++;
 return index;
 }
 return true;
}


/////////////////////////////////////////
//CONSOLE DROP DOWN: Populate drop options
/////////////////////////////////////////
function changeconsole(k,selectedOne){

	x = document.theForm.manufacturer.options.selectedIndex;
	var groups=document.theForm.manufacturer.options.length;

	var group=new Array(groups);
	for (i=0; i<groups; i++) 
	group[i]=new Array();

	group[1][0]=new Option("Step 2: --Select--","");
	group[1][1]=new Option("D1","D1");
	group[1][2]=new Option("D5","D5");
	group[1][3]=new Option("SD7","SD7");
	group[1][4]=new Option("SD8","SD8");
	group[1][5]=new Option("View All", "All");
	
	group[2][0]=new Option("Step 2: --Select--","");
	group[2][1]=new Option("Venue D-Show","Venue D-Show");
	group[2][2]=new Option("Venue D-Show Profile","Venue D-Show Profile");
	group[2][3]=new Option("Venue D-Show Profile Mix Rack","Venue D-Show Profile Mix Rack");
	group[2][4]=new Option("View All", "All");
	
	group[3][0]=new Option("Step 2: --Select--","");
	group[3][1]=new Option("XL8","XL8");
	group[3][2]=new Option("Pro6","Pro6");
	group[3][3]=new Option("View All", "All");
	
	group[4][0]=new Option("Step 2: --Select--","");
	group[4][1]=new Option("Vi6","Vi6");
	group[4][2]=new Option("View All", "All");
	
	group[5][0]=new Option("Step 2: --Select--","");
	group[5][1]=new Option("Vista 5 SR","Vista 5 SR");
	group[5][2]=new Option("View All", "All");

	group[6][0]=new Option("Step 2: --Select--","");
	group[6][1]=new Option("DM2000 V2","DM2000 V2");
	group[6][2]=new Option("DSP5D","DSP5D");
	group[6][3]=new Option("LS9-32","LS9-32");
	group[6][4]=new Option("M7CL-48","M7CL-48");
	group[6][5]=new Option("PM1D V2","PM1D V2");
	group[6][6]=new Option("PM5D V2","PM5D V2");
	group[6][7]=new Option("PM5DRH V2","PM5DRH V2");
	group[6][8]=new Option("View All", "All");

	
	group[7][0]=new Option("Step 2: --Select--","");
	group[7][1]=new Option("Digico - D1","Digico|D1");
	group[7][2]=new Option("Digico - D5","Digico|D5");	
	group[7][3]=new Option("Digico - SD7","Digico|SD7");	
	group[7][4]=new Option("Digico - SD8","Digico|SD8");	
	group[7][5]=new Option("Digidesign - Venue D-Show","Digidesign|Venue D-Show");
	group[7][6]=new Option("Digidesign - Venue D-Show Profile","Digidesign|Venue D-Show Profile");
	group[7][7]=new Option("Digidesign - Venue D-Show Profile Mix Rack","Digidesign|Venue D-Show Profile Mix Rack");
	group[7][8]=new Option("Midas - XL8","Midas|XL8");
	group[7][9]=new Option("Midas - Pro6","Midas|Pro6");
	group[7][10]=new Option("Soundcraft - Vi6","Soundcraft|Vi6");
	group[7][11]=new Option("Studer - Vista 5 SR","Studer|Vista 5 SR");
	group[7][12]=new Option("Yamaha - DM2000 V2","Yamaha|DM2000 V2");
	group[7][13]=new Option("Yamaha - DSP5D","Yamaha|DSP5D");
	group[7][14]=new Option("Yamaha - LS9-32","Yamaha|LS9-32");
	group[7][15]=new Option("Yamaha - M7CL-48","Yamaha|M7CL-48");
	group[7][16]=new Option("Yamaha - PM1D V2","Yamaha|PM1D V2");
	group[7][17]=new Option("Yamaha - PM5D V2","Yamaha|PM5D V2");
	group[7][18]=new Option("Yamaha - PM5DRH V2","Yamaha|PM5DRH V2");
	group[7][19]=new Option("View All", "All|All");
	
	var temp=document.theForm.console;
	for (m=temp.options.length-1;m>0;m--) {
		temp.options[m]=null;
		for (i=0;i<group[x].length;i++){
			temp.options[i]=new Option(group[x][i].text,group[x][i].value);
		}
		if (selectedOne != "null") {
			temp.options[selectedOne].selected=true;
		} else {
			temp.options[0].selected=true;
		}
	}
}

/*
Author: Michele
Date: 09/6/2007
Description: testimonial rotation
*/

function testimonialConsoles() {
	
	var testToUse;
	testimonials = new Array();
	
	testimonials[0] = '<span class=clientTestCopy>"We love our PM1D. It makes our shows much easier. Louis was great in every aspect from the sale to the installation and after. Shipping was on time and the training Louis gave was superb even after the installation. And when we needed answers to something Hi-Tech Audio answered them. Our Sound Engineer, Mike Porter, appreciates you. I know our next purchase will be with them. Thanks Hi-Tech Audio and staff."</span><p><table width=100% cellpadding=0><tr><td align=right><span class=clientTestCopy><i>Bodie Pebbles<br>Concert Hall Director<br>Peppermill Casino<br>West Wendover NV</i></span></td></tr></table>',
	testimonials[1] =  '<span class=clientTestCopy>"Hi-Tech will get us what we need, where we need it, when we need it. They are all about consoles and service."</span><p><table width=100% cellpadding=0><tr><td align=right><span class=clientTestCopy><i>Smoother Smythe<br>CEO and Co-Founder<br>Delicate Productions</i></span></td></tr></table>',
	testimonials[2] = '<span class=clientTestCopy>"Dear Louis,<br>I want to thank you again for your help and support for my mixing console purchases since 1997. You have always given the best advice in terms of console purchases and support during and after the transaction." </span><p><table width=100% cellpadding=0><tr><td align=right><span class=clientTestCopy><i>George Rellis<br>Rellis Sound, Inc.<br>Eugene, OR</i></span></td></tr></table>',
	

	totalNum = testimonials.length;
	whichTesti = Math.floor(totalNum*Math.random());
	testToUse = testimonials[whichTesti];
	document.write(testToUse);
//	return testToUse;
	
//	var testLine = '<span class=clientTestCopy>""</span><p><table width=100% cellpadding=0><tr><td align=right><span class=clientTestCopy><i><br><br></i></span></td></tr></table>';
}

/*
Author: Michele
Date: 09/6/2007
Description: new window
*/

var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
	win=window.open(mypage,myname,settings);
	win.focus();
}
