function ON_load(){
document.getElementById('content_area').style.color="rgb(128,128,128)";	
document.getElementById('content_area').style.backgroundColor="rgb(0,0,0)";	
alert("Warning, this is not your normal website. It will take some work to navigate it. If you have problems, use the instruction book. And don't forget to turn off the power before you leave.");	
}
var defaultStep=10;
var step=defaultStep;
var timerDown="";
var timerUp="";
var default_padding_value=80;
var default_width_value=440;
var padding_offset;
var new_width;
var screen_width=1;
var color_value;
var bg_color_value;
var letr_spacing=0;

var img_wdth = new Array();
		
function text_replace (){
		if (C_tune == tuning.length){C_tune=0;}
		if (C_tune < 0){C_tune=tuning.length-2;}
		
		if (F_tune > tuning[C_tune+1].length-1){F_tune=0;}
		if (F_tune < 0){F_tune=tuning[C_tune+1].length-2;}
		
		url_address=tuning[C_tune+1][F_tune+1];		 
		document.getElementById('text1').innerHTML=tuning[C_tune];	
		document.getElementById('text2').innerHTML=tuning[C_tune+1][F_tune];	
			
	}

function spinKnob(id){
	if (/bknob1.gif/.test(document.getElementById(id).src)==true){
		document.getElementById(id).src="../design_images/bknob2.gif";
	}else{
	 	document.getElementById(id).src="../design_images/bknob1.gif";}
	}
	
/*	var	knob_cycle=0;
function spinKnob2(id){
	if (knob_cycle==1){
	 	knob_cycle=0;
		document.getElementById(id).src="../images/sknob2.gif";
	}else{
	 	knob_cycle=1;
	 	document.getElementById(id).src="../images/sknob1.gif";}
	}
*/
function toggle_power(){
	if (power_status==0){
		power_status=1;
		document.power_switch.src="../design_images/switch_1.gif";
		document.meter.src="../design_images/meter_0_80.gif";
		document.getElementById('text1').style.backgroundPosition="bottom";	
		document.getElementById('text2').style.backgroundPosition="bottom"; // makes dial look on;	
		document.getElementById('text1').style.color="#C00";	
		document.getElementById('text2').style.color="#C00";	
		document.getElementById('overlay').style.visibility='visible'
		document.overlay.src='../design_images/power_on.gif'
		window.setTimeout("document.getElementById('content_area').style.visibility='visible'",2200);
		window.setTimeout("document.overlay.src='../design_images/snow.gif'",2000);
//		window.setTimeout("document.getElementById('overlay').style.visibility='hidden'",2500);
		window.setTimeout("document.meter.src='../design_images/meter_hover_80.gif'",2700);



	}else{
		power_status=0;
		document.power_switch.src="../design_images/switch_0.gif";
		document.getElementById('overlay').style.visibility='visible';
		document.getElementById('content_area').style.visibility="hidden";
		document.getElementById('text1').style.backgroundPosition="top"; //makes dial look off	
		document.getElementById('text2').style.backgroundPosition="top"; 	
		document.getElementById('text1').style.color="#500";	
		document.getElementById('text2').style.color="#500";	
		document.meter.src="../design_images/meter_100_off.gif";
		window.setTimeout("document.overlay.src='../design_images/power_off.gif'",50);
		}
}//end toggle power

function channel_lock(){
	if (power_status==1){getAXAH(url_address,'content_area');}
}

function cancel_switch(){
	if (power_status==0){document.power_switch.src="../design_images/switch_0.gif";}
	else{document.power_switch.src="../design_images/switch_1.gif";
	}
}

//object detection to return the correct object depending upon broswer type. Used by the getAXAH(); function.
function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

//Function used to update page content with new xhtml fragments by using a javascript object, the dom, and http.
function getAXAH(url,elementContainer){
		document.overlay.src='../design_images/snow.gif';
		document.getElementById('overlay').style.visibility='visible';
		var theHttpRequest = getNewHttpObject();
		theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);};
		theHttpRequest.open("GET", url);
		theHttpRequest.send(false);

		function processAXAH(elementContainer){
		   if (theHttpRequest.readyState == 4) {
			   if (theHttpRequest.status == 200) {
					document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;
					disp = document.getElementById(elementContainer);
					img_lst = disp.getElementsByTagName("img");
					// gets image widths for v-size
					for (var i = 0; i < img_lst.length; i++) { 
			    		img_wdth[i]=img_lst[i].getAttribute("width"); 
					    status = img_wdth[i];
					} 
					// resets width
					screen_width=1;
					new_width=(screen_width*default_width_value);
					document.getElementById(elementContainer).style.width=new_width+'px';
					padding_offset=((default_width_value-new_width)/2)+default_padding_value;
					document.getElementById(elementContainer).style.paddingRight=padding_offset+'px';
					document.getElementById(elementContainer).style.paddingLeft=padding_offset+'px';
					document.getElementById(elementContainer).style.letterSpacing=(screen_width*10)-7+"px";
					document.getElementById(elementContainer).scrollTop="top";
//					document.getElementById(knob_id).src='../design_images/sknob'+parseInt((screen_width*10))+'.gif';
					//clears snow
					window.setTimeout("document.getElementById('overlay').style.visibility='hidden'",150);
			   } else {
				   //document.getElementById(elementContainer).innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message:&nbsp;" + theHttpRequest.statusText +"<\/p>";
			   }
		   }
		}

}


function stopMe(){
	clearTimeout(timerDown);
	clearTimeout(timerUp);
}

document.onmousemove=function(){stopMe()}  

function display_narrow(id,knob_id){
  	disp = document.getElementById(id);
 	img_lst = disp.getElementsByTagName("img");
	if (screen_width >.3){
	 	screen_width=screen_width-.1;
		new_width=(screen_width*default_width_value);
		document.getElementById(id).style.width=new_width+'px';
		padding_offset=((default_width_value-new_width)/2)+default_padding_value;
		document.getElementById(id).style.paddingRight=padding_offset+'px';
		document.getElementById(id).style.paddingLeft=padding_offset+'px';
		document.getElementById(id).style.letterSpacing=(screen_width*10)-7+"px";
		document.getElementById(knob_id).src='../design_images/sknob'+parseInt((screen_width*10))+'.gif';
		for (var i = 0; i < img_lst.length; i++) { 
    		img_lst[i].setAttribute("width",img_wdth[i]*screen_width);
		} 
	}
}	

function display_widen(id,knob_id){
	if (screen_width <1.2){
	 	screen_width=screen_width+.1;
		new_width=(screen_width*default_width_value);
		document.getElementById(id).style.width=new_width+'px';
		padding_offset=((default_width_value-new_width)/2)+default_padding_value;
		document.getElementById(id).style.paddingRight=padding_offset+'px';
		document.getElementById(id).style.paddingLeft=padding_offset+'px';
		document.getElementById(id).style.letterSpacing=(screen_width*10)-7+"px";
		document.getElementById(knob_id).src='../design_images/sknob'+parseInt((screen_width*10))+'.gif';
		for (var i = 0; i < img_lst.length; i++) { 
    		img_lst[i].setAttribute("width",img_wdth[i]*screen_width);
		} 
   }
}


function scrollDivDown(id,knob_id){
	clearTimeout(timerDown);
	document.getElementById(id).scrollTop+=step;
	timerDown=setTimeout("scrollDivDown('"+id+"','"+knob_id+"')",10);
} 

function scrollDivUp(id,knob_id){
	clearTimeout(timerUp);
	document.getElementById(id).scrollTop-=step;
	timerUp=setTimeout("scrollDivUp('"+id+"','"+knob_id+"')",10);
} 

function brightness(id, direction,knob_id){
	clearTimeout(timerDown);
	color_value=document.getElementById(id).style.color;
	bg_color_value=document.getElementById(id).style.backgroundColor;
	if (direction=="plus"){
	 colorIncrease(color_value);
	 bgColorIncrease(bg_color_value);
	}else{
		colorDecrease(color_value);
		bgColorDecrease(bg_color_value);
	}
	document.getElementById(id).style.color=color_value;
	document.getElementById(id).style.backgroundColor=bg_color_value;
	timerDown=setTimeout("brightness('"+id+"','"+direction+"','"+knob_id+"')",20);
}

function contrast(id, direction,knob_id){
	clearTimeout(timerDown);
	color_value=document.getElementById(id).style.color;
	bg_color_value=document.getElementById(id).style.backgroundColor;
	if (direction=="plus"){
	 colorIncrease(color_value);
	 bgColorDecrease(bg_color_value);
	}else{
		colorDecrease(color_value);
		bgColorIncrease(bg_color_value);
	}
	document.getElementById(id).style.color=color_value;
	document.getElementById(id).style.backgroundColor=bg_color_value;
	timerDown=setTimeout("contrast('"+id+"','"+direction+"','"+knob_id+"')",20);
}

function colorIncrease(str) {									
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10); //R 0-255
   str[1] = parseInt(str[1], 10); //G 0-255
   str[2] = parseInt(str[2], 10); //B 0-255
   if (str[0] >= 255 || str[1] >= 255 || str[2] >= 255 ){
    return ;
	}else{
		str[0]=str[0]+5;
		str[1]=str[1]+5;
		str[2]=str[2]+5;
	}
	color_value= "rgb("+str[0]+","+str[1]+","+str[2]+")";
}

function colorDecrease(str) {									
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10); //R 0-255
   str[1] = parseInt(str[1], 10); //G 0-255
   str[2] = parseInt(str[2], 10); //B 0-255
   if (str[0] <= 0 || str[1] <= 0 || str[2] <= 0 ){
    return ;
	}else{
		str[0]=str[0]-5;
		str[1]=str[1]-5;
		str[2]=str[2]-5;
	}
	color_value= "rgb("+str[0]+","+str[1]+","+str[2]+")";
}

function bgColorIncrease(str) {									
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10); //R 0-255
   str[1] = parseInt(str[1], 10); //G 0-255
   str[2] = parseInt(str[2], 10); //B 0-255
   if (str[0] >= 255 || str[1] >= 255 || str[2] >= 255 ){
    return ;
	}else{
		str[0]=str[0]+5;
		str[1]=str[1]+5;
		str[2]=str[2]+5;
	}
	bg_color_value= "rgb("+str[0]+","+str[1]+","+str[2]+")";
}

function bgColorDecrease(str) {									
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10); //R 0-255
   str[1] = parseInt(str[1], 10); //G 0-255
   str[2] = parseInt(str[2], 10); //B 0-255
   if (str[0] <= 0 || str[1] <= 0 || str[2] <= 0 ){
    return ;
	}else{
		str[0]=str[0]-5;
		str[1]=str[1]-5;
		str[2]=str[2]-5;
	}
	bg_color_value= "rgb("+str[0]+","+str[1]+","+str[2]+")";
}

