

		var FirstImage = 1;
		var ImageNum = (FirstImage);
		var cName = "LastImage";
		var picture = "image-";
		var ext = ".jpg";


function OpenRemoteWindow(urlAddress){ 
		window.open('worldwide/' + urlAddress,'',config='height=320,width=350')
		}


function chgSlide(direction) {
	if (document.images) {
		ImageNum = ImageNum + direction
		if (ImageNum > TotalImages) {
			ImageNum = FirstImage 
		}
		if (ImageNum < FirstImage) {
			ImageNum = TotalImages
		}
		document.SlideShow.src = picture + (ImageNum + 100) + ext
		document.frmMain.Pix.value = ImageNum
		}
		}


function getPix(){
	if (parseInt(document.frmMain.Pix.value) < FirstImage){
		document.frmMain.Pix.value = FirstImage}
		if (parseInt(document.frmMain.Pix.value) < TotalImages){
			ImageNum = parseInt(document.frmMain.Pix.value)
			document.SlideShow.src = picture + (ImageNum + 100) + ext
			document.frmMain.Pix.value = ImageNum
			}
			else (ImageNum = TotalImages)
			document.SlideShow.src = picture + (ImageNum + 100) + ext
			document.frmMain.Pix.value = ImageNum
			}

function Calculate_Values(){
	if (document.forms[0].ResonantFrequency.value){
        if (document.forms[0].CableLength.value){
         
            var ResonantFrequency = eval(document.forms[0].ResonantFrequency.value);
            var CableLength = eval(document.forms[0].CableLength.value);
            var TotalCapacitance = eval(document.forms[0].TotalCapacitacnce.value);
            
            var PropagationDelay_Foot = ((1/ResonantFrequency)/CableLength)*1000
            var Capacitance_Foot = TotalCapacitance / CableLength
            var Impedance = (PropagationDelay_Foot*1000)/Capacitance_Foot            
            
            document.forms[0].PropagationDelay_Foot.value = Math.round(PropagationDelay_Foot*100)/100;
            document.forms[0].Impedance_Ohms.value = Math.round(Impedance*100)/100 ;
            document.forms[0].Capacitance_Foot.value = Math.round(Capacitance_Foot*100)/100;
            document.forms[0].Inductance_Foot.value = Math.round((Math.pow(Impedance,2)*Capacitance_Foot)/1000000*100)/100; 
            document.forms[0].VelocityOfPropagation_Foot.value = Math.round((1.016/PropagationDelay_Foot)*100*100)/100;
            }
            }
            }


function CalculateLengths(){
      var Frequency = eval(document.forms[0].Frequency.value)
         if (Frequency > 0){
            var sD = (Math.round((234 / Frequency) * 1000)/1000);
            document.forms[0].dipole.value = sD
            var sV = Math.round(sD * 950)/1000
            document.forms[0].invertedV.value = sV;
            }
            }

function CalculateGain(){
      if (document.forms[0].input.value){
         if (document.forms[0].output.value){
            d1=eval(document.forms[0].input.value);
            d2=eval(document.forms[0].output.value);
            db=10*(Math.LOG10E * Math.log(d2/d1))
            db = Math.round(db*1000)/1000
            document.forms[0].gain.value =db;
            }
            }
            }

function CalculateSWR(){
      if (document.forms[0].forward.value){
         if (document.forms[0].reflected.value){
            fwd =eval(document.forms[0].forward.value);
            ref =eval(document.forms[0].reflected.value);
            var swr = (1+(Math.sqrt(ref/fwd)))/(1-(Math.sqrt(ref/fwd)));
            swr = Math.round(swr*100)/100
            document.forms[0].swrRatio.value = swr + ':1';
            }
            }
            }


//			Impedance = (60 / e^(1/2)) * log (D/d)

function Calculate_Z(){
      if (document.forms[0].DielectricConstant.value){
         if (document.forms[0].ConductorDiameter.value){
	         if (document.forms[0].ShieldDiameter.value){
         
    	        var e = eval(document.forms[0].DielectricConstant.value);
        	var d = eval(document.forms[0].ConductorDiameter.value);
            	var D = eval(document.forms[0].ShieldDiameter.value);
            
            	var Z = (60/Math.sqrt(e))*Math.log(D/d);
            	document.forms[0].Z.value = Math.round(Z*100)/100;
            	}
            	}
            	}
            	}

function CalculateLensAngle(){

	var CCDHeight, CCDWidth, FOVHeight, FOVWidth, FOVAngle, Distance, LensSize;

	LensSize = document.calcfov.lens.value;
	Distance = document.calcfov.distance.value;

	// Check that the required values have been supplied. Display message if not
	if ((LensSize <= 0) || (Distance <= 0)){
		document.calcfov.angle.value = 0;
		document.calcfov.height.value = 0;
		document.calcfov.width.value = 0;				
		window.alert("Please enter a valid Lens Size and Distance.")
	}
	else{
	//got valid input values
		switch (document.calcfov.ccdvalue.value){
			case "third":
				CCDWidth = 4.8;
				CCDHeight = 3.6;
				break;
			case "quarter":
				CCDWidth = 3.6;
				CCDHeight = 2.7;
				break;
		}

		FOVHeight = Math.round(((CCDHeight * Distance)/LensSize)*10)/10;
		FOVWidth = Math.round(((CCDWidth * Distance)/LensSize)*10)/10;				
		FOVAngle = Math.atan(FOVWidth/Distance) * 100;
		document.calcfov.height.value = FOVHeight;
		document.calcfov.width.value = FOVWidth;	
		//window.alert("FOVAngle:" + FOVAngle);				
		//window.alert("FOVAngle Rounded:" + Math.round(FOVAngle));	
		document.calcfov.angle.value = Math.round(FOVAngle);
		//debug
		//window.alert("LensSize:" + LensSize);
		//window.alert("Distance:" + Distance);		
	}

}

