var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
	  chr1 = input.charCodeAt(i++);
	  chr2 = input.charCodeAt(i++);
	  chr3 = input.charCodeAt(i++);

	  enc1 = chr1 >> 2;
	  enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
	  enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
	  enc4 = chr3 & 63;

	  if (isNaN(chr2)) {
		 enc3 = enc4 = 64;
	  } else if (isNaN(chr3)) {
		 enc4 = 64;
	  }

	  output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
		 keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
	  enc1 = keyStr.indexOf(input.charAt(i++));
	  enc2 = keyStr.indexOf(input.charAt(i++));
	  enc3 = keyStr.indexOf(input.charAt(i++));
	  enc4 = keyStr.indexOf(input.charAt(i++));

	  chr1 = (enc1 << 2) | (enc2 >> 4);
	  chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
	  chr3 = ((enc3 & 3) << 6) | enc4;

	  output = output + String.fromCharCode(chr1);

	  if (enc3 != 64) {
		 output = output + String.fromCharCode(chr2);
	  }
	  if (enc4 != 64) {
		 output = output + String.fromCharCode(chr3);
	  }
   } while (i < input.length);

   return output;
}

//termina lo de B64
function MenuOverOut(o, over)
{
	var divs = o.parentNode.parentNode.parentNode.getElementsByTagName('div');
	divs[0].style.background = divs[2].style.background = (over ? '#FFAF37' : '');
}

function getE(id)
{
	return document.getElementById(id);
}

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["ifrSeccion"];

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes";

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.contentDocument && currentfr.contentDocument.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}


function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

function CreateSwfControl(containerId, width, height, src)
{
	var c = document.getElementById(containerId);
	if(c != null)
	{
		var widthStr = '';
		var heightStr = '';
		if(width != '' && width != null)
		{
			widthStr = ' width=' + width + 'px';
		}
		if(height != '' && height != null)
		{
			heightStr = ' height=' + height + 'px';
		}
		c.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + widthStr + heightStr + '"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="src" value="' + src + '"/><param name="quality" value="high"/><embed src="' + src + '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"' + widthStr + heightStr + '"></embed></object>';
	}
}

function d(i) { return document.getElementById(i); }

function anulaVisible(obj) {
	if (obj != null) {
		obj.style.display='none';	
	}
}
function fixHeight()
{
	var dc = d('divContainer');
	var dl = d('divLeft');
	var dr = d('divRight');
	var max = (dl.scrollHeight > dr.scrollHeight) ? dl.scrollHeight : dr.scrollHeight;
	if(dc.scrollHeight < max)
	{
		dc.style.height = dc.scrollHeight + max;
	}
}

function valiDate(source, arguments) 
	{ 
		var ret = false; 
		var ctls=fldsTo.split('|');
		var dia=document.getElementById(ctls[0]);
		var mes=document.getElementById(ctls[1]);
		var ano=document.getElementById(ctls[2]);
		if (dia != null && mes != null && ano != null)
			date=ano.value + '/' + mes.value + '/' + dia.value;
		//var date = arguments.Value; 
		if(date != "" && date != null) 
		{ 
			var parts = date.split('/'); 
			if(parts.length == 3 && !isNaN(parts[0]) && !isNaN(parts[1]) && !isNaN(parts[2])) 
			{ 
				ret = isDate(parts[0], parts[1], parts[2]); 
			} 
		} 
		arguments.IsValid = ret; 
	} 
	 
	function getYear (d) 
	{ 
		return (d < 1000) ? d + 1900 : d; 
	} 
	 
	function isDate (year, month, day) 
	{ 
		// month argument must be in the range 1 - 12 
		month = month - 1;  // javascript month range : 0 - 11 
		var tempDate = new Date(year,month,day); 
		if ( (getYear(tempDate.getYear()) == year) && 
		(month == tempDate.getMonth()) && 
		(day == tempDate.getDate()) ) 
		return true; 
		else 
		return false; 
	}
		
		function findControl(valor) {
			var ctlName=valor.substring(0,valor.length-1);
			ctlName += parseInt(valor.substring(valor.length-1,valor.length)) - 1;
			ctlName=ctlName.replace(/_/g,":");
			ctlName=ctlName.replace(/::/g,":_");
			return document.getElementById(ctlName);		
		}
		function validateAreaEspecial(args,e) {
			var returnValue=true;
			var nameCtl="areaespecial";
			var ctl=document.getElementById(nameCtl);
			if (ctl != null) {
				if (ctl.value.length == 0) {
					returnValue=false;
				}
			}
			e.IsValid = returnValue;
		}
		
		function validateLineaPhone(args,e) {
			var returnValue=true;
			//Declarar aca los controles fijos que se quieran validar
			var ctlsName=new Array('PaisPhone','AreaPhone','PhonePhone');
			for (var i=0;i < ctlsName.length;i++) {
				var obj=document.getElementById(ctlsName[i]);
				if (obj != null) 
					returnValue= !(obj.value.length==0)
				if (!returnValue)
					break;
			}
			e.IsValid = returnValue;
		}
		function validateField(args, e)
		{
			var returnValue=true;
			var ctl=findControl(args.id);
			if (ctl !=null) {
				
				switch(ctl.type) {
					case 'text':
						if (ctl.value.length == 0) {
							returnValue=false;
						}else{
							returnValue=true;
						}
						break;
					case 'radio':
						var i=0;
						var clickeo=false;
						var name=ctl.id.substring(0,ctl.id.length - 1) ;
						var obj=document.getElementById(name  + i);
						while (obj != null && !clickeo) {
							clickeo=obj.checked;
							i++;
							obj=document.getElementById(name + i);
						}					
						returnValue=clickeo;
						break;
					case 'select-one':
						//Alias combo
						if (ctl.selectedIndex == 0) {
							returnValue=false;
						}else{
							returnValue=true;
						}
						break;
					default:
						returnValue=true;
				}
			}
			else
			{
				returnValue=true;
			}
			e.IsValid = returnValue;
		}