/*var/www/neoroot/backend/js*/
// <![CDATA[

	/*
	 * GET parsing.
	 */
	
	var previousDialog = false;
	var asd123asd = 0;
	 var hideDialogs = [];
	 var carlitos = false;
	var estiloDelTemplate = "<style>body { border: 0px; margin: 0px; scrollbar-face-color: #F2F5F9; scrollbar-arrow-color: #A9BBD6; scrollbar-highlight-color: #FFFFFF; scrollbar-3dlight-color: #FFFFFF; scrollbar-shadow-color: #FFFFFF; scrollbar-darkshadow-color: #FFFFFF; scrollbar-track-color: #FFFFFF; font-family: Arial; font-size: 12px; color: #666666;} p { margin:0px;}</style>";
	//var estiloDelTemplate = "<style>body { border: 0px; margin: 0px; font-family: Arial; font-size: 12px; color: #666666;} p { margin:0px;}</style>";
	function openLink(url, target){
			if(target != 'blank'){
				window.location.href = url;
			}else{
				window.open(url,'window','params');
			}
	}
	function QueryString(sQueryString) {
		this.params = new Object();
		
		if(sQueryString) {
			this.QueryString = sQueryString.search.substring(1, sQueryString.search.length);
		} else {
			this.QueryString = location.search.substring(1, location.search.length);
		}

		if (this.QueryString.length == 0){
			return false;
		}
		this.QueryString = this.QueryString.replace(/\+/g, ' ');
		var aArgs = this.QueryString.split('&');

		for (i=0; i < aArgs.length; i++) {
			var value;
			var pair = aArgs[i].split('=');
			var name = unescape(pair[0]);

			if (pair.length == 2) {
				value = unescape(pair[1]);
			} else {
				value = name;
			}
			
			this.params[name] = value;
		}
	}
	String.prototype.isNumeric = function() { return (this.match(/^\d+$/) !=
	null); }
	
	QueryString.prototype = {
		get: function(key) {
			return this.params[key]
		}
	}

	/*
	 * ajax requests
	 */
	function Request(sURL) {
		this.URL = sURL;
		this.Options = {
			method: 'post'
		}

	}
	
	Request.prototype = {
		Async: function(sPostBody, fnHandler, oObject, vExtra) {
			this.Options.postBody = sPostBody;
			this.Options.asynchronous = true;
			this.Options.evalJSON = 'force';
			this.Options.onSuccess = fnHandler.bind(oObject, vExtra);
			this.Options.on404 = function(oRequest) {
				sendError(oRequest.responseText);
			};
			this.Options.onFailure = function(oRequest) {
				sendError('Error ' + oRequest.status + ' -- ' + oRequest.statusText);
			}

			new Ajax.Request(this.URL, this.Options);		
		},
		
		Sync: function(sPostBody, fnHandler, oObject, vExtra) {
			this.Options.postBody = sPostBody;
			this.Options.asynchronous = false;
			this.Options.evalJSON = 'force';
			this.Options.onSuccess = fnHandler.bind(oObject, vExtra);
			this.Options.on404 = function(oRequest) {
				sendError(oRequest.responseText);
			};
			this.Options.onFailure = function(oRequest) {
				sendError('Error ' + oRequest.status + ' -- ' + oRequest.statusText);
			};
			new Ajax.Request(this.URL, this.Options);
		}
	}

	var dialogPremium;
	var AJAXPREMIUM;
	
	
	
	function puedoSubir(){
		dialogPremium = new Dialog();
		AJAXPREMIUM = new Request("/backend/ajax/puedeSubir.php");
		AJAXPREMIUM.Sync('',puedoSubir_CallBack, this, false);				
	}
	
	
	
	function puedoSubir_CallBack(varExtra, aData){	
		
		aData = aData.responseJSON;
		
		if(aData["status"] == 1){
			
			// no hago nada
			 
		}else{
			
			TIT_PREMIUM= aData['TEXT_TIT_PREMIUM'];
			SUB_PREMIUM = aData['TEXT_SUB_PREMIUM'];
			OTRO_PREMIUM = aData['TEXT_OTRO_PREMIUM'];
			IMAGEN_PREMIUM = aData['TEXT_IMAGEN_PREMIUM'];
			
			$("TitPremium").innerHTML = TIT_PREMIUM;
			$("SubPremium").innerHTML = SUB_PREMIUM;
			$("OtroPremium").innerHTML = OTRO_PREMIUM;
			$("imagenPremium").src = IMAGEN_PREMIUM;
			
			dialogPremium.Show("divPremium");
			
			return false;

		}
	}
	/*
	 * dialog class
	 */
	function Dialog() {
		if (previousDialog && previousDialog instanceof Dialog) {
			try{return previousDialog;}catch(e){}
		}
		
		this.Dialog = Builder.node('table', {cellpadding: 0, cellspacing: 0, border: 0});

		
		Element.hide(this.Dialog);

		//this.Dialog.setAttribute('id', 'dialog');
		//Element.addClassName(this.Dialog, "dialog");
		
		this.Background = Builder.node('div');
		this.Background.setAttribute('id', 'dialog_background');
		Element.hide(this.Background);
		
		this.oBody = document.getElementsByTagName("body").item(0);
		this.Background.setAttribute('id', 'dialog_background');
		this.oBody.insertBefore(this.Background, this.oBody.firstChild);
		this.oBody.appendChild(this.Dialog);
		
		
		this.Dialog.style.width = "100%";
		this.Dialog.style.height = "auto";
		
		
  		var myWidth = 0, myHeight = 0;
		
		if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		    myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		   //IE 4 compatible
		    myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		}
	
		
		this.Dialog.style.height = myHeight + "px";
		this.Dialog.style.zIndex = 99999;
		this.Dialog.style.position = "absolute";
		this.Dialog.style.left = "0px";
		this.Dialog.style.top = "0px";
		
		this.Background.style.height = myHeight + "px";
		this.Background.realHeight = myHeight;

		aTableTbody = Builder.node("tbody");
		aTableTr = Builder.node("tr");
		this.dialogContent = Builder.node("td");
		
		this.dialogContent.align = "center";
		this.dialogContent.valign = "middle";
		
		aTableTr.appendChild(this.dialogContent);
		aTableTbody.appendChild(aTableTr);
		this.Dialog.appendChild(aTableTbody);

		this.Browser = this.checkBrowser();
		
		if (this.Browser == "Internet Explorer"){
			//this.Background.style.height = Element.getDimensions(document.body).height;
			window.onscroll = this.setBackgroundPosition.bind(this);
			setInterval("getDialogInstance().setBackgroundPosition()", 1);
		} else {
			this.Background.style.position = "fixed";
			this.Dialog.style.position = "fixed";
		}
		previousDialog = this;
	}
	
	function getDialogInstance() {
		try{return new Dialog();}catch(e){}
	}
	
	Dialog.prototype = {
		Show: function(sDiv, bNoHideSelects) {
			if (!$(sDiv)) return false;
		    bNoHideSelects = ( bNoHideSelects == true ) ? false : true;
			
			/*if (this.Browser == 'Internet Explorer' && bNoHideSelects) {
				this.hideSelects('hidden');
			}*/
			if (this.checkBrowser() == 'Internet Explorer') {
				this.hideSelects('hidden');
				//document.body.onselectstart = function () { return false; }
			} else {

			}

			if (this.checkBrowser() == 'Internet Explorer') {

				//Ahora, una forma mas simple
				if ((document.body.scrollHeight) && (this.Background.realHeight < document.body.scrollHeight)) {
					this.Background.style.height = document.body.scrollHeight;
					this.Background.style.width = document.body.scrollWidth;
				} else 
					if ((document.documentElement.scrollHeight) && 
						(this.Background.realHeight < document.documentElement.scrollHeight)) {
					this.Background.style.height = document.documentElement.scrollHeight;
					this.Background.style.width = document.documentElement.scrollWidth;
				} else {
					this.Background.style.width = "100%";
					this.Background.style.height = this.Background.realHeight;
				}
			}
			
			this.hideObjects('hidden');
			this.Prepare('100%', 'hidden');

			this.dialogContent.appendChild($(sDiv));
			Element.show(this.Background);
			Element.show(this.Dialog);
			//$(sDiv).style.overflow = "auto";
			Element.show($(sDiv));
			if (this.checkBrowser() == 'Internet Explorer') {
				var inputs = $(sDiv).getElementsByTagName('input'); 
				try{
					inputs[0].focus();
				}catch(e){}
			}
		//new Draggable2(sDiv, {starteffect: function() {}, endeffect: function() {}, constraint: "vertical"});
			this.Center(this.Dialog);
			return true;			
		},
		
		Hide: function(sDiv) {
			if (this.Browser == "Internet Explorer"){
				this.hideSelects("visible");
				document.body.onselectstart = null;
			} else {
				document.onmousedown = null;
				document.onclick = null;
			}
			this.hideObjects('visible');
			
			this.Prepare("auto", "auto");
			
			Element.hide(sDiv);
			Element.hide(this.Background);
			Element.hide(this.Dialog);
			//parent.toolbar.scrollhere(0,3);

			return true;		
		},
		
		setBackgroundPosition: function () {
			if (this.Browser == "Internet Explorer") {
				if (document.body.scrollTop) {
					//this.Background.style.top = document.body.scrollTop;
					this.Dialog.style.top = document.body.scrollTop;
				} else {
					//this.Background.style.top = document.documentElement.scrollTop;
					this.Dialog.style.top = document.documentElement.scrollTop;
				}
			}
		},
		
		showError: function(sError) {
			$('error_message').innerHTML = sError;
			this.Show('error');
		},


		showErrorSinEncuesta: function(sError) {
			$('error_message').innerHTML = sError;
			this.Show('error');
		},

		showWarning: function (sWarning) {
			Element.update('warning_message', sWarning);
			this.Show('warning');
		},
				
		hideWarning: function () {
			this.Hide('warning');
		},
		
		hideError: function() {
			$('error_message').innerHTML = '';
			this.Hide('error');
		},
		
		showWorking: function() {
			this.Show('working');
		},
		
		hideWorking: function() {
			this.Hide('working');
		},
		
		parseError: function(errorData) {
			errorText = errorData["text"];
			errorType = errorData["type"];
			
			switch (errorType) {
				case 2: //Error
					this.showError(errorText);
					break;
				default: //Warning
					this.showWarning(errorText);
					break;
			}
			return true;
		},
		
		Prepare: function(height, overflow) {

		},
		
		checkBrowser: function() {
			sUserAgent = navigator.userAgent.toLowerCase();
			exists = sUserAgent.indexOf('msie') + 1;
			if(exists) {
				return 'Internet Explorer';
			} else {
				return 'Other';
			}
		},
		
		hideSelects: function(visibility) {

			selects = document.getElementsByTagName('select');
			for(i = 0; i < selects.length; i++) {
				selects[i].style.visibility = visibility;
			}
		},
		
		hideObjects: function(visibility) {
			objects = document.getElementsByTagName('object');
			for(i = 0; i < objects.length; i++) {
				objects[i].style.visibility = visibility;
			}
		},
		
		Center: function(element) {
			
		}	
}

	/*
	 * ajax requests
	 */
	function doAsyncRequest(sPostBody, fnHandler, oObject, vExtra) {

		var aAjaxOpt = {
			method: 'post',
			postBody: sPostBody,
			asynchronous: true,
			/* if its ok execute handler */
			onSuccess: fnHandler.bind(oObject, vExtra),
			/* handle 404 */
			on404: function(oRequest) {
				sendError(oRequest.responseText);
			},
			/* handle other errors */
			onFailure: function(data) {
				sendError('Error ' + oRequest.status + ' -- ' + oRequest.statusText);
			}
		}
		new Ajax.Request(sAjaxURL, aAjaxOpt);
	}

	function doSyncRequest(sPostBody, fnHandler, oObject, vExtra) {

		var aAjaxOpt = {
			method: 'post',
			postBody: sPostBody,
			asynchronous: false,
			/* if its ok execute handler */
			onSuccess: fnHandler.bind(oObject, vExtra),
			/* handle 404 */
			on404: function(oRequest) {
				sendError(oRequest.responseText);
			},
			/* handle other errors */
			onFailure: function(data) {
				sendError('Error ' + oRequest.status + ' -- ' + oRequest.statusText);
			}
		}
		new Ajax.Request(sAjaxURL, aAjaxOpt);
	}	
	

	
	/*
	 * dialog functions
	 */
	function dialog_init() {

	}
	
	/*
	 * error functions.
	 */
	function showError(sError) {
		try{getDialogInstance().showError(sError);}catch(e){}
	}
	
	

	function hideError() {
		try{getDialogInstance().hideError();}catch(e){}
		
	}
	
	function showWarning(sWarning) {
		try{getDialogInstance().showWarning(sWarning);}catch(e){}
		
	}
	
	function hideWarning() {
		try{getDialogInstance().hideWarning();}catch(e){}
	}
	
	function hideObjects (visibility) {
		try{getDialogInstance().hideObjects(visibility);}catch(e){}
	}
	
	function parseError (errorData) {
		try{getDialogInstance().parseError(errorData);}catch(e){}
	}
	 
	function dialog_show() {

	}
	
	function dialog_showDialog(sDialog) {
		try{getDialogInstance().Show(sDialog);}catch(e){}
	}
	
	function dialog_blockThemAll() {
		try{getDialogInstance().showWorking();}catch(e){}
	}
	
	function dialog_unblockThemAll() {
		try{getDialogInstance().hideWorking();}catch(e){}
	}

	function dialog_hide() {

	}
	
	function dialog_hideDialog(sDialog, hideNow) {
		try{getDialogInstance().Hide(sDialog);}catch(e){}
	
	}
	
	function dialog_showWorking() {
		try{getDialogInstance().showWorking();}catch(e){}
	}

	function dialog_hideWorking() {
		try{getDialogInstance().hideWorking();}catch(e){}
	}
	
	/* this is from http://particletree.com */
	function dialog_prepareBrowser(height, overflow) {
		try{getDialogInstance().Prepare(height, overflow);}catch(e){}
	}
	
	function dialog_hideSelects(visibility) {
		try{getDialogInstance().hideSelects(visibility);}catch(e){}
	}
	
	function dialog_checkBrowser() {
		try{getDialogInstance().checkBrowser();}catch(e){}
	}
	
	function dialog_center(element) {
		try{getDialogInstance().Center(element);}catch(e){}
	}
	
	function replaceThis(strData, strWhat, strWith, dontReplaceP) {
		i = 0;
		ret = "";
		while (str = strData.substr(i, strWhat.length)) {
			if (str == strWhat) {
				ret += strWith;
				i += strWhat.length - 1;
			} else {
				ret += strData.substr(i, 1);
			}
			i ++;
		}
		if (!dontReplaceP) {
			ret = replacePs(ret)
		}
		return ret;
	}
	
	function replacePs(strData) {
		strData = replaceThis(strData, "<P>", "", true);
		strData = replaceThis(strData, "</P>", "<BR>", true);
		
		return removeBorderSpaces(strData);
	}
	
	function removeBorderSpaces(strData) {
		help = strData;
		while (true) {
			lasthelp = help;
			help = removeBorders(help, " ");
			help = removeBorders(help, "&nbsp;");
			help = removeBorders(help, "<BR>");
			help = removeBorders(help, "\n");
			help = removeBorders(help, "\r");
			help = removeBorders(help, "\t");
			if (help == lasthelp) {
				return help;
			}
		}
		return strData;
	}
	
	function replaceThisOnce(strData, strWhat, strWith) {
		strDataLen = strData.length;
		strWhatLen = strWhat.length;
		for (aWd = 0; aWd < strDataLen; aWd ++) {
			miniData = strData.substr(aWd);
			if (miniData.substr(0, strWhatLen) == strWhat) {
				return strData.substr(0, aWd) + strWith + miniData.substr(strWhatLen);
			}
		}
		return strData;
	}
	
	function replaceTags(strData) {
		toReturn = "";
		isTag = false;
		for (iPWsq = 0; iPWsq < strData.length; iPWsq ++) {
			chrAt = strData.charAt(iPWsq);
			//Si comienza un tag
			if (chrAt == "<") isTag = true;
			if (!isTag) {
				toReturn += chrAt;
			}
			//Si termina un tag
			if (chrAt == ">") {
				isTag = false;	
			}
		}
		return toReturn;
	}
	
	function removeBorders(str, what) {
		whatLen = what.length;
		while (str.substr(0, whatLen) == what) str = str.substr(whatLen);
		while (str.substr(str.length - whatLen) == what) str = str.substr(0, str.length - whatLen);
		return str;
	}
	
	function closeTagsInBounds(range, fChar, lChar) {
		texto = range.htmlText;
		//texto = range;
		tags = [];
		openTag = [];
		closeTag = [];
		
		//Primero vemos los tags que hay
		iniChar = texto.indexOf("<");
		endChar = texto.indexOf(">") + 1;
		
		while (iniChar > -1 && endChar > -1) {
			ttag = new NeoTag(texto.substring(iniChar, endChar), iniChar, endChar);
			tags.push(ttag);
			iniChar = texto.indexOf("<", endChar);
			endChar = texto.indexOf(">", endChar) + 1;
		}
		
		if (tags.length > 0) {
			alert(texto + " // " + tags);
			moveStart = 0;
			moveEnd = 0;
			//Se fija si es coherente y corrige
			for (tagIT = 0; tag = tags[tagIT]; tagIT ++) {
				if (!tag.isOpen()) {
					//Se fija los ya abiertos
					prev = openTag[0];
					if (prev) {
						if (prev.getType() == tag.getType()) {
							// Si son el mismo tipo no hay problema
							openTag.shift();
							continue;
						} else { //Si abre un <b>y al rato cierra un </a> es malo
							//Una forma de solucionarlo es ver si se puede cambiar por alguno de los que cierran despues
							
							cont = false;
							next = tagIT;
							while (true === true) {
								prevTag = tags[next];
								next ++;
								nextTag = tags[next];
								
								if (prevTag && nextTag && getWhatsBetweenTags(prevTag, nextTag, texto) == "") {
									if (!nextTag.isOpen()) { //Si este cierra
										if (nextTag.getType() == prev.getType()) { //Si es del mismo tipo que el anterior que abre
											tags[tagIT] = nextTag;
											tags[next] = tag;
											openTag.shift();
											
											//Terminamos
											cont = true;
											break;
										}
									} else { //Si abre no me sirve
										break;
									}
								} else {
									break;
								}
							}
							if (cont) continue;
							//Si eso no funciono...
							//Y, que hacemos...
							//Metamos un tag de la nada que lo cierre y listo
							tagContent = "</" + prev.type + ">";
							closeTag = new NeoTag(tagContent, tag.getIni(), tag.getIni());
							
							//Pone el abierto despues de este, asi lo sigue analizando
							newOpen = prev.clone();
							newOpen.setPosition(tag.getEnd(), tag.getEnd());
							tags.splice(tagIT + 1, 0, newOpen);
							tags.splice(tagIT, 0, closeTag);
							openTag.shift();
							continue;
						}
					} else {
						//Aca ya tenemos un error, cierra algo que no se ve abierto
						//Lo dejamos para el final
						tagContent = "<" + tag.type + ">";
						openTag2 = new NeoTag(tagContent, 0, 0);
						
						tagContent = "</" + tag.type + ">";
						closeTag = new NeoTag(tagContent, tag.getIni(), tag.getIni());
						tags.unshift(openTag2);
						tags.unshift(closeTag);
						tagIT += 2;
						
						moveStart += tagContent.length;
						continue;
					}
				} else {
					openTag.unshift(tag);
					continue;
				}
			}
			
			//Si quedaron tags abiertos los cierra al final
			for (tagIT = 0; tag = openTag[tagIT]; tagIT ++) {
				tagContent = "<" + tag.type + ">";
				openTag2 = new NeoTag(tagContent, texto.length, texto.length);
				tags.push(openTag2);
			}
			//Y ahora los agrega para que no se pierda la coherencia con el resto
			while (tag = openTag.pop()) {
				tag.open();
				newOpen.setPosition(texto.length, texto.length);
				moveEnd += tag.toString().length;
				tags.push(newOpen);
			}
			
			
			toReturn = "";
			//Coloca el nuevo texto
			for (tagIT = 0; tag = tags[tagIT]; tagIT ++) {
				if (tagIT == 0) {
					toReturn += texto.substring(0, tag.getIni());
				}
				toReturn += tag + getWhatsBetweenTags(tag, tags[tagIT + 1], texto, true);
			}
			range.pasteHTML(toReturn);
			
			range.moveEnd("character", moveEnd);
			range.moveStart("character", -(toReturn.length - moveStart));
			
			alert(toReturn + " // " + range.htmlText);
		}
		return range;
	}
	
	function NeoTag(texto, ini, end) {
		this.attributes = [];
		this.text = texto;
		this.type = "";
		this.open = false;
		
		this.ini = ini;
		this.end = end;
		
		this.init();
	}
	
	NeoTag.prototype = {
		init : function() {
			this.open = (this.text.substr(0, 2) != "</");
			if (!this.open) startFrom = 2;
			if (this.open) startFrom = 1;
			
			isAttAssign = false;
			isFirst = true;
			igual = false;
			atrValue = "";
			atrName = "";
			
			//Sigue el resto
			for (tagIteration = startFrom; thisChr = this.text.charAt(tagIteration); tagIteration ++) {
				switch (thisChr) {
					case " ": //Espacio significa que es otra cosa
						if (this.text.charAt(tagIteration + 1) == " ") { //Si se viene un espacio
							break;
						} else if (this.text.charAt(tagIteration + 1) == "=") { //Si se viene un igual
							break;
						} else if (igual) { //Si tiene un igual antes
							break;
						}
					case ">": //Eso significa que termina
						if (isAttAssign || !isFirst) {
							this.attributes.push(new Array(atrName.toLowerCase(), atrValue));
						} else {
							this.type = atrName.toLowerCase();
							isFirst = false;
						}
						atrName = "";
						atrValue = "";
						isAttAssign = false;
						igual = false;
						break;
					case "=": //Igual significa que es asignacion
						isAttAssign = true;
						igual = true;
						break;
					default: //El resto
						if (!isAttAssign) atrName += thisChr;
						if (isAttAssign) atrValue += thisChr;
						igual = false;
						break;
				}
			}
		},
		isOpen : function () {
			return this.open;
		},
		getType : function () {
			return this.type;
		},
		getIni : function() {
			return this.ini;
		},
		getEnd : function() {
			return this.end;
		},
		
		clone : function() {
			return new NeoTag(this.text, this.ini, this.end);
		},
		setPosition: function(ini, end) {
			this.ini = ini;
			if (end) {
				this.end = end;
			} else {
				this.end = ini + this.text.length;
			}
		},
		
		valueOf : function() {
			return this.text;
		},
		
		toString : function() {
			return this.text;
		}
	}
	
	function getWhatsBetweenTags(iniTag, endTag, txtToGetFrom, dontRemoveSpaces) {
		if (endTag) {
			rep = txtToGetFrom.substring(iniTag.getEnd(), endTag.getIni())
		} else {
			rep = txtToGetFrom.substring(iniTag.getEnd())
		}
		if (!dontRemoveSpaces) {
			rep = removeBorders(rep, " ");
		}
		return rep;
	}
	
	function seek() {
		seekForm = $("seek_form");
		if (seekForm) seekForm.submit();
	}


	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_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_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 manejoTabs(el, cant){
		/*
Formato de esta funcion y utilizacion:
Lo que vamos a hacer vamos a pasar los tres elementos que les tenemos que aplicar el seleccionado 
y una cantidad para sacarle el over a los otros
*/
		var ConstanteDerSel = "/backend/images/gallery/izqcel.jpg";
		var ConstanteCentroSel = "url(/backend/images/gallery/middlecel.jpg)";
		var ConstanteIzqSel = "/backend/images/gallery/dercel.jpg";
		var ConstanteMedio = "url(/backend/images/gallery/middleazul.jpg)";
		var ConstanteIzq = "/backend/images/gallery/izqazul.jpg";
		var ConstanteDer = "/backend/images/gallery/derazul.jpg";

		for(i=1;i<=cant;i++){
			try{
				$("p"+i+"_1").src = ConstanteIzq;
				$("p"+i+"_2").style.background = ConstanteMedio;
				$("p"+i+"_3").src = ConstanteDer;
				$("p"+i+"_2").className  = "inactivohover";
				$("p"+i+"_2").onmouseover = function () { this.className='activo' };
				$("p"+i+"_2").onmouseout  = function () { this.className='inactivohover' };
			}catch(e){}
		}
		try{		
			$("p"+el+"_1").src = ConstanteDerSel;
			$("p"+el+"_2").style.background = ConstanteCentroSel;
			$("p"+el+"_3").src = ConstanteIzqSel;
			$("p"+el+"_2").className = "inactivo";
			$("p"+el+"_2").onmouseover = function () { this.className='inactivo2' };
			$("p"+el+"_2").onmouseout  = function () {this.className='inactivo' };
		}catch(e){}
	}
	function closeBanner(){
		document.getElementById("neoContact").style.display="none";
	}
	function openPopUp(modulo){
		if(modulo == 'main'){
			window.open("neocontact.php?vienede="+modulo,null,"height=500,width=390,status=yes,toolbar=no,menubar=no,location=no");
		}else{
			window.open("/backend/neocontact.php?vienede="+modulo,null,"height=500,width=390,status=yes,toolbar=no,menubar=no,location=no");
		}
		return false;
	}
	function creaContactame(modulo){
		//Evitamos duplicados
		/*try{
		if ($("contactame")) return false
		if (asd123asd == 1) return false;
		asd123asd = 1;
		}catch(e){
			
		}
		tControl = "";
		try{

					tControl += '<div id="neoContacto" name="neoContacto" onselectstart="return false"><table width="190" height="70" border="0" cellpadding="0" cellspacing="0" background="/backend/images/fondo_div.png" style="background-repeat:no-repeat;"><tr><td width="171" height="19" valign="top">&nbsp;</td><td width="19" align="left" valign="bottom"><a href="#" onclick="javascript:closeBanner()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'cerrar\',\'\',\'/backend/images/cerrar_div_oc.gif\',1)"><img src="/backend/images/cerrar_div.gif" name="cerrar" id="cerrar" width="11" height="13" border="0"></a></td></tr><tr><td height="28" colspan="2" valign="top"><div align="center"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif">Nos gustar&iacute;a que nos <br> env&iacute;es tus comentarios!</font></div></td></tr><tr> <td height="22" colspan="2" valign="top"><div align="center"><a href="#" onclick="javascript:openPopUp(\'' + modulo + '\');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'clic\',\'\',\'/backend/images/haz_clic_oc.gif\',1)"><img src="/backend/images/haz_clic.gif" name="clic" id="clic" width="101" height="18" border="0"></a></div></td></tr></table></div>';
			
					var oDialogBackground2 = Builder.node('div', {width:'100%',height:'100%', align:'right', style:'position: absolute; z-index:400; top:5px;left:5px;'});
					oDialogBackground2.setAttribute('id', 'neoContact');
				
			oDialogBackground2.innerHTML = tControl;
					
			var oBody = document.getElementsByTagName("body").item(0);
			oBody.insertBefore(oDialogBackground2, oBody.firstChild);
			
			/*if(modulo == "main"){
				new Draggable("neoContacto", {} );
			}*/
		/*}catch(e){
			
		}*/
	}
	
function setPassword(){
	pass = $F('txtPassword');
	text = $F('txtTextoPagina');
	txtchk = $("chkText").checked;
	try{
		QueryString1 = new QueryString();
		Id = QueryString1.get('id');
	}catch(e){}
	sendAjax='id=' + Id + '&a=password&spassword='+pass+'&passwordtext='+text+'&txtchk='+txtchk;
	AJAX.Async(sendAjax,callback_setPassword, this, pass);
	
}
var Dialogo;
function mostrarDivPremium(titulo, subtitulo, otro, imagen){
	$("TitPremium").innerHTML = titulo;
	$("SubPremium").innerHTML = subtitulo;
	$("OtroPremium").innerHTML = otro;
	$("imagenPremium").src = imagen;
	Dialogo = new Dialog();
	Dialogo.Show('divPremium');
	
}
function callback_setPassword(varExtra, aData){
	aData = aData.responseJSON;
	if(varExtra != ""){
		$("txtPasswordActual").innerHTML = "La p&aacute;gina tiene password.";
		$("tablaInformacionPassword").removeClassName('tablaroja');
		$("tablaInformacionPassword").addClassName('tablaverde');
	}else{
		$("txtPasswordActual").innerHTML = "No se ha definido un password.";
		$("tablaInformacionPassword").removeClassName('tablaverde');
		$("tablaInformacionPassword").addClassName('tablaroja');		
	}
}	
function logout() {
	window.location = '/backend/logout.php';	
}
function logueoportal(){
	DialogoLogin = new Dialog();
	DialogoLogin.Show('contenedor_cargador');
	document.getElementById('miForm').submit();
}
// ]]>

