// JavaScript Document
function getDateStr() {
				var today = new Date();
				var todayStr = (today.getMonth()+1) + "/" + today.getDate() + "/" + today.getFullYear();;
				document.resform.DateIn.value = todayStr;
			}
			getDateStr();


	function openCalendar(FormElement){
	var calendarwindow;
	url = "calendar.html?formname=resform&formelement=" + FormElement;
	calendarwindow = window.open(url,"calendar","toolbar=no,width=200,height=144,top=50,left=50,status=no,scrollbars=no,resize=no,menubar=no");
	calendarwindow.focus();
	}
function CambiaImagen(sender, idDescripcion,idLink, cin,total)
{
	//alert(sender.name);
	currentimagenum=cin;
	
	//document.getElementById(currentimagenum).src="images/f2.gif";
	var img = document.getElementById("bigImageG");
	var desc = document.getElementById("tdDescripcion");
	var iLink = document.getElementById("tdLink");
	var senderDesc1 = document.getElementById(idLink);
	var senderDesc = document.getElementById(idDescripcion);
	img.src = "uploads/" + sender.name;
	//alert(img.src);	
	desc.innerHTML = senderDesc.value;
	//iLink.innerHTML = senderDesc1.value;
	

	
	//alert(iLink.innerHTML);
}
function CambiaImagen1(Pimagen)
{
	//alert(Pimagen);
	//document.getElementById("bigImageG").src="uploads/colSim.jpg";
	var img1 = document.getElementById("bigImageG");
	img1.src = "uploads/" + Pimagen;
	//alert(img1.src);	
	//iLink.innerHTML = senderDesc1.value;
	//alert(iLink.innerHTML);
}
function CambiaImagenTh(Pimagen)
{
	var img2 = document.getElementById("ImageTh");
	img2.src = "uploads/" + Pimagen;
	//alert(img2.src);	
}

function CambiaImagenBg(Pimagen)
{
	var img3 = document.getElementById("ImageBg");
	img3.src = "uploads/" + Pimagen;
	//alert(img3.src);	
}

function descPaquetes(idTitulo,idDescripcion)
{
	//alert(idDescripcion);
	
	var tit = document.getElementById("tdTitulo");
	var sendertit = document.getElementById(idTitulo);
	var desc = document.getElementById("tdDescripcion");
	var senderDesc = document.getElementById(idDescripcion);
	desc.innerHTML = senderDesc.value;
	tit.innerHTML = sendertit.value;
	
   //alert(desc.innerHTML);
}

function controlaEmail(id)
{
var se;
se = document.getElementById("txtEmailFC").value;

//alert(se);
var valido = false;
var s = document.getElementById(id);
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if(filter.test(s.value)==false)
{
alert("El correo ingresado es incorrecto");
s.style.background = "Yellow";
valido = false;
}
else
    {
       valido = true;
    }
setTimeout("document.getElementById('" + id + "').style.background='#dedede'", 500);
//alert(valido);
return valido;
}
function controlaText(id, aviso)
{
	var s;
	s= document.getElementById(id).value;
	//alert(s);
	var elemento = document.getElementById(id);
	var valido = false;
	if(elemento.value=="")
	{
		elemento.style.background = "Yellow";
		alert("El campo " + aviso + " no puede estar vacio");
		valido = false;
	}
        else
        {
            valido = true;
        }
	setTimeout("document.getElementById('" + id + "').style.background='#ffffff'", 500);
	//alert(valido);
	return valido;
}

function validaTotal()
{
	var msg = false;
        if(controlaText("txtNombre", "Nombre")==true)
            {
			if(controlaText("txtApe", "Apellido")==true)
            	{
              if(controlaEmail("txtEmail")==true)
                    {
						msg = true;
					}
            	}
			}
            if(msg==true)
                {
					//alert(msg);
                    document.frmTest.submit();
                }
}

function validaFC()
{
	var msg1 = false;
        if(controlaText("txtNombreFC", "Nombre")==true)
            {
                if(controlaEmail("txtEmailFC")==true)
                    {
                        if(controlaText("txtFonoFC", "Telefono")==true)
                        {
                            msg1 = true;
                        }   
                    }
            }
            if(msg1==true)
			   {
				   //alert(msg1);
                   document.frmContact.submit();
                }
}
function desplegarContraer(cual,desde) {
var elElemento=document.getElementById(cual);
if(elElemento.className == 'elementoVisible') {
elElemento.className = 'elementoOculto';
desde.className = 'linkContraido';
} else {
elElemento.className = 'elementoVisible';
desde.className = 'linkExpandido';
}
}

function enviaDato(txt)
{
    var url = "CUSScripts.asp";
    var cadenaValores = null;
    cadenaValores = "idGal="  + $(txt);    
    //alert(cadenaValores)
    //envioInfoPOST(url, "tdMsgSug", cadenaValores);
    envioInfo(url + "?" + cadenaValores, "tdMsgSug");
    $("txtSugerencia").value = "";    
    //IWSSugerencias.asp?
    current = 0;
    $("tdMaxText").innerHTML = "Restan 500 caracteres";
}
function switchdiv(tid)
{
ShowHide("plus" + tid);
ShowHide("minus" + tid);
ShowHide("docs" + tid);
ShowHide("minus2" + tid);
}

function ShowHide(elId)
{
if( 'none' == document.getElementById(elId).style.display )
{
document.getElementById(elId).style.display = '';
}
else
{
document.getElementById(elId).style.display = 'none';
}
}

ddaccordion.init({
	headerclass: "mypets", //Shared CSS class name of headers group
	contentclass: "thepet", //Shared CSS class name of contents group
	revealtype: "mouseover", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", "openpet"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
//Initialize 2nd demo:
ddaccordion.init({
	headerclass: "technology", //Shared CSS class name of headers group
	contentclass: "thelanguage", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["closedlanguage", "openlanguage"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix", "<img src='images/der.jpg' /> ", "<img src='images/aba.jpg' /> "], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "slow", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
