function sendFormUser($opt , $inputHidden, $optDoc)
{
	var $option = $opt, $form = document.getElementsByTagName("form")[0], $input = document.getElementById('' + $inputHidden + '');
	if ( $input.value = $opt )
	{
		if ($optDoc)
		{
			document.getElementsByTagName("form")['f1']['usserOpt'].value = 2;
			document.getElementsByTagName("form")['fintra']['usserOpt'].value = 2;
		}
		document.getElementById('selAux').value = 0;
		$form.action = window.location.protocol + '//' + window.location.host + '/rdr.php' ;
		$form.submit();
	}
}

function sendFormUser2($opt , $inputHidden)
{
	var $option = $opt, $form = document.getElementsByTagName("form")['f1'], $input = document.getElementsByTagName("form")['f1']['' + $inputHidden + ''];
	if ( $input.value = $opt )
	{
		document.getElementsByTagName("form")['f1']['sel'].value = 0;
		$form.action = window.location.protocol + '//' + window.location.host + '/rdr.php' ;
		return true;
	}
	return false;
}

function testIntro(e,form)
{
	var key = window.event ? e.keyCode : e.which;
	if(key == 13)
	{
		document.getElementById('like').value = document.getElementById('userApi').value;
		document.getElementById('pob').value = document.getElementById('pobAux').value;
		document.getElementById('f1').submit();
	}
	return true;
}

function resources()
{
	//document.getElementById('like').value = document.getElementById('userApi').value;
	//document.getElementById('pob').value = document.getElementById('pobAux').value;
	document.getElementById('rec_id').value = 0;
	document.getElementById('f1').submit();
}

function testIntro2(e,form)
{
	var key = window.event ? e.keyCode : e.which;
	if(key == 13)
	{
		document.getElementById(form).submit();
	}
	return true;
}

function pressEnter(e,form)
{
	var key = window.event ? e.keyCode : e.which;
	if(key == 13)
	{
		document.getElementById(form).submit();
	}
	return true;
}

function init()
{
	document.getElementById('lang1').onclick = function(){
		document.getElementById('idiomaCh').value = 'es' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang2').onclick = function(){
		document.getElementById('idiomaCh').value = 'es' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang3').onclick = function(){
		document.getElementById('idiomaCh').value = 'es' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang4').onclick = function(){
		document.getElementById('idiomaCh').value = 'cn' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang5').onclick = function(){
		document.getElementById('idiomaCh').value = 'de' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang6').onclick = function(){
		document.getElementById('idiomaCh').value = 'fr' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang7').onclick = function(){
		document.getElementById('idiomaCh').value = 'uk' ;document.getElementById('f1').submit();
	}
	document.getElementById('lang8').onclick = function(){
		document.getElementById('idiomaCh').value = 'es' ;document.getElementById('f1').submit();
	}
}

function view_date( msg1, msg2, msg3, msg4 )
{
	var msg1 = msg1; var msg2 = msg2; var msg3 = msg3; var msg4 = msg4;
	if ( !document.formDates.nombre.value == "" && document.formDates.nombre.value.length > '2'  )
	{
		if ( document.formDates.pais.selectedIndex > 0  )
		{
			if ( !document.formDates.nick.value == "" && document.formDates.nick.value.length > '5'  )
			{
				if ( !document.formDates.clave.value == "" && document.formDates.clave.value.length > '5')
				{
					return true;
				}else{ alert(msg1); };
				}else{ alert(msg2); };
				}else{ alert(msg3); };
				}else{ alert(msg4); };
					return false;
				};

				function view_dateDoc( msg1, msg2, msg3, aux )
				{
					var msg1 = msg1; var msg2 = msg2; var msg3 = msg3;var aux = aux;
					if ( document.fdocs.titulo.value.length > 1  )
					{
						if ( document.fdocs.resumen.value.length > 5  )
						{
							if ( aux == '0' )
							{
								if ( !document.fdocs.doc.value == ''  )
								{
									return true;
								}else{ alert(msg3); };
								}else return true;
							}else{ alert(msg2); };
							}else{ alert(msg1); };
								return false;
							};

							function nuevoAjax()
							{
								var xmlhttp=false;
								try
								{
									xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
								}
								catch(e)
								{
									try
									{
										xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
									}
									catch(E) { xmlhttp=false; }
								}
								if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }
								return xmlhttp;
							}

							function VerificarMail(strMail)
							{
								var patMail = /^(.+)@(.+)$/;
								var patUser = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)*$/;
								var patDomainIP = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
								var patDomain = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)+$/;
								var matchArray = strMail.match(patMail);
								if(matchArray == null)
								{
									return false;
								}
								var user = new String(matchArray[1]);
								var domain = new String(matchArray[2]);
								if(user.match(patUser) == null)
								{
									return false;
								}

								var IPArray = domain.match(patDomainIP);
								if(IPArray != null)
								{
									for (var i=1;i<=4;i++)
									{
										if(IPArray[i]>255)
										{
											return false;
										}
									}
									return true;
								}

								var domainArray = domain.match(patDomain);
								if(domainArray == null)
								{
									return false;
								}
								if(domainArray[domainArray.length - 1].length < 3 || domainArray[domainArray.length - 1].length > 4)
								{
									return false;
								}

								return true;
							}

							function abreventana(url, name, w, h, perc, scrolli)
							{
								var winX = (screen.availWidth - w)*perc*0.1;
								var winY = (screen.availHeight - h)*perc*0.1;
								if(w==0)
								{
									w=	screen.availWidth;
								}
								if(h==0)
								{
									h=screen.availHeight	;
								}
								var popupWin = window.open(url, name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scrolli+',resizable=0,width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
								return popupWin;
							}


							function controlForm(obj,texto)
							{
								if(obj.value==texto)
								obj.value='';
							}




							function resizeWindow(w,h)
							{
								if (document.all || document.getElementById)
								{
									window.resizeTo(w,h);
								}
								else if (document.layers||document.getElementById)
								{
									if (window.outerHeight<screen.availHeight|| window.outerWidth<screen.availWidth)
									{
										window.innerHeight =h;
										window.innerWidth = w;
									}
								}
							}

							function getURLParam(strParamName){
								var strReturn = "";
								var strHref = window.location.href;
								if(strHref.indexOf("?")>-1){
									var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
									var aQueryString = strQueryString.split("&");
									for (var i=0;i<aQueryString.length;i++){
										if (aQueryString[i].indexOf(strParamName + "=")>-1){
											var aParam = aQueryString[i].split("=");
											strReturn = aParam[1];
											break;
										}
									}
								}
								return strReturn;
							}
							function validar_permisos(obj)
							{
								var valor;
								valor=obj.value;
								if (valor==-1)
								{
									window.alert("Sección restringida por permisos");
									obj.selectedIndex=0;
								}
							}

var Base64b = {
 
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64b._utf8_encode(input);
 
		while (i < input.length) {
 
			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 +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._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);
			}
 
		}
 
		output = Base64b._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	} 
}



							function testF()
							{

								if(document.getElementById('f1'))
								{
									if(document.getElementById('masinfo')||document.getElementById('resumen'))
									{
										document.getElementById('f1').onsubmit = function()
										{
											if(document.getElementById('f').value == 1 || document.getElementById('f').value == 2 )
											{
												if(document.getElementById('masinfo'))
												{
													document.getElementById('masinfo').value = Base64b.encode(document.getElementById('masinfo').value);
												}
												if(document.getElementById('resumen'))
												{
													document.getElementById('resumen').value = Base64b.encode(document.getElementById('resumen').value);
												}
											}
											return true;
										}


									}

								}
							}


							window.onload=testF;
