onLoadArray = new Array();
var actualContDisplayed;
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;

window.onload = function(){
	for(ii in onLoadArray){	onLoadArray[ii](); }
}

/******************************/
function evalScript(scripts){	
	try{
		if(scripts != ''){
			var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}catch(e){
		alert(e)
	}
}
function $(id){
	if(document.getElementById(id)){ return document.getElementById(id); }else{ return false; }
}
function oN(obj){
	obj.style.display = "block";
}
function oFF(obj){
	obj.style.display = "none";
}
function toogle(obj){
	obj.style.display = obj.style.display == "none" ? "block":"none";
}
/******************************/

function chargeCalendarHomepageFlash(){
	var params = {};
	params.wmode = "transparent";
	swfobject.embedSWF("resources/swf/calendario_corto.swf", "calendarios_cont", "247", "148", "9.0.0.0", "expressInstall.swf","",params);
	swfobject.embedSWF("resources/swf/slides.swf", "3k_cont", "240", "148", "9.0.0.0", "expressInstall.swf","",params);
	swfobject.embedSWF("resources/swf/importantSpace.swf", "contInfoMicro1", "238", "70", "9.0.0.0", "expressInstall.swf","",params);
}

function contLightMinHeight(){
	if(IE6==true){
		if(document.documentElement.clientHeight < 673){
		$("contLight").style.height="673px";	
		}else if($("contLight").style.height=="673px"){
			$("contLight").style.height=null;
		}
		
	}
//contLight
}
function openLight(up,obj){
	if(up==false){
		if(obj){
			if(typeof(actualContDisplayed) != "undefined"){
				if(actualContDisplayed.style.display == "block"){
					actualContDisplayed.style.display = "none";
				}
			}
			setTimeout("oN($('"+obj+"'))",300);
			actualContDisplayed = $(obj);
			}
		
			if($("contLight").style.display != "block"){
				opacity("contLight", 0, 80, 500);
			}
	}else{
		opacity("contLight", 80, 0, 500);
		if(actualContDisplayed){
			oFF(actualContDisplayed);
		}
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
	
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "','down')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
		
        changeOpac(opacStart, id, "up");
		oN($(id));
		
		for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "','up')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacityIn, id, sent) {
    var object = document.getElementById(id).style;
    object.opacity = (opacityIn / 100);
    object.MozOpacity = (opacityIn / 100);
    object.KhtmlOpacity = (opacityIn / 100);
    object.filter = "alpha(opacity=" + opacityIn + ")";
	if(sent=="down"){
		if(opacityIn==0){ oFF($(id)); }
	}
} 

function loadContent(url, id, fpFuncion)
{
	var xmlhttp=null;
	
	if (window.XMLHttpRequest){
	  xmlhttp=new XMLHttpRequest();
	}else if (window.ActiveXObject){
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4){
				if($(id)){ $(id).innerHTML = xmlhttp.responseText; evalScript($(id).innerHTML); }
				if($("loading")){ opacity("loading", 80, 0, 200); }
				if(fpFuncion){ fpFuncion(xmlhttp); }
			}
	  };
	  
	  xmlhttp.open("GET",url,true);
	  xmlhttp.send(null);

	}
	else
	  alert("Your browser does not support XMLHTTP.");
}

function chargeGalery(){
	var params = {};
	params.wmode = "transparent";

	swfobject.embedSWF("resources/uniformsGalery/galery.swf", "galeryFlash", "720", "65", "9.0.0.0", "expressInstall.swf","",params);
}

function chargeLGalery(){
	var params = {};
	params.wmode = "transparent";

	swfobject.embedSWF("resources/locationGalery/galery.swf", "galeryFlash", "720", "65", "9.0.0.0", "expressInstall.swf","",params);
}


function loadGaleryImage(imgName,imgPath){
	$("contGaleryCharge").style.backgroundImage = "url('resources/uniformsGalery/"+imgPath+"')";
	$("contGaleryText").innerHTML = imgName;
}
function loadInstalacionesImage(imgName,imgPath){
	$("contGaleryCharge").style.backgroundImage = "url('resources/locationGalery/"+imgPath+"')";
	$("contGaleryText").innerHTML = imgName;
}
function loadCentral(file,fpFuncion){
	opacity("loading", 0, 80, 200);
	setTimeout('loadContent("'+file+'","contCharge",'+fpFuncion+')',500);
}

function chargeIntro(){
	var params = {};
	params.wmode = "transparent";
	swfobject.embedSWF("resources/swf/intro/intro2.swf", "flash", "1024", "643", "8.0.0.0", "expressInstall.swf","",params);
	$("flash").className="flashObject";
}

function showSub(Index,This,Sub){
	var subs = $("contQuienesSubs").getElementsByTagName("div");
	
	for(var ii = 0; ii< subs.length ; ii++){
		subs[ii].style.display = ii == Index ? "block" : "";
	}

	if(This){
			var subs = $("quieneSomosItems").getElementsByTagName("li");
			for(var ii = 0; ii< subs.length ; ii++){
				subs[ii].className = subs[ii] == This.parentNode ? "on" : "";
			}
			
			var subs = $("quieneSomosItems").getElementsByTagName("a");
			
			for(var ii = 0; ii< subs.length ; ii++){
				subs[ii].className = subs[ii] == This ? "quienesSomosSelected" : "";
				
			}
	}
}
function submitForm(){
	oFF($("formCharge"));
	oN($("loadingForm"));
	$("formResults").innerHTML = "";
	
	parameters = "";
	for(ii=0;ii<$("formCharge").length;ii++){
		parameters += $("formCharge")[ii].name + "=" + $("formCharge")[ii].value;
		if(ii<$("formCharge").length-1){
			parameters += "&";
		}
	}
	
	parameters = encodeURI(parameters);
	
	loadContent("submitForm.php?" + parameters, "formResults",formDone)
}
function formDone(){
	oFF($("loadingForm"));
	oN($("formResults"));
}


function resetForm(){
	oN($("formCharge"));
	oFF($("loadingForm"));
	oFF($("formResults"));
}
/*******************************/
if($("contLight")){
	window.onresize = contLightMinHeight;
	onLoadArray.push(contLightMinHeight);
}
/******************************/

var section_slide_paths = new Array();
var section_slide_actual = 0;

function set_section(section_name){
	switch (section_name){
		case "historia":
			section_slide_paths = ["resources/img/sections_slide_photos/historia01.jpg","resources/img/sections_slide_photos/historia02.jpg","resources/img/sections_slide_photos/historia03.jpg"];
		break;
		case "campamentos":
			section_slide_paths = ["resources/img/sections_slide_photos/campamentos/camp1.jpg","resources/img/sections_slide_photos/campamentos/camp2.jpg","resources/img/sections_slide_photos/campamentos/camp3.jpg","resources/img/sections_slide_photos/campamentos/camp4.jpg"];
		break;
		
		case "ed_fisica":
			section_slide_paths = ["resources/img/sections_slide_photos/ed_fisica/ed_fis1.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis2.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis3.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis4.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis5.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis6.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis7.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis8.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis9.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis10.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis11.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis12.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis13.jpg",
								   "resources/img/sections_slide_photos/ed_fisica/ed_fis14.jpg"];
		break;
		case "extprog":
			section_slide_paths = ["resources/img/sections_slide_photos/extprog/extraprog1.jpg",
								   "resources/img/sections_slide_photos/extprog/extraprog2.jpg",
								   "resources/img/sections_slide_photos/extprog/extraprog3.jpg",
								   "resources/img/sections_slide_photos/extprog/extraprog4.jpg",
								   "resources/img/sections_slide_photos/extprog/extraprog5.jpg"];
		break;
		case "castellano":
			section_slide_paths = ["resources/img/sections_slide_photos/castellano/ep_castellano01.jpg",
								   "resources/img/sections_slide_photos/castellano/ep_castellano02.jpg",
								   "resources/img/sections_slide_photos/castellano/ep_castellano03.jpg",];
		break;
	}
}


function next_slide_image(){
	section_slide_actual++;
	section_slide_actual = section_slide_paths.length == section_slide_actual ? 0 : section_slide_actual;
	$("actual_section_photo").style.backgroundImage = "url("+section_slide_paths[section_slide_actual]+")";
}
function prev_slide_image(){
	section_slide_actual--;
	section_slide_actual = section_slide_actual == -1 ? section_slide_paths.length-1 : section_slide_actual;
	$("actual_section_photo").style.backgroundImage = "url("+section_slide_paths[section_slide_actual]+")";
}

/**********************************************************************************/

function showThisTool(This,boo){
	if(typeof(This.getElementsByTagName("div")[1])!="undefined"){
		This.getElementsByTagName("div")[1].style.display = boo ? "block" : "none";
	}
}

/********************************************************************************/

function next_news_image(){
	if(acutal_photo_news_showed+1 >= photos_paths.length){
		acutal_photo_news_showed = 0;
	}else{
		acutal_photo_news_showed++;
	}
	
	$("contImgBg_New").style.backgroundImage = "url(resources/img/novedades/"+ photos_paths[acutal_photo_news_showed] +")"
	
}

function prev_news_image(){
	if(acutal_photo_news_showed == 0){
		acutal_photo_news_showed = photos_paths.length-1;
	}else{
		acutal_photo_news_showed--;
	}
	
	$("contImgBg_New").style.backgroundImage = "url(resources/img/novedades/"+ photos_paths[acutal_photo_news_showed] +")"
	
}

/********************************************************************************/

function next_proj_image(){
	if(acutal_photo_news_showed+1 >= photos_paths.length){
		acutal_photo_news_showed = 0;
	}else{
		acutal_photo_news_showed++;
	}
	
	$("contImgBg_New").style.backgroundImage = "url(resources/img/proyectos/"+ photos_paths[acutal_photo_news_showed] +")"
	
}

function prev_proj_image(){
	if(acutal_photo_news_showed == 0){
		acutal_photo_news_showed = photos_paths.length-1;
	}else{
		acutal_photo_news_showed--;
	}
	
	$("contImgBg_New").style.backgroundImage = "url(resources/img/proyectos/"+ photos_paths[acutal_photo_news_showed] +")"
	
}
