﻿//<?

function toogle(id) {
	var $eElement = $(id);
	$eElement.style.display = ($eElement.style.display != "none" ? "none" : "" );
}

function loadDoc($sType, $nId) {
	var $sURL = null;
	switch($sType.toUpperCase()) {
		case "FER":
			$sURL = "feria.html?ndoc="+$nId;
			break;
	}
	
	if($sURL) {
		$().ajax.send({url:$sURL, after:function($sHTML) {
			$("content").innerHTML = $sHTML;
		}});
	}
}


function validate($sForm) {
	var $aExamples = {};
	$aExamples["email"] = "info@sudominio.com";
	$aExamples["user"] 	= "exporter, cater";
	$aExamples["day"] 	= "29";
	$aExamples["month"] = "03";
	$aExamples["year"] 	= "1983";

	var $sMessage = "";
	var $aChk = $().form.validate($sForm, "#FFFF99");
	
	if($aChk==true) {
		document.forms[$sForm].submit();
	} else {
		for(var $x in $aChk) {
			var $eField = $aChk[$x];
			if($eField.checks!=true) {
				$sMessage += "<b>"+$x+"</b>:<br />";
				var $aChecks = $eField.checks
				if($aChecks.distinct) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; debe ser diferente de <i>"+$aChecks.distinct+"</i><br />";
				}

				if($aChecks.minlength) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; mínimo "+$aChecks.minlength+" caracteres<br />";
				}

				if($aChecks.maxlength) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; máximo "+$aChecks.maxlength+" caracteres<br />";
				}

				if($aChecks.lessthan) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; debe ser menor a "+$aChecks.lessthan+"<br />";
				}

				if($aChecks.greaterthan) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; debe ser mayor a "+$aChecks.greaterthan+"<br />";
				}

				if($aChecks.datatype) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; tipo de dato incorrecto<br />";
					$sMessage += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>ej</b>: "+$aExamples[$eField.id]+"<br />";
				}
				
				if($aChecks.docheck) {
					$sMessage += "&nbsp;&nbsp;-&nbsp; debe seleccionar una opción<br />";
				}

				$sMessage += "<br />";
			}
		}
		
		var $sAlert  = "";
		$sAlert 	+= "<table bgcolor='#FFFFFF' width='350' border='0' cellspacing='0' cellpadding='0'>";
		$sAlert 	+= "	<tr>";
		$sAlert 	+= "		<td style='padding:20px'>";
		$sAlert 	+= "			<h3 style='padding-left:0px;color:#FF0000'>Error en los Datos</h3><br />";
		$sAlert 	+= 				$sMessage
		$sAlert		+= "			<div style='text-align:center'><input type='button' value='aceptar' onclick='$().fx.modal({close:true})' class='btn' /></div>";
		$sAlert		+= "		</td>";
		$sAlert 	+= "	</tr>";
		$sAlert 	+= "</table>";

		$().fx.modal({
			id			: "error",
			mode		: "FIXED",
			overlay		: {color:"#333336"},
			content		: $sAlert,
			autosize	: true
		});
	}
}


function validateField($eField) {
	var $aChecks = $eField.checks
	if($aChecks!=true) {
		$sMessage = "<span style='font-size:7pt;color:#FF0000'>";
		if($aChecks.distinct) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; debe ser diferente de <i>"+$aChecks.distinct+"</i><br />";
		}

		if($aChecks.minlength) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; mínimo "+$aChecks.minlength+" caracteres<br />";
		}

		if($aChecks.maxlength) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; máximo "+$aChecks.maxlength+" caracteres<br />";
		}

		if($aChecks.lessthan) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; debe ser menor a "+$aChecks.lessthan+"<br />";
		}

		if($aChecks.greaterthan) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; debe ser mayor a "+$aChecks.greaterthan+"<br />";
		}

		if($aChecks.datatype) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; tipo de dato incorrecto<br />";
		}
		
		if($aChecks.docheck) {
			$sMessage += "&nbsp;&nbsp;-&nbsp; debe seleccionar una opción<br />";
		}
		
		$sMessage += "</span>";
	} else {
		$sMessage = "";
	}
	
	if($($eField.id+"_err")) {
		$($eField.id+"_err").innerHTML = $sMessage;
	}
}


function modal($sTxt, $nWidth, $nHeight) {
	if(!$().is($nWidth)){
		$nWidth=790;
	}
	if(!$().is($nHeight)){
		$nHeight=560;
	}

	var $sMessage	 = "";
	$sMessage 		+= "<table width='"+($nWidth)+"' height='"+($nHeight+40)+"' border='0' cellspacing='0' cellpadding='0'>";
	$sMessage 		+= "	<tr>";
	$sMessage 		+= "		<td style='padding:0px'>";
	$sMessage		+= "			<div style='width:"+($nWidth)+"px; text-align:right; margin:0px 20px 10px 0; cursor: pointer; '><img src='www/theme/images/close-icon.png' onclick='$().fx.modal({close:true})' alt='cerrar'></div>";
	$sMessage 		+= "			<div style='float:right; overflow:auto;width:"+($nWidth)+"px;height:"+($nHeight)+"px;'>"+$sTxt+"</div>";
	$sMessage		+= "		<br style='clear:both; margin: 0; padding: 0; display:inline;'/>";
	$sMessage		+= "		</td>";
	$sMessage 		+= "	</tr>";
	$sMessage 		+= "</table>";

	$().fx.modal({
		id			: "modal",
		mode		: "FIXED",
		overlay		: {color:"#000000"},
		content		: $sMessage,
		autosize	: false
	});
}


function getConvo($sType, $nId) {
	$().fx.modaljx({
		id			: "modal",
		mode		: "FIXED",
		overlay		: {color:"#333336"},
		url			: "/convocatoria.html?stype="+$sType+"&ndoc="+$nId,
		autosize	: true
	});
}

function getInforme($sType, $nId) {
	$().fx.modaljx({
		id			: "modal",
		mode		: "FIXED",
		overlay		: {color:"#333336"},
		url			: "/informe.html?stype="+$sType+"&ndoc="+$nId,
		autosize	: true
	});
}


function openNews(sDocId, sDocName) {
	//modal("<iframe src='http://www.issuu.com/exportar/docs/"+sNews+"' width='770' height='470' scrolling='no'></iframe>",780,550);
	modal('<div><object style="width:781px;height:550px" ><param name="movie" value="http://static.issuu.com/webembed/viewers/style1/v1/IssuuViewer.swf?mode=embed&amp;layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Flight%2Flayout.xml&amp;showFlipBtn=true&amp;documentId='+sDocId+'&amp;docName='+sDocName+'&amp;username=exportar&amp;loadingInfoText=ExportAr%20News&amp;et=1311852639274&amp;er=81" /><param name="allowfullscreen" value="true"/><param name="menu" value="false"/><embed src="http://static.issuu.com/webembed/viewers/style1/v1/IssuuViewer.swf" type="application/x-shockwave-flash" allowfullscreen="true" menu="false" style="width:781px;height:550px" flashvars="mode=embed&amp;layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Flight%2Flayout.xml&amp;showFlipBtn=true&amp;documentId='+sDocId+'&amp;docName='+sDocName+'&amp;username=exportar&amp;loadingInfoText=ExportAr%20News&amp;et=1311852639274&amp;er=81" /></object></div>');
}

function openCalendar() {
	modal("<iframe src='https://www.google.com/calendar/embed?src=calendario.exportar%40gmail.com&ctz=America/Argentina/Buenos_Aires ' style=' border-width:0 ' width='700' height='450' frameborder='0' scrolling='no'></iframe>", 750, 500);
	//modal('<div><object style="width:781px;height:550px" ><param name="movie" value="http://static.issuu.com/webembed/viewers/style1/v1/IssuuViewer.swf?mode=embed&amp;layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Flight%2Flayout.xml&amp;showFlipBtn=true&amp;documentId='+sDocId+'d&amp;docName='+sDocName+'&amp;username=exportar&amp;loadingInfoText=ExportAr%20News&amp;et=1311852639274&amp;er=81" /><param name="allowfullscreen" value="true"/><param name="menu" value="false"/><embed src="http://static.issuu.com/webembed/viewers/style1/v1/IssuuViewer.swf" type="application/x-shockwave-flash" allowfullscreen="true" menu="false" style="width:781px;height:550px" flashvars="mode=embed&amp;layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Flight%2Flayout.xml&amp;showFlipBtn=true&amp;documentId='+sDocId+'&amp;docName='+sDocName+'&amp;username=exportar&amp;loadingInfoText=ExportAr%20News&amp;et=1311852639274&amp;er=81" /></object></div>');	
}
