function menu_open_close(submenu) {
	if (submenu.nextSibling.style.display=='none') {
		$(submenu.nextSibling).slideToggle(100);
		submenu.className='menu_expand';
	}
	else {
		submenu.className='menu_collapse';
		$(submenu.nextSibling).slideToggle(100);		
	}
}

function show_img(image,url_embed)
{
var divTag = document.createElement("div");
divTag.id = "shadow";
divTag.style.opacity=0;

var isIE = /*@cc_on!@*/false;
if (isIE){
	 divTag.style.position ="absolute";
	 divTag.style.top=document.body.scrollTop;
	 }
else{
	 divTag.style.position ="fixed";
	 divTag.style.top="0";
	 }
 
divTag.style.width = "100%";
divTag.style.height = "100%";
divTag.style.left = "0";
divTag.innerHTML="<p class='image_close' onclick='img_close()'>[ Exit ]</p>";
document.body.appendChild(divTag);

$("#shadow").fadeTo("fast","0.8");

var divTag = document.createElement("div");
divTag.id = "imagen_content";
divTag.onclick=img_close;		

if (isIE)
	 {
	 divTag.style.position = "absolute";
	 divTag.style.top=document.body.scrollTop+50;
	 }
else
	 {
	 divTag.style.position = "fixed";

	 if (!url_embed)	 
	 		divTag.style.top="50%";
	 else
	 		divTag.style.top="25";
						
	 divTag.style.display="none";	 
	 }

if (!url_embed)	 
	 divTag.style.left="50%";
	 
if (url_embed)
	 {
	 divTag.style.width = "100%";
	 divTag.style.left = "0";
	 }
	 
document.body.appendChild(divTag);

if (!url_embed)
	 divTag.innerHTML = "<img id='img_big' onload='img_center()' class='image_big' onclick='img_close()' src='"+image+"'>";
else
	 {	 
	 	$.ajax({
						url: url_embed,success:
						function(datos)
								{
								divTag.innerHTML=datos;
								$("#imagen_content").fadeIn("fast");
								}
						});
	 }	 
	 
 
}

function img_center()
        {
        img_width=document.getElementById("img_big").width;
        img_height=document.getElementById("img_big").height;
        document.getElementById("imagen_content").style.marginLeft=img_width/-2;
        var isIE = /*@cc_on!@*/false;
        if (!isIE)
        document.getElementById("imagen_content").style.marginTop=img_height/-2;
        $("#imagen_content").fadeIn("fast");
        }

function img_close()
				 {
				 document.body.removeChild(document.getElementById("shadow"));
				 document.body.removeChild(document.getElementById("imagen_content"));
				 }
				 
function date_validate(field) {
	fecha=field.value;
	campo=field.name;
	var error_msg='';
	var formato=/^\d{2}\-\d{2}\-\d{4}$/
	if (!formato.test(fecha))
		error_msg="Formato de fecha no válido (dd-mm-yyyy).";
	else {
		var dayfield=fecha.split("-")[0]
		var monthfield=fecha.split("-")[1]
		var yearfield=fecha.split("-")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
			error_msg="Fecha incorrecta.";
	}

	if (error_msg!='') {
		$("#"+campo+"_info").fadeOut("normal");		
		document.getElementById(campo+"_info").innerHTML=error_msg;
		$("#"+campo+"_info").fadeIn("normal");
	}
	else
		$("#"+campo+"_info").fadeOut("normal");
}

// jqueryUI
	$(function() {
		$(".datepicker").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-mm-yy',
			showOn: 'button',
			buttonImage: 'http://gt.dieyes.com/basic/gt/images/calendar.gif', buttonImageOnly: true
		});
	});				 