var xmlHttp;
/*JavaScript*/

function GetXmlHttpObject(){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

/*Functions*/

function hidePopUp(){
	$("#delMensaje").fadeOut("fast");
}

function deleteMensaje(mensId, artId, menuId){
	 xmlHttp=GetXmlHttpObject();
	 var url = "ajax/for_libro.php?sendID=" + mensId;
	 xmlHttp.onreadystatechange=stateChangedTemp;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
}

function stateChangedTemp(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

		var bringcode = xmlHttp.responseText;
		$("#delMensaje").fadeIn("fast");
		document.getElementById("delMensaje").innerHTML=bringcode;

	}
}

function hidePopUp1(){
	$("#delVideo").fadeOut("fast");
}

function deleteVideo(vidId, artId, menuId){
	 xmlHttp=GetXmlHttpObject();
	 var url = "ajax/for_videos.php?sendID=" + vidId + "&art=" + artId + "&men=" + menuId;
	 xmlHttp.onreadystatechange=stateChangedTemp1;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
}

function stateChangedTemp1(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

		var bringcode = xmlHttp.responseText;
		$("#delVideo").fadeIn("fast");
		document.getElementById("delVideo").innerHTML=bringcode;

	}
}

function hidePopUp2(){
	$("#addComments").fadeOut("fast");
}

function addComments(){
	 xmlHttp=GetXmlHttpObject();
	 var url = "ajax/for_shopping.php";
	 xmlHttp.onreadystatechange=stateChangedTemp2;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
}

function stateChangedTemp2(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

		var bringcode = xmlHttp.responseText;
		$("#addComments").fadeIn("fast");
		document.getElementById("addComments").innerHTML=bringcode;

	}
}

function showPic(pid, type){
	 xmlHttp=GetXmlHttpObject();
	 var url = "ajax/showpic.php?pid=" + pid + "&type=" + type;
	 xmlHttp.onreadystatechange=stateChangedpic;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
}

function stateChangedpic(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

		var bringcode = xmlHttp.responseText;

		$("#backBlack").fadeIn("fast");
		$("#showPicBox").fadeIn("fast");		
		document.getElementById('innerDetailPopUp').innerHTML = bringcode;

	}
}

function hidePopUpForm(rel){
	$("#backBlack").fadeOut("fast");
	$("#" + rel).fadeOut("fast");
}

function hidePopUp3(){
	$("#consulta").fadeOut("fast");
}

function consulta(pid){
	 xmlHttp=GetXmlHttpObject();
	 var url = "ajax/for_consulta.php?pid=" + pid;
	 xmlHttp.onreadystatechange=stateChangedTemp3;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
}

function stateChangedTemp3(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

		var bringcode = xmlHttp.responseText;
		$("#consulta").fadeIn("fast");
		document.getElementById("consulta").innerHTML=bringcode;

	}
}

function swapButtons(id, type){
	if(type == 0){
		document.getElementById(id).src = "graficos/botones/c_" + id + ".jpg";
	}else{
		if(id == "comen"){
			document.getElementById(id).src = "graficos/botones/" + id + ".png";
		} else {
			document.getElementById(id).src = "graficos/botones/" + id + ".jpg";
		}
	}
}

