var activeSub=0;
var SubNum=0;

function reDo(){ window.location.reload() }
    window.onresize = reDo;


    //Define global variables

	    var timerID = null;
		var timerOn = false;
		var timecount = 1000;
		var what = null;
		var newbrowser = true;
		var check = false;

    	function init(){
    	//  alert ("Running Init");
          if (document.layers) {
                      //  alert ("Running Netscape 4");
                        layerRef="document.layers";
                        styleSwitch="";
                        visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";


          }else if(document.all){
                      //  alert ("Running IE");
                        layerRef="document.all";
                        styleSwitch=".style";
                        visibleVar="visible";
			screenSize = document.body.clientWidth + 18;
			what ="ie";

		  }else if(document.getElementById){
                      //  alert ("Running Netscape 6");
                        layerRef="document.getElementByID";
                        styleSwitch=".style";
                        visibleVar="visible";
			what="moz";

		  }else{
		  	//alert("Older than 4.0 browser.");
			what="none";
			newbrowser = false;



		  }

		check = true;
//document.forms[0].reset();
  	 	}

	// Turns the layers on and off
        function showLayer(layerName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
	        	else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="visible";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
                  }
		 }
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
		}

        function hideLayer(layerName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="hidden";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
				}

        	}
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
        }


		function hideAll(){

for (i=1; i<7; i++){
thelayer = ('layer'+i);

hideLayer(thelayer);
//calculate();
}


				}


		function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , timecount);
                timerOn = true;

	        }

		}


		function stopTime() {
	        if (timerOn) {
    	        clearTimeout(timerID);
                timerID = null;
                timerOn = false;
	        }
		}

		function onLoad(){
			init();

			}








// HIGHLIGHT FORM FIELDS
clr=new Array('#efefef','white','silver');
function highlight(state) {
	element=event.srcElement;
	etype=element.type;
	if ((element.tagName=='INPUT') && (etype=="text")) {
	etype=element.type;
		if ((etype=='submit' || etype=='reset') && state==1) state=2;
		element.style.backgroundColor=clr[state];
		element.focus();
		}
	}

function calculate(){
/*
mhotel_d_d=73;
mhotel_d_s=73;
mhotel_s_d=155;
mhotel_s_s=155;
mhotel_v_d=165;
mhotel_v_s=165;

bhotel_d_d=88;
bhotel_d_s=88;
bhotel_s_d=165;
bhotel_s_s=165;

shotel_d_d=80;
shotel_d_s=80;
shotel_s_d=103;
shotel_s_s=103;
shotel_v_d=180;
shotel_v_s=180;


mexc1=50;
mexc2=93;
mexc3=310;
mexc3a=20;
mexc4=385;
mexc4a=32;
mexc5=1110;
mexc5a=56;
mexc6=500;
mexc7=25;

bexc1=60;
bexc2=93;
bexc3=310;
bexc3a=16;
bexc4=400;
bexc4a=20;
bexc5=730;
bexc5a=38;
bexc6=740;
bexc6a=38;

sexc1=160;
sexc1a=10;
sexc2=190;
sexc2a=10;

*/


mhotelTotal=0;
bhotelTotal=0;
shotelTotal=0;
mexcTotal=0;
bexcTotal=0;
sexcTotal=0;

//FIND MADRID HOTEL VALUE
for (var i=0; i < document.spainform.mhotel.length; i++) {
   if (document.spainform.mhotel[i].checked)  {
      mhotelTotal = parseInt(document.spainform.mhotel[i].value)*3;
      }
   }

//ADD MADRID EXCURSIONS VALUE
for (var i=1; i <= 10; i++) {
	currentBox = eval ('document.spainform.mexc'+ i);
		if (currentBox.checked){
			mexcSubTotal = parseInt(currentBox.value)
			mexcTotal += mexcSubTotal;
			}
		}


//FIND BARCELONA HOTEL VALUE
for (var i=0; i < document.spainform.bhotel.length; i++) {
   if (document.spainform.bhotel[i].checked)  {
      bhotelTotal = parseInt(document.spainform.bhotel[i].value)*4;
	//alert(bhotelTotal);
      }
   }


//ADD BARCELONA EXCURSIONS VALUE
for (var i=1; i <= 10; i++) {
	currentBox = eval ('document.spainform.bexc'+ i);
		if (currentBox.checked){
			bexcSubTotal = parseInt(currentBox.value)
			bexcTotal += bexcSubTotal;
	//alert(bexcTotal);
			}
		}

//FIND SITGES HOTEL VALUE
for (var i=0; i < document.spainform.shotel.length; i++) {
   if (document.spainform.shotel[i].checked)  {
      shotelTotal = parseInt(document.spainform.shotel[i].value)*2;
	//alert(shotelTotal);
      }
   }

//ADD SITGES EXCURSIONS VALUE
for (var i=1; i <= 4; i++) {
	currentBox = eval ('document.spainform.sexc'+ i);
		if (currentBox.checked){
			sexcSubTotal = parseInt(currentBox.value)
			sexcTotal += sexcSubTotal;
	//alert(sexcTotal);
			}
		}

grandTotal = mhotelTotal+bhotelTotal+shotelTotal+mexcTotal+bexcTotal+sexcTotal;

document.spainform.total.value = grandTotal;

}
