
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 Mmm(ajax)
{
	alert(ajax.status);
}

function mailExists2(mail)
	{
		var mail = mail;
		ajax = nuevoAjax();
		ajax.open( "GET", "../../trashcode/core/response_mail.php?mail="+mail, true );
		ajax.onreadystatechange = function()
			{
			if (ajax.readyState==1)
				{
				document.getElementById('mail').value = 'testing...';
				}
			if ( ajax.readyState == 4 )
				{
				alert('read');
				if( ajax.responseXML.documentElement == null )
					{
					var doc = new ActiveXObject("Msxml2.DOMDocument.4.0");
					doc.async = false;
					doc.loadXML( ajax.responseText );
					}
				else
					{
					var doc = ajax.responseXML;
					}
				var mailAux = doc.getElementsByTagName('response')[0].firstChild.data;
				ajax.send(null);
				alert(mailAux);
				return mailAux;
				}
			}
	}


function mail_exists(mail)
{
	var mail = mail;
	var mailAux = 0;
	var hiddenSum =	document.getElementById('c3');
	if ( mail != "" )
		{
		ajax = nuevoAjax();
		ajax.open( "GET", "../../trashcode/core/response_mail.php?mail="+mail, true );
		ajax.onreadystatechange = function()
			{
			if (ajax.readyState==1)
				{
				document.getElementById('mail').value = 'Cargando...';
				}
			if ( ajax.readyState == 4 )
				{
				document.getElementById('mail').value = mail;				
				if( ajax.responseXML.documentElement == null )
					{
					var doc = new ActiveXObject("Msxml2.DOMDocument.4.0");
					doc.async = false;
					doc.loadXML( ajax.responseText );
					}
				else
					{
					var doc = ajax.responseXML;
					}
					var mailAux = ajax.responseText;
					if( doc.getElementsByTagName('response')[0].firstChild.data == 1 )
					{
					document.getElementById('mail').style['border'] = '1px solid #AE000C';	
					document.getElementById('mail').value = 'Email existente';	
					hiddenSum.value = 0;
					//mailAux = 1;	
					}
					else
					{
					document.getElementById('mail').style['border'] = '1px solid #CCCCCC';	
					hiddenSum.value = 1;	
					//mailAux = 0;
					}
					//return mailAux == 1?true:false;					
				}
			}	
			ajax.send(null);
			return false;
		}
}

function viewSDates ( naMe, len, msg, hiddenSum )
	{
	if ( naMe != '' )
		{
		var name = document.getElementById(naMe);	
		var len = len;
		var msg = msg;
		var hiddenSum =	document.getElementById(hiddenSum);
		name.value = name.value == msg?'':name.value;
		
		if ( name.value.length > len )
			{
				name.style['border'] = '1px solid #CCCCCC';
				hiddenSum.value = 1;
			}
		else
			{
				name.style['border'] = '1px solid #AE000C';			
				hiddenSum.value = 0;
				name.value = msg;
			}
		}
	}



		function numbersEstrict(e)
		{
			var key = window.event ? e.keyCode : e.which;
			var keychar = String.fromCharCode(key);
			reg = /[\t0-9]/;
			if (key==0 || key==8 || key==32 || key==40 || key==41 || key==46 || key==44 )
			{
				return true;
			}
			else
				{
					return reg.test(keychar);
				}
			}

			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;
				}


