//&L(0,"*",1);
/* STL standard visual functions
 * Angelo Dureghello, Barix AG 
 */
function clear(o) {
	o.getElementById('table1').style.display = "none";
	o.getElementById('table2').style.display = "none";
	o.getElementById('table3a').style.display = "none";
	o.getElementById('table3b').style.display = "none";
   o.getElementById('table3c').style.display = "none";
	o.getElementById('table3d').style.display = "none";
	o.getElementById('table3e').style.display = "none";
   o.getElementById('table3f').style.display = "none";
	o.getElementById('table3g').style.display = "none";
	o.getElementById('table4').style.display = "none";
	o.getElementById('table4a').style.display = "none";
	o.getElementById('table4b').style.display = "none";
	o.getElementById('table4c').style.display = "none";
	o.getElementById('table4d').style.display = "none";
	o.getElementById('table4e').style.display = "none";
	o.getElementById('table4f').style.display = "none";
	o.getElementById('table5').style.display = "none";
	o.getElementById('table6').style.display = "none";
	o.getElementById('table7').style.display = "none";
}
function basicSettings()
{
	var st=&LSetup(1,"%u",536,B);;
	if (st==0) { document.getElementById('bsrs').innerHTML="---"; }
	if (st==1) { document.getElementById('bsos').innerHTML="---"; }
}
function loadLocations()
{
	var htype=&LState(1,"%d",28);&0xff;
	var stydd=document.getElementById('stype');
	var n=0;
	sel=&LSetup(1,"%lu",536,B,);;
	switch (htype) {
		case 1:
		case 9:
		case 14:
		case 20:
			stydd.options[n++]=new Option("Transmitter Decoder",1,true,sel==1);
		break;
		case 8:
			stydd.options[n++]=new Option("Studio Encoder",0,true,sel==0);
		break;
		default:
			stydd.options[n++]=new Option("Studio Encoder",0,true,sel==0);
			stydd.options[n++]=new Option("Transmitter Decoder",1,false,sel==1);
			stydd.options[n++]=new Option("Studio Encoder/Decoder",2,false,sel==2);
			stydd.options[n++]=new Option("Transmitter Encoder/Decoder",3,false,sel==3);
		break;
	}
}
function def_hideshow(frame){
	if (frame)
		object=parent.frames[frame].document;
	else
		object=document;
	clear(object);
	toggleDisplay('1');
	aftChange(0);
}
function turnBackBold(speclink){
	var anchors=document.links
	for (i=0;i<anchors.length;i++){
		anchors[i].style.fontWeight='300';
	}
	speclink.style.fontWeight='900';
}
function showHideQlty(o) {
	var i=o.getElementById('aft').value;
	if (i>=6) {
		o.getElementById('table4c').style.display="block";
	} else {
		o.getElementById('table4c').style.display="none";
	}
}

function setInputSource()
{
   var tsrc=document.getElementById('isrc');
   var htype=&LState(1,"%u",28);
   n=0;
   tsrc.options.length=0;
   sel=&LSetup(1,"%lu",510,B);;
   
   tsrc.options[n++]=new Option("Analog Line",0,false,sel==0);
   tsrc.options[n++]=new Option("Analog Line, external ADC",7,false,sel==7);
   if (htype==21) tsrc.options[n++]=new Option("AES/EBU",9,false,sel==9);
}

// dynamic sample rate based on Audio Format, i is the AF value
function loadSampleRates(o)
{
	var st=&LSetup(1,"%u",536,B);;
	var i=o.getElementById('aft').value;
	var srtdd=o.getElementById('srt');
	srtdd.options.length=0;
	sel=&LSetup(1,"%lu",512,B);;
	n=0;
	if (i<6) { // Analog
		if (i <4) { 
			srtdd.options[n++]=new Option("8 kHz",0,false,sel==0);
			srtdd.options[n++]=new Option("24 kHz",4,false,sel==4); // all analog mono
		}
		//if (i <4)	{ srtdd.options[n++]=new Option("12 kHz",1,false,sel==1); }	// DISABLE
		if (i==4) {
			if (st>=2) { srtdd.options[n++]=new Option("32 kHz",5,false,sel==5); }  // 32 Khz PCM only HD, stereo big endian
			srtdd.options[n++]=new Option("44.1 kHz",6,false,sel==6);   // 44.1 Khz stereo big endian only
			/*if (st<2) {*/ srtdd.options[n++]=new Option("48 kHz",7,false,sel==7);   // 48 Khz PCM only HD, stereo big endian
		}
	} else { // MPEG
		srtdd.options[n++]=new Option("16 kHz (MPEG2 Layer III)",2,false,sel==2); 
		srtdd.options[n++]=new Option("22.05 kHz (MPEG2 Layer III)",3,false,sel==3); 
		srtdd.options[n++]=new Option("24 kHz (MPEG2 Layer III)",4,false,sel==4); 
		srtdd.options[n++]=new Option("32 kHz (MP3)",5,false,sel==5); 
		srtdd.options[n++]=new Option("44.1 kHz (MP3)",6,false,sel==6); 
		srtdd.options[n++]=new Option("48 kHz (MP3)",7,false,sel==7); 
	}
}
function toggleDisplay(e) {
	/*
	st values, SE 0, TD 1, SED 2, TED 3
	*/
	var st=&LSetup(1,"%u",536,B);;
	var o=parent.frames['config'].document;
	clear(o);
	switch(e) {
		case '1': 
         o.getElementById('table1').style.display="block";
         if (st!=1){
            o.getElementById('table3a').style.display="block";
            o.getElementById('table3b').style.display="block";
         }
         if (st!=0){
            o.getElementById('table3f').style.display="block";
         }
      break;
		case '2': o.getElementById('table2').style.display="block"; break;
		case '3':
			o.getElementById('table3a').style.display="block";
			if (st!=1) {
            o.getElementById('table3b').style.display="block";
            o.getElementById('table3c').style.display="block";
			}
			if (st!=0) {
				o.getElementById('table3d').style.display="block";
			}	
			o.getElementById('table3e').style.display="block";
			if (st!=0) {
            o.getElementById('table3f').style.display="block";
            o.getElementById('table3g').style.display="block";
         }
      break;
		case '4':
			o.getElementById('table4').style.display="block"; // title, always
			if (st!=1) {
				o.getElementById('table4a').style.display="block";
				o.getElementById('table4b').style.display="block";
				if (st==0) showHideQlty(o);
				o.getElementById('table4d').style.display="block";
			}
			o.getElementById('table4e').style.display="block"; // volume, always
			if (st!=0) o.getElementById('table4f').style.display="block"; // fading time
		break;
		case '5': o.getElementById('table5').style.display="block"; break;
		case '6': o.getElementById('table6').style.display="block"; break;
		case '7': o.getElementById('table7').style.display="block"; break;
	}
}

function aftChange(show) {
	var o=parent.frames['config'].document;
	if(show) showHideQlty(o);
	loadSampleRates(o);
}
// dynamic Audio Format options, inserting as per site type (st)
function selAudioFormat(){
	var st=&LSetup(1,"%u",536,B);;
	var aftdd=document.getElementById("aft");
	aftdd.options.length=0;
	sel=&LSetup(1,"%u",511,B);;
	n=0;
	if (st!=1) {
		// analog
		aftdd.options[n++]=new Option("u-Law 8bit mono", 0, false, sel==0);
		aftdd.options[n++]=new Option("A-Law 8bit mono ", 1, false, sel==1);
		aftdd.options[n++]=new Option("PCM 16bit mono MSB", 2, false, sel==2);
		//aftdd.options[3]=new Option("PCM 16bit mono little endian", 3, false, sel==3);
		aftdd.options[n++]=new Option("PCM 16bit stereo MSB", 4, false, sel==4);
		//aftdd.options[5]=new Option("PCM 16bit stereo little endian", 5, false, sel==5);
	}
	if (st==0)
	{
		aftdd.options[n++]=new Option("MPEG mono", 6, false, sel==6);
		aftdd.options[n++]=new Option("MPEG stereo", 7, false, sel==7);
	}
}
