
function mostrar_ocultar(div, value){
	contenedor = document.getElementById(div);

	if(value == ""){
		if(contenedor.style.display == "none"){
			contenedor.style.display = "block";
		}else{
			contenedor.style.display = "none";
		}
	}else{
		contenedor.style.display = value;
	}
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return (scrOfY);
}

function NuevoAjax(){
        var xmlhttp=false;
        try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
                try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }catch(E){
                        xmlhttp = false;
                }
        }

        if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
                xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
}

function armarStrAjax(nForm){
	var strAjax = "";
	var count_array = 0;

	for (i=0; i<nForm.length; i++)
	{
		if(nForm[i].type == "checkbox"){
			// only checked form
			if(nForm[i].checked){
				strAjax += nForm[i].name + "=" + nForm[i].value + "&";
			}else{
				strAjax += nForm[i].name + "=&";
			}
			
		}else if(nForm[i].type == "radio"){
			if(nForm[i].checked){
				strAjax += nForm[i].name + "=" + nForm[i].value + "&";
			}
		}else if(nForm[i].type == "image"){
			strAjax += nForm[i].name + "=" + nForm[i].value + "&";
		}else{
			strAjax += nForm[i].name + "=" + nForm[i].value + "&";
		}
	}
	if(strAjax == ""){
		strAjax = null;
	}
	
	return(strAjax);
}


function CargarWithForm_an_enter_div(nameForm, url, div){
	var contenido, preloader, strAjax, nForm;
	nForm = document.getElementById(nameForm);
	
	strAjax = armarStrAjax(nForm);
	CargarWithForm_an_enter_div_with_strAjax(nameForm, url, div, strAjax);
}
function CargarWithForm_an_enter_div_with_strAjax(nameForm, url, div, strAjax){
	var ajax = this;
	var contenido, preloader;
	nForm = document.getElementById(nameForm);
	nDiv = document.getElementById(div).id;
	

	contenido = document.getElementById(nDiv);
	preloader = document.getElementById('preloader');
	preloader.style.display			= "block";
	preloader.style.color			= "white";	
	preloader.style.background		= "red";
	preloader.style.padding			= "2px";
	preloader.style.paddingLeft		= "4px";
	preloader.style.paddingBottom	= "4px";
	preloader.style.float			= "right";
	preloader.style.border			= "1px solid #CCCCCC";
	preloader.style.position		= "absolute";
	preloader.style.right			= "0px";
	preloader.style.top				= getScrollXY() + "px";

//creamos el objeto XMLHttpRequest
	ajax=NuevoAjax(); 
	//peticionamos los datos, le damos la url enviada desde el link
	ajax.open("POST", url,true); 
	ajax.onreadystatechange=function(){
//		preloader.style.zIndex		=++posicion;
		if(ajax.readyState==1){
			preloader.innerHTML			= "Cargando...";
		}else if(ajax.readyState==4){
			if(ajax.status==200){
				//mostramos los datos dentro de la div	
				txt		= ajax.responseText;

				contenido.innerHTML			= txt;
				contenido.style.display		= "block";
				
				intentos = 0;
				preloader.innerHTML			= "";
				preloader.style.display		= "none";
			}else if(ajax.status==404){
				preloader.innerHTML = "La página no existe";
			}else{
				//mostramos el posible error
				preloader.innerHTML = "Error:".ajax.status; 
			}
		}
	}
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.setRequestHeader("Accept-Charset", "UTF-8");
	ajax.send(strAjax);
}

function votacion_onOver(iform,iAdding,num,i1src){
	idiv0  = document.getElementById(iform+ '0' +iAdding);
	iform1 = document.getElementById(iform+ '1' +iAdding);
	iform2 = document.getElementById(iform+ '2' +iAdding);
	iform3 = document.getElementById(iform+ '3' +iAdding);
	iform4 = document.getElementById(iform+ '4' +iAdding);
	iform5 = document.getElementById(iform+ '5' +iAdding);
	
	iform1[0].style.background = 'url('+i1src+')';
	idiv0.innerHTML = 'Mala';
	
	if(num > 1){
		iform2[0].style.background = 'url('+i1src+')';
		idiv0.innerHTML = 'Regular';
	}else{
		iform2[0].style.background = 'url(img/star_off.png)';
	}
	if(num > 2){
		iform3[0].style.background = 'url('+i1src+')';
		idiv0.innerHTML = 'Buena';
	}else{
		iform3[0].style.background = 'url(img/star_off.png)';
	}
	if(num > 3){
		iform4[0].style.background = 'url('+i1src+')';
		idiv0.innerHTML = 'Excelente';
	}else{
		iform4[0].style.background = 'url(img/star_off.png)';
	}
	if(num > 4){
		iform5[0].style.background = 'url(img/star5.png)';
		idiv0.innerHTML = 'Célebre';
	}else{
		iform5[0].style.background = 'url(img/star_off5.png)';
	}
}
function votacion_onOut(iform,iAdding,num,textDefoult){
	idiv0  = document.getElementById(iform+ '0' +iAdding);
	iform1 = document.getElementById(iform+ '1' +iAdding);
	idiv0.innerHTML = textDefoult;
	if(num < 0.5){
		iform1[0].style.background = 'url(img/star_off.png)';
	}else if(num >= 1){
		iform1[0].style.background = 'url(img/star.png)';
	}else{
		iform1[0].style.background = 'url(img/star_media.png)';
	}

	iform2 = document.getElementById(iform+ '2' +iAdding);
	if(num < 1.5){
		iform2[0].style.background = 'url(img/star_off.png)';
	}else if(num >= 2){
		iform2[0].style.background = 'url(img/star.png)';
	}else{
		iform2[0].style.background = 'url(img/star_media.png)';
	}
	
	iform3 = document.getElementById(iform+ '3' +iAdding);
	if(num < 2.5){
		iform3[0].style.background = 'url(img/star_off.png)';
	}else if(num >= 3){
		iform3[0].style.background = 'url(img/star.png)';
	}else{
		iform3[0].style.background = 'url(img/star_media.png)';
	}
	
	iform4 = document.getElementById(iform+ '4' +iAdding);
	if(num < 3.5){
		iform4[0].style.background = 'url(img/star_off.png)';
	}else if(num >= 4){
		iform4[0].style.background = 'url(img/star.png)';
	}else{
		iform4[0].style.background = 'url(img/star_media.png)';
	}
	
	iform5 = document.getElementById(iform+ '5' +iAdding);
	if(num < 4.5){
		iform5[0].style.background = 'url(img/star_off5.png)';
	}else if(num >= 5){
		iform5[0].style.background = 'url(img/star5.png)';
	}else{
		iform5[0].style.background = 'url(img/star_media.png)';
	}
	
}

function mostrar_mensaje(nombreCapa){ 
	document.getElementById(nombreCapa).style.display="block";
} 
function ocultar_mensaje(nombreCapa){
	document.getElementById(nombreCapa).style.display="none";
}

function change_background(div, color){
	esteDiv						= document.getElementById(div);
	esteDiv.style.background	= color;
}

function vaciar_div(div){
	Ndiv = document.getElementById(div);
	Ndiv.style.display="none";
}

function open_win(folder){
	window.location = "http://www.frasess.com.ar/" + folder;
}
