var globalCallbacks = {
	onCreate: function(){ Loading(true, 1) },
	onComplete : function(){ Loading(false, Ajax.activeRequestCount) }
}
function Loading(status, activeRequestCount)
{
	if(status)
		$('loadOn').style.display = 'block';
	else
	{
		if (activeRequestCount == 0)
			$('loadOn').style.display = 'none';	
	}
}
//////////////////////////////////////////////////////////////////////////////////
window.onerror=function(){return true}
var timeform;
function setContent(container, page, params, method, asyn)
{
	//analytics
	if(!arguments[5])
	{
		var pages = params.split('&');
		var pages_1 = pages[0].split('=');
		if(pages[1]){ var pages_2 = pages[1].split('=');
		var analytics = '/'+pages_1[1]+'/'+pages_2[1]; }
		else var analytics = '/'+pages_1[1];
	}
	else var analytics = '/'+arguments[5];

	try {
	pageTracker._trackPageview(analytics);
	} catch(err) {}
	
	
	try {
		if(page != 'axmodulos.php' && container == 'c_cuerpo')
			dhtmlHistory.add(params,container+"|"+page+"|"+method+"|"+asyn);
	} catch(err) {}

	new Ajax.Updater(container, page, {asynchronous:asyn, parameters:params, method:method, onFailure:setError, evalScripts: true});
}
function irOpcion(container, params)
{
	if(arguments[2])
		setContent(container, 'axpage.php', params, 'get', true, arguments[2]);
	else
		setContent(container, 'axpage.php', params, 'get', true);
	//selMenu(arguments[2]);
}
function selMenu(opc)
{
	var arropc = new Array('quienes');
	var arropcclass = new Array('mn_quienes_off.jpg','mn2','mn3','mn4');
	for(var i=0; i<arropc.length; i++)
		$(arropc[i]).src = "images/menu2/"+arropcclass[i];
	if(opc)
		$(opc).src = "images/menu2/mn_"+opc+"_on.jpg";
}
function formCallback(result, form)
{
	var c_status = form.name+'_estado';
	var c_cuerpo = form.name+'_cuerpo';
	if($(c_status)) var boolStatus = true;
	else var boolStatus = false;
	if(!result)
	{
		if(boolStatus == true){
			new Effect.Appear(c_status);
			$(c_status).innerHTML = 'Hay campos obligatorios sin llenar';
			$(c_status).className = 'validation-advice';
			clearTimeout(timeform);
			timeform = setTimeout("new Effect.Fade('"+c_status+"')",5000);
		}
	}
	else
	{		
		if(boolStatus == true){
			new Effect.Appear(c_status);
			$(c_status).innerHTML = 'La información está siendo enviada...';
			$(c_status).className = 'custom-advice';
			window.status = "La información está siendo enviada...";
		}
		if($('submit')) new Element.hide('submit');
		enviarFormulario(form,$F(c_cuerpo));
	}
}
function formCallbackMaestros(result, form)
{
	if(!result)
	{
		new Effect.Appear('c_maestro_datos');
		$('c_maestro_datos').innerHTML = 'Hay campos obligatorios sin llenar';
		$('c_maestro_datos').className = 'validation-advice';
	}
	else
	{
		new Effect.Appear('c_maestro_datos');
		$('c_maestro_datos').innerHTML = 'Los datos han sido validados, el formulario se guardara correctamente';
		$('c_maestro_datos').className = 'custom-advice';
		window.status = "Los datos han sido validados, el formulario se guardara correctamente";
		enviarFormulario(form,'ax_panel');
	}	
}
function enviarFormulario(form,capa)
{
	if(arguments[2]) var method = arguments[2];
	else var method = form.method;
	var params = Form.serialize($(form));
	var action = $(form).action;
	new Ajax.Updater(capa, action, {asynchronous:true, parameters:params, method:method, onComplete: setRespuesta, evalScripts: true});
}
function setError(resp)
{
	//resp.responseText o resp.responseXML
	alert("Oops, Ha ocurrido en un error.");
}
function setRespuesta(resp)
{
	//resp.responseText o resp.responseXML
}
function chmenu(tipo, obj)
{
	obj.className = 'text_menu_'+tipo;
}
function enlace(url)
{
		alert('s');
	//document.location.href = url;
}
function showObjArray(vecCapa,boolean)
{
	for(i=0; i<vecCapa.length; i++)
	{			
		objC=document.getElementById(vecCapa[i]);
		if(boolean == true)
			objC.style.display='';
		else
			objC.style.display = 'none'
	}
}
function showObjArrayEfecto(enlace,vecCapa,obj)
{
	var bgcolor = "#C4C4C4";
	for(i=0; i<vecCapa.length; i++)
	{	
		objC=document.getElementById(vecCapa[i]);	
		if(objC.length > 0)
		{
			for(x=0; x<objC.length; x++)
				objC[x].style.display = 'none'
		}
		else
			objC.style.display = 'none';
		document.getElementById(enlace+vecCapa[i]).src = 'images/principal2/'+enlace+vecCapa[i]+'Off.gif';
	}
	objN = document.getElementById(obj);
	objN.style.display='';
	document.getElementById(enlace+obj).src = 'images/principal2/'+enlace+obj+'On.gif';
}
function showObj(obj)
{
	if(obj != '[object]')
		obj = document.getElementById(obj);
	if(obj.style.display == 'none')
		obj.style.display='';
	else
		obj.style.display='none';
}
function showObjTrue(obj,boolean)
{
	if(obj != '[object]')
		obj = document.getElementById(obj);
	if(boolean == true)
		obj.style.display='';
	else
		obj.style.display='none';
}
function traerDisplay(obj)
{
	if(obj != '[object]')
		obj = document.getElementById(obj);
	if(obj.style.display == '')
		return true;
	if(obj.style.display == 'none')
		return false;
}
function ms_delete()
{
    return agree = confirm('¿Desea eliminar el registro?');
}
function retirarMenu(div_menu){
   if (document.getElementById(div_menu).style.visibility=="visible")
      document.getElementById(div_menu).style.visibility="hidden";
}
function mostrarMenu(div_menu, upd, del, view, act, inact, varupdate, varview, vardelete, varincativar)
{
   var valores = "";
   var id = 0;
   var eveover = " onMouseOver='menuOver(this, 1);' ";
   var eveout = " onMouseOut='menuOver(this ,0);' ";
   var tabla = "<table style='border:1px solid #999999' width=150 border=0 cellpadding=2 cellspacing=0>"+
   "<tr>"+
    "<td width=70% class='encabezado'>&nbsp;<font size='1'><b>Acciones</b></td>"+
    "<td width=30% class='encabezado' style='cursor:pointer;'><font size='1' onclick='retirarMenu(\""+div_menu+"\")'>"+
   		"<b>Cerrar</b>"+
    "</td>"+
   "</tr>"+
   "<tr>"+
   	"<td colspan=2>"+
		"<table width='100%' border='0' cellpadding='2' cellspacing='0'>";
		if(varupdate == 1) {
		  tabla += "<tr "+eveover+eveout+">"+
			'<td valign="top" onClick="retirarMenu(\''+div_menu+'\');'+upd+';"><font size="1" face="verdana,arial,helvetica" color="black">'+
         		"Modificar"+
			 "</font></td>"+
		  "</tr>";
		}
		if(varview == 1) {		
		  tabla += "<tr "+eveover+eveout+">"+
			'<td valign="top" onClick="retirarMenu(\''+div_menu+'\');'+view+';"><font size="1" face="verdana,arial,helvetica" color="black">'+
         		"Consultar"+
			 "</font></td>"+
		  "</tr>";
		}
		if(vardelete == 1) {
		  tabla += "<tr "+eveover+eveout+">"+
			'<td valign="top" onClick="retirarMenu(\''+div_menu+'\');if(ms_delete()) '+del+';"><font size="1" face="verdana,arial,helvetica" color="black">'+
         		"Eliminar"+
			 "</font></td>"+
		  "</tr>";
		}
		if(varincativar == 1)
		{				
			if(act != "")
			{
				tabla += "<tr "+eveover+eveout+">"+
				'<td valign="top" onClick="retirarMenu(\''+div_menu+'\');if(ms_confirmar(\'activar el registro\')) '+act+';"><font size="1" face="verdana,arial,helvetica" color="black">'+
				"Activar"+
				"</font></td>"+
				"</tr>";
			}
			if(inact != "")
			{
				tabla += "<tr "+eveover+eveout+">"+
				'<td valign="top" onClick="retirarMenu(\''+div_menu+'\');if(ms_confirmar(\'inactivar el registro\')) '+inact+';"><font size="1" face="verdana,arial,helvetica" color="black">'+
				"Inactivar"+
				"</font></td>"+
				"</tr>";
			}				
		}		 
		tabla += "</table>"+
	 "</td>"+
	"</tr>"+
	"</table>";
   var textmenu = tabla;
   document.getElementById(div_menu).innerHTML=textmenu;
   if (document.getElementById(div_menu).style.visibility=="hidden")
      document.getElementById(div_menu).style.visibility="visible"
   else
      document.getElementById(div_menu).style.visibility="hidden"
}
function menuOver(ctr,tipo)
{
	if(tipo == 1)
	{
		ctr.style.background = '#efefef';
		ctr.style.color = "#98AD13";
		ctr.style.cursor = "hand";
	}
	else
	{
		ctr.style.background = "#ffffff";		
		ctr.style.color = "#000000";
		ctr.style.cursor = "default";
	}
}
function flupload(upVar,fsProg,btnAdj,btnCan,divSta,id,rand,destino,input,limit,tipo)
{
	if(tipo == 'images'){
		var fileTypes = "*.jpg;*.jpeg;*.png;*.gif";
		var fileDescription = "Archivos de imagen";
	}
	
	if(document.all) //IE
		var up_url = "includes/swfupload/upload.php?destino="+destino+"&randomi="+rand+"&nameAlt=";
	else //FIREFOX
		var up_url = "upload.php?destino="+destino+"&randomi="+rand+"&nameAlt=";
	
	var settings = {
		flash_url : "includes/swfupload/swfupload.swf?RandID="+rand,
		upload_url: up_url,	// Relative to the SWF file
		post_params: {"PHPSESSID" : id},
		file_size_limit : "2 MB",
		file_types : fileTypes,
		file_types_description : fileDescription,
		file_upload_limit : limit,
		file_queue_limit : 1,
		custom_settings : {
			progressTarget : fsProg,
			cancelButtonId : btnCan,
			statusDIV : divSta,
			ruta: destino,
			input_file: input,
			randomi: rand
		},
		debug: false,
	
		// Button settings
		button_image_url: "includes/swfupload/images/TestImageNoText_65x29.png",	// Relative to the Flash file
		button_width: "67",
		button_height: "29",
		button_placeholder_id: btnAdj,
		button_text: '<span class="theFont">Adjuntar</span>',
		button_text_style: ".theFont { font-size:12;font-family:Arial; }",
		button_text_left_padding: 12,
		button_text_top_padding: 3,
		
		// The event handler functions are defined in handlers.js
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete	// Queue plugin event
	};
	eval(upVar+' = new SWFUpload(settings);');
}
function ImprimirCapa(capa, w, h)
{
	var html = $(capa).innerHTML;
   newWindow = window.open("","Imagenes","width="+w+",height="+h+",left=100,top=60,menubar=1,toolbar=1,status=1");
   newWindow.document.open();
   newWindow.document.write('<html><head><link rel="stylesheet" type="text/css" href="css/PDigital_Styles.css"><script src="js/functions.js" type="text/javascript"></script></head><body style="margin:0px;">'+ html +'</body></html>');
   newWindow.document.close();
   newWindow.focus();
   // onload="window.print()"
}
function slideshow(num)
{
	//SLIDE SHOW ---------------------------------------
	var feed  = "http://www.plazadigital.com.co/slideshow_album.php?num="+num;
	var options = {
		displayTime:4000, transistionTime:600, scaleImages:true, fullControlPanel: true
	};
	var ss = new GFslideShow(feed, "slideShow", options);
	//*------------------------------------------------
}
function CambiarImagen(identificador, imagen, width, height, identificador2, imagenbig)
{
	identificador.width = identificador.width;
	identificador.heigth = identificador.height; 
	identificador.src = imagen;
	if(imagenbig != ''){
			identificador2.href = imagenbig;
			$('c_ampliar').style.display='';
	}
	else $('c_ampliar').style.display='none';
}
function toggleEditor(id) {
	if (!tinyMCE.get(id))
	tinyMCE.execCommand('mceAddControl', false, id);
	else
	tinyMCE.execCommand('mceRemoveControl', false, id);
}
function openWindow(url, params, method, w, h, theme) {
    new UI.Window({theme:theme, shadow: true, width:w, height:h, activeOnClick:false }).setAjaxContent(url,{asynchronous:true, parameters:params, method:method, onFailure:setError, evalScripts: true}).center().show();
}
function subir(){
	if( document.documentElement.scrollTop < 10 ){
	   window.scrollTo(0,0);
	}else{
	   window.scrollBy(0,-10);
	   setTimeout("subir()",10);
	}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function guardar_dado()
{
	var nombre = document.getElementById('nombre').value;
	var email = document.getElementById('email').value;
	var telefono = document.getElementById('telefono').value;
	if(nombre == ''){
		alert("Debe llenar el campo 'Nombre'")
		return false;
	}
	if(telefono == ''){
		alert("Debe llenar el campo 'Teléfono'")
		return false;
	}
	if(email == ''){
		alert("Debe llenar el campo 'Correo Electronico'")
		return false;
	}
	else
		return validarEmail(document.getElementById('email'));	
	return true;
}
function validarEmail(control)
{	
	if(control.value != "")
	{
		var chr;
		var arrobas=0;
		var puntos=0;
		var blancos=0;
		
		for (var x=0;x < control.value.length; x++)
		{
			  chr=control.value.substring(x,x+1);
			  if ( (chr=="@") )
					  arrobas=arrobas+1;
			  if ( (chr==".") )
					  puntos=puntos+1;
			  if ( (chr==" ") || (chr=="<")||(chr==">")||(chr==",")||(chr==";")||(chr=="&")||(chr=="$")||(chr=="#")||(chr=="]")||(chr=="["))
					  blancos=blancos+1;
		}
		if ( (blancos!=0) || (arrobas!=1) || (puntos<1))
		{
			alert("La dirección de correo escrita no es correcta. Recuerda que no se adminten espacios en blanco y debe tener el signo @ ");
			return false;
		}
	}
	return true;
}
document.write('<div id="loadOn">Cargando...</div>');