//eliminar apostrofes 
function validartext(formulario)
{
	var cadena;
	CamposTxt=formulario.elements;
	for (i=0;i<=CamposTxt.length-1;i++)
		if  ( (CamposTxt[i].type == "text" )||(CamposTxt[i].type == "textarea" )) 
			if (CamposTxt[i].value.length != 0) 
				{
				cadena="";
				for (j=0;j<=CamposTxt[i].value.length-1;j++)
					if (CamposTxt[i].value.charAt(j)!="'")
						cadena=cadena+CamposTxt[i].value.charAt(j);
				CamposTxt[i].value=cadena;
				}			
	return true;
}

function validarselect(formulario)
{ 
sw=0;   // uso un interruptor para ver si hay alguno seleccionado
	CamposSelect=formulario.elements;
    
	for (i=0;i<CamposSelect.length;i++)     //Miro cuales son select y que ademas empiecen por NV para que sean obligatorios
		if ( (CamposSelect[i].type == "select-one") && (CamposSelect[i].name.substring(0,2) == "NV") )
		{	
			if (CamposSelect[i].options.selectedIndex == 0)
				{
					alert("debes introducir algo");
					CamposSelect[i].focus();
					return false;
					
				}
	    }
	 return true;
}



//-----------------------------------------------------------------------------------------------------
// creates a new cookie
// input values: name of the cookie want to create
// input values: value of the cookie
// if expiration date is not set the cookie will expire when the user close the all sessions of browser..
//-----------------------------------------------------------------------------------------------------
function setcookie(sname, svalue){
	 
	window.document.cookie = sname + "=" + escape(svalue) + "; path=/ ";		
		
}

//-----------------------------------------------------------------
// returns the value of a cookie
// input parameters: name of the cookie
// output parameter: value of the cookie otherwise an empty string 
//-----------------------------------------------------------------
function getcookie(sname){
  //check if the cookie exist	
  var index = window.document.cookie.indexOf(sname + "=");
  if (index != -1){
	var acookie = window.document.cookie.split("; ");		
	for (var i=0; i < acookie.length; i++){
    		var acrumb = acookie[i].split("=");
    		if (sname == acrumb[0]){
			return unescape(acrumb[1]);
    		}
  	 }
  }
  //cookie do not exists
  else{
	return "";
  }
}

//-----------------------------------------------------
// deletes a cookie
// input parameters: name of the cookie to be deleted
//-----------------------------------------------------
function deletecookie(sname){	

	var svalue="";
	window.document.cookie = sname + "=" + escape(svalue) + "; expires=Fri, 01-Jan-70 00:00:01 GMT; path=/; ";
}

//---------------------------------------------------------------------------
//creates a list of values and stores them in a cookie
//input parameters: name of the cookie
//input parameters: svalue1 to be added to the cookie - name of the translator
//input parameters: svalue2 to be added to the cookie - id of the translator
//input parameters: noverbose if selected shows no information about the process
//output parameters: none
//----------------------------------------------------------------------------
function add2listofcookies(sname,svalue1,svalue2,noverbose)
{	
	var cookie = getcookie(sname);
	
	//check if the value is already in the list
	if (cookie.indexOf(svalue2) != -1)
	{
		if (noverbose == null){
			window.alert(svalue1 + ' is already in your list');
		}
	}
	else{
		var lista = svalue1 + "," + svalue2 + ";";
		lista = cookie + lista;
		setcookie(sname,lista);
		
		//only if we want to notify
		if (noverbose == null){
			window.alert (svalue1 + ' has been sucesfully added to your list');
		}

	}
}

//--------------------------------------------------------
//adds the content of a cookie to a list control in html
//input parameter: complete reference to the list control
//input parameter: name of the cookie
//--------------------------------------------------------
function add2list(slistreference,snamecookie)
{
	var lista=getcookie(snamecookie);
	var pos=lista.indexOf(";");
	
	if (pos!=-1)
	//{
		//window.alert("Empty Cookie");
	//}
	//else
	{
		var listado = lista.split(";");
		for(var i=0;i<listado.length - 1;i++)
		{
			//get two values of one value of the cookie
			var valores = listado[i].split(",");
			
			//Only if the first element is NOT empty or null
			if (valores[0] != ""){
				eval(slistreference + ".options[" + i + "]= new Option(valores[0],valores[1])");
			}
		}
	}
}

//-----------------------------------------------------------
//opens a pop-up window with help about the topic selected
//input paremeter: index of the item that will be showed
//Output paremeter: none
//-----------------------------------------------------------
function showhelp(index){

	//left-down corner over the task bar 
	var x = (window.screen.width - 410);
	var y = (window.screen.height - 560);
	
	var sventana = window.open('/tt/helpreference.htm#'+index,'helpwindow','width=420,height=500,blur=helpwindow,scrollbars=yes,left=' + x + ',top=' + y);
	sventana.creator=self;
	sventana.focus();
}

//-------------------------------------------------------------------
//opens a pop-up window with help about the topic selected
//this function is applied only from the profile menu due path change
//input paremeter: index of the item that will be showed
//Output paremeter: none
//-------------------------------------------------------------------
function showhelpfromprofile(index){

	//left-down corner over the task bar 
	var x = (window.screen.width - 410);
	var y = (window.screen.height - 560);
	
	var sventana = window.open('/tt/helpreference.htm#'+index,'helpwindow','width=410,height=500,blur=helpwindow,scrollbars=yes,left=' + x + ',top=' + y);
	sventana.creator=self;
	sventana.focus();
}

//---------------------------------------------------------------------------
//shows an alert window indicating that the action will logout of the system
//used in the locator window within top.asp
//input parameters:
//	1 - Exits to don Quijote web site
//  2 - Exits to translation services
//CHANGE THE LOCATION METHOD IN CASE OF RELOCATING THE WEB
//---------------------------------------------------------------------------
function logoutwarning(index){

	if (window.confirm('This action will finish your session in this page, are you sure?')){
		switch(index){
			case 1:{window.location.href="http://www.translationtown.com/tt/index.asp?Desconectar=2";}
			break;
			case 2:{window.location.href="http://www.translationtown.com/tt/index.asp?Desconectar=1";}
			break;			
		}	
	}
}

//-----------------------------------------------------------------------
//open the pop-Up window describing a translator
//input parameters: reference to a list with the translators to be showed
//output parameters: None
//-----------------------------------------------------------------------
function showinfo(lista){

	//check out the list	
	if (checklist(lista)){

		var index = eval(lista + '.selectedIndex');

		//open the window
		abrirprofile(eval(lista + '.options[' + index + '].value'),false);
	}
}

//-----------------------------------------------------------------------
//deletes an item from the list
//input parameters: index of the element to be deleted
//input parameters: reference to the list object
//output parameters: None
//-----------------------------------------------------------------------
function deleteitem(lista){
	
	//check out the list
	if (checklist(lista)){

		//mensaje de advertencia
		if (confirm ('You are about to delete this item from the list, are you sure?')){
			var indice = eval(lista + '.selectedIndex');
			
			//deletes from list
			eval(lista + '.options[' + indice +']=null');
			
			//updates cookie
			//NOTE: change the name of the cookie if needed (second argument)
			deletefromcookie(lista,'listatrad');

			//updates window
			//window.history.go(0);
		}
	}
}

//---------------------------------------------------------------------------
//checks if it is possible to edit items from the list
//input parameters: index of the element to be deleted
//input parameters: reference to the list object
//output parameters: true if it is possible to edit the (items) from the list
//		     false in other cases
//---------------------------------------------------------------------------
function checklist(lista){

	//no items in the list
	if (eval(lista + '.options.length == 0')){
		window.alert('You must first add items to the list');
		return false;		
	}

	//No selected items
	if (eval(lista + '.selectedIndex == -1')){
		window.alert('You must first select an item from the list');
		return false;
	}

	return true;
}

//---------------------------------------------------------------------------
//delete an item from a cookie; first delete the cookie; second creates the
//same cookie with the new set of values
//input parameters: list object to read the elements from
//input parameters: name of the cookie to be deleted-created
//output parameters: none
//---------------------------------------------------------------------------
function deletefromcookie(lista,sname){
	
	//first deletes the cookie;the default path is /
	deletecookie(sname);

	//read the list object and adds the values to the cookie
	var indice = eval(lista + '.options.length');
	for(var i=0;i<indice;i++){
		add2listofcookies(sname,eval(lista + '.options[' + i + '].text'),eval(lista + '.options[' + i + '].value'),'yes');
	}
	
}

//open the profile window--the size is fixed:width=690; height=630
//input parameter: code of the translator to be shown
//input paremeter: Boolean value 
//	--> true opens the new window to show information about the favourite
//	--> false opens the new window to show information normally
function abrirprofile(codetrad,favourite){
				
	//coordenadas del centro de la pantalla
	var x = (window.screen.width - 690)/2;
	var y = (window.screen.height - 630)/2;
	
	var sventana = window.open('http://www.translationtown.com/tt/profile.asp?codetrad=' + codetrad + '&favourite=' + favourite,'details','width=690,height=630,blur=profile,scrollbars=yes,left=' + x + ',top=' + y);
	sventana.creator=self;
	sventana.focus();
}

//add the favourites to the selection
//input parameter: list of favourites
//output paremeter: none
function copy2selection(favourites){
	
	//first check if string is empty
	if (favourites.length == 0){
		alert('Sorry, you dont have any favourite translators to add.');
	}
	else{	
		//first check if the cookie exists
		//if doesnt we create it
		if (getcookie('listatrad')==""){
			setcookie('listatrad','');
		}
		
		//now we fill the cookie
		var listado = favourites.split(";");
		for(var i=0;i<listado.length - 1;i++){
			var substr=listado[i];
			var listaaux = substr.split(",");
			add2listofcookies('listatrad',listaaux[0],listaaux[1],true);
		}
	//add to list control of html code
	add2list('window.document.form1.lista','listatrad')
	}
}

//Shows an alert to the user before logging out
//input paremeters: none
//output: none
function logoutmessage(){
	
	if (confirm("This action will finish your current session, are you sure?")){
		//deletes the cookie with the list of translators
		deletecookie("listatrad");
		//forms must have the same name
		document.desconectar.submit();
		return(true);
	}
	return(false);
}




//Estas funciones se usan en los ficheros de /tt/datos/education y 
//para abrir una ventana con el folleto de Abroad Languages
function openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,onClose,scroll,X,Y) {

	var windowW = W;
	var windowH = H;
	var windowX = X?X:Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Y?Y:Math.ceil( (window.screen.height - windowH) / 2 );

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) 
		isie=true;
	else
		isie=false;

	if (isie){ 
		H=H+20+2; 
		W=W+2; 
	}
	else{
		windowX=X?X:Math.ceil( (screen.width  - windowW) / 2 );
		windowY=Y?Y:Math.ceil( (screen.height - windowH) / 2 );
	}
	
	s = ",width="+W+",height="+H;

	if (isie && (navigator.userAgent.toLowerCase().indexOf("win")!=-1) ) {

var dowin = theURL != "" ? true : false;

var chromeTIThtml = '\n' +
'<html>																							'+ '\n'+
'<head>                                                                                                                                                                         	'+ '\n'+
'<title>&nbsp;CHROMELESS WINDOWS / TITLEBAR</title>                                                                                                                      		'+ '\n'+
'<style type="text/css">                                                                                                                                                        	'+ '\n'+
'#mywindowTITLE 	{ position: absolute; left:   0px; top:   0px; width: 100%; height: 22px; z-index: 1; background-color: '+windowTITBGCOLOR+'; clip:rect(0,100%,22,0); }         '+ '\n'+
'#mywindow 		{ position: absolute; left:   0px; top:   0px; width: 100%; height: 22px; z-index: 2;                            	      clip:rect(0,100%;22,0); }         '+ '\n'+
'#mywindowCLOSE 	{ position: absolute; left: -22px; top: -22px; width: 11px; height: 11px; z-index: 3;                            	      clip:rect(0,11,11,0);   }         '+ '\n'+
'#mywindowCLOCK 	{ position: absolute; left: -22px; top: -22px; width: 11px; height: 11px; z-index: 3;                            	      clip:rect(0,11,11,0);   }         '+ '\n'+
'</style>                                                                                                                                                                       	'+ '\n'+
'<script language="javascript">																				'+ '\n'

if ( theURL != "" ) {

chromeTIThtml = chromeTIThtml + 
'	theURL 	    	    = "'+theURL			+'"                                                                                                                             '+ '\n'+
'	windowCERRARa 	    = "'+windowCERRARa		+'"                                                                                                                             '+ '\n'+
'	windowCERRARd 	    = "'+windowCERRARd		+'"                                                                                                                             '+ '\n'+
'	windowCERRARo 	    = "'+windowCERRARo		+'"                                                                                                                             '+ '\n'+
'	windowCLOCK         = "'+windowCLOCK            +'"                                                                                                                             '+ '\n'+
'	windowBORDERCOLOR   = "'+windowBORDERCOLOR	+'"                                                                                                                             '+ '\n'+
'	windowBORDERCOLORsel= "'+windowBORDERCOLORsel	+'"                                                                                                                             '+ '\n'+
'	windowTITBGCOLOR    = "'+windowTITBGCOLOR	+'"                                                                                                                             '+ '\n'+
'	windowTITBGCOLORsel = "'+windowTITBGCOLORsel	+'"                                                                                                                             '+ '\n'

} else {

chromeTIThtml = chromeTIThtml + 
'	theURL="about:blank"                                                                                                                                                            '+ '\n'+
'	windowCERRARa 		= "close_a.gif"                                                                                                                                     '+ '\n'+
'	windowCERRARd 		= "close_d.gif"                                                                                                                                     '+ '\n'+
'	windowCERRARo 		= "close_o.gif"                                                                                                                                     '+ '\n'+
'	windowCLOCK         	= "/al/images/clock.gif"                                                                                                                             		'+ '\n'+
'	windowTIT 	    	= "<font face=verdana size=1>&nbsp; XXXXXX</font>"                                                                                               '+ '\n'+
'	windowBORDERCOLOR   	= "#000000"                                                                                                                                             '+ '\n'+
'	windowBORDERCOLORsel	= "#FF8A00"                                                                                                                                             '+ '\n'+
'	windowTITBGCOLOR    	= "#cdc7bb"                                                                                                                                             '+ '\n'+
'	windowTITBGCOLORsel 	= "#ffffff"                                                                                                                                             '+ '\n'

}

chromeTIThtml = chromeTIThtml + 
'var windowCERRARImg_a = new Image(); windowCERRARImg_a.src = windowCERRARa;                                                                                                            '+ '\n'+
'var windowCERRARImg_d = new Image(); windowCERRARImg_d.src = windowCERRARd;                                                                                                            '+ '\n'+
'var windowCERRARImg_o = new Image(); windowCERRARImg_o.src = windowCERRARo;                                                                                                            '+ '\n'+
'var windowCLOCKImg    = new Image();    windowCLOCKImg.src = windowCLOCK;                                                                                                              '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function mouseSTATUS() {                                                                                                                                                               '+ '\n'+
'	this.x       = null;                                                                                                                                                            '+ '\n'+
'	this.y       = null;                                                                                                                                                            '+ '\n'+
'	this.bt      = "up";                                                                                                                                                            '+ '\n'+
'	this.oldx    = null;                                                                                                                                                            '+ '\n'+
'	this.oldy    = null;                                                                                                                                                            '+ '\n'+
'	this.dx      = null;                                                                                                                                                            '+ '\n'+
'	this.dy      = null;                                                                                                                                                            '+ '\n'+
'	this.screeny = null;                                                                                                                                                            '+ '\n'+
'	this.screenx = null;                                                                                                                                                            '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	this.element = null;                                                                                                                                                            '+ '\n'+
'	this.event   = null;                                                                                                                                                            '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'var mouse = new mouseSTATUS();                                                                                                                                                         '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function actualizateMouseSTATUS(e) {                                                                                                                                                   '+ '\n'+
'	if (!e) var e = event                                                                                                                                                           '+ '\n'+
'	if ( (e.type=="mousedown" || e.type=="mouseup") && e.button!=1) return true                                                                                                     '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	var x=e.x+document.body.scrollLeft                                                                                                                                              '+ '\n'+
'	var y=e.y+document.body.scrollTop                                                                                                                                               '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	mouse.x   = x;                                                                                                                                                                  '+ '\n'+
'	mouse.y   = y;                                                                                                                                                                  '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	     if ( e.type == "mousedown" ) mouse.bt = "down";                                                                                                                            '+ '\n'+
'	else if ( e.type == "mouseup" )   mouse.bt = "up";                                                                                                                              '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	if (window.event) {                                                                                                                                                             '+ '\n'+
'		mouse.screenx=window.event.screenX;                                                                                                                                     '+ '\n'+
'		mouse.screeny=window.event.screenY;                                                                                                                                     '+ '\n'+
'	} else {                                                                                                                                                                        '+ '\n'+
'		mouse.screenx=-1;                                                                                                                                                       '+ '\n'+
'		mouse.screeny=-1;                                                                                                                                                       '+ '\n'+
'	}                                                                                                                                                                               '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function initMouseEvents() {                                                                                                                                                           '+ '\n'+
'	document.onmousedown = actualizateMouseSTATUS                                                                                                                                   '+ '\n'+
'	document.onmousemove = actualizateMouseSTATUS                                                                                                                                   '+ '\n'+
'	document.onmouseup   = actualizateMouseSTATUS                                                                                                                                   '+ '\n'+
'	document.onselectstart = selectstart                                                                                                                                            '+ '\n'+
'	document.ondragstart   = new Function("actualizateMouseSTATUS(event); return false;")                                                                                           '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function selectstart(){                                                                                                                                                                '+ '\n'+
'	if ( event.srcElement.tagName != "INPUT" && event.srcElement.tagName != "TEXTAREA") { return false; }                                                                           '+ '\n'+
'	else { mouse.bt="up"; return true; }                                                                                                                                            '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'																							'+ '\n'+
'initMouseEvents()                                                                                                                                                                      '+ '\n'+
'																							'+ '\n'+
'var mywindowbt    ="up";                                                                                                                                                               '+ '\n'+
'var wincloseSTATUS="up";                                                                                                                                                               '+ '\n'+
'																							'+ '\n'+
'var ofx=0;                                                                                                                                                                             '+ '\n'+
'var ofy=0;                                                                                                                                                                             '+ '\n'+
'var opx=0;                                                                                                                                                                             '+ '\n'+
'var opy=0;                                                                                                                                                                             '+ '\n'+
'var px=0;                                                                                                                                                                              '+ '\n'+
'var py=0;                                                                                                                                                                              '+ '\n'+
'																							'+ '\n'+
'var wcpx1=-1, wcpy1=-1;                                                                                                                                                                '+ '\n'+
'var wcpx2=-1, wcpy2=-1;                                                                                                                                                                '+ '\n'+
'																							'+ '\n'+
'var wclosechanged = false;                                                                                                                                                             '+ '\n'+
'																							'+ '\n'+
'function initToMoveWin() {                                                                                                                                                             '+ '\n'+
'		if (wincloseSTATUS=="up" && ( mywindowbt=="up" || mywindowbt=="over") ) {                                                                                               '+ '\n'+
'					                                                 												'+ '\n'+
'				if ( parent.mainloaded ) document.all["mywindowCLOCK"].style.visibility = "hidden";                                                 			'+ '\n'+
'					                                                 												'+ '\n'+
'				document.all["mywindowCLOCK"].style.pixelLeft=document.body.clientWidth-36 										'+ '\n'+
'				document.all["mywindowCLOCK"].style.pixelTop =4                                                                         				'+ '\n'+
'					                                                 												'+ '\n'+
'				wcpx1 = document.all["mywindowCLOSE"].style.pixelLeft=document.body.clientWidth-18                                                                      '+ '\n'+
'				wcpy1 = document.all["mywindowCLOSE"].style.pixelTop =4                                                                                                 '+ '\n'+
'				wcpx2 = wcpx1 + 11 - 1                                                                                                                                  '+ '\n'+
'				wcpy2 = wcpy1 + 11 - 1                                                                                                                                  '+ '\n'+
'				if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2) {                                                                    '+ '\n'+
'					if (wclosechanged == false) {                                                                                                                   '+ '\n'+
'						document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_o.src                                                     '+ '\n'+
'						wclosechanged = true                                                                                                                    '+ '\n'+
'					}                                                                                                                                               '+ '\n'+
'						                                                                                                                                        '+ '\n'+
'				} else if (wclosechanged == true) {                                                                                                                     '+ '\n'+
'					document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_d.src                                                             '+ '\n'+
'					wclosechanged = false                                                                                                                           '+ '\n'+
'				}                                                                                                                                                       '+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'																							'+ '\n'+
'		     if (   mouse.y <= 22 && mouse.y >= 1   && mywindowbt == "up"   && mouse.bt =="up"    ) { mywindowbt = "over" }                                                     '+ '\n'+
'		else if ( ( mouse.y  > 22 || mouse.y <  1 ) && mywindowbt == "over" && mouse.bt =="up"    ) { mywindowbt = "up"   }                                                     '+ '\n'+
'		else if (   mouse.y <= 22 && mouse.y >= 1   && mywindowbt == "over" && mouse.bt == "down" ) {                                                                           '+ '\n'+
'			self.window.focus();                                                                                                                                            '+ '\n'+
'	                                                                                                                                                                                '+ '\n'+
'			if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2 ) {                                                                           '+ '\n'+
'				wincloseSTATUS="down"                                                                                                                                   '+ '\n'+
'				document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_a.src                                                                     '+ '\n'+
'			} else {                                                                                                                                                        '+ '\n'+
'				document.all["mywindowTITLE"].style.backgroundColor = windowTITBGCOLORsel                                                                               '+ '\n'+
'				document.body.style.borderColor    = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				parent.chromewinb.document.bgColor = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				parent.chromewinl.document.bgColor = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				parent.chromewinr.document.bgColor = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				ofx =  mouse.x;                                                                                                                                         '+ '\n'+
'				ofy =  mouse.y;                                                                                                                                         '+ '\n'+
'				opx =  mouse.x;                                                                                                                                         '+ '\n'+
'				opy =  mouse.y;                                                                                                                                         '+ '\n'+
'			}	                                                                                                                                                        '+ '\n'+
'			mywindowbt="down";                                                                                                                                              '+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'		else if ( mouse.bt =="up" && mywindowbt == "down" ) {                                                                                                                   '+ '\n'+
'			mywindowbt="up";                                                                                                                                                '+ '\n'+
'			ofx=0;                                                                                                                                                          '+ '\n'+
'			ofy=0;                                                                                                                                                          '+ '\n'+
'			opx=0;                                                                                                                                                          '+ '\n'+
'			opy=0;                                                                                                                                                          '+ '\n'+
'																							'+ '\n'+
'			if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2 && wincloseSTATUS=="down" ) { top.window.close();'+onClose+'}                            '+ '\n'+
'																							'+ '\n'+
'			wincloseSTATUS="up"                                                                                                                                             '+ '\n'+
'		                                                                                                                                                                        '+ '\n'+
'			if ( document.all["mywindowTITLE"] ) {                                                                                                                          '+ '\n'+
'				document.all["mywindowTITLE"].style.backgroundColor = windowTITBGCOLOR                                                                                  '+ '\n'+
'				document.body.style.borderColor   = windowBORDERCOLOR                                                                                                   '+ '\n'+
'				parent.chromewinb.document.bgColor= windowBORDERCOLOR                                                                                                   '+ '\n'+
'				parent.chromewinl.document.bgColor= windowBORDERCOLOR                                                                                                   '+ '\n'+
'				parent.chromewinr.document.bgColor= windowBORDERCOLOR                                                                                                   '+ '\n'+
'			}                                                                                                                                                               '+ '\n'+
'																							'+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'		else if ( mywindowbt == "down" && wincloseSTATUS == "up") {                                                                                                             '+ '\n'+
'			var m_scrx = mouse.screenx;                                                                                                                                     '+ '\n'+
'			var m_scry = mouse.screeny;                                                                                                                                     '+ '\n'+
'			opx = px + ofx - m_scrx;                                                                                                                                        '+ '\n'+
'			opy = py + ofy - m_scry;                                                                                                                                        '+ '\n'+
'			px = m_scrx - ofx;                                                                                                                                              '+ '\n'+
'			py = m_scry - ofy;                                                                                                                                              '+ '\n'+
'			top.window.moveTo(px , py);                                                                                                                                     '+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'	setTimeout("initToMoveWin()",50);                                                                                                                                               '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'</script>                                                                                												'+ '\n'+
'</head>                                                                                                                                                                        	'+ '\n'+
'<body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=no style="border: 1px solid '+ windowBORDERCOLOR +'; overflow: hidden; margin: 0pt;" bgcolor='+windowTITBGCOLOR+'>  '+ '\n'+
'<div id=mywindow><img src="'+windowNONEgrf+'" width=100% height=20></div>                                                                                                             	'+ '\n'+
'<div id=mywindowTITLE>'+ '<table width=100% height=20 border=0 cellpadding=0 cellspacing=0><tr><td valign=middle align=left>'+windowTIT+'</td></tr></table>' +'</div>                  '+ '\n'+
'<div id=mywindowCLOSE><img name=closewin src="'+ windowCERRARd +'" border=0 width=11 height=11></div>                                                                                  '+ '\n'+
'<div id=mywindowCLOCK><img name=clockwin src="'+ windowCLOCK   +'" border=0 width=11 height=11></div>                                                                                  '+ '\n'+
'</body>                                                                                                                                                                        	'+ '\n'+
'<script>initToMoveWin();</script>																			'+ '\n'+
'</html>                                                                                                                                                                        	'+ '\n'

var chromeFRMhtml = '' +
'<HTML>																		'+ '\n'+
'<HEAD>                                                                         								'+ '\n'+
'<TITLE>'+ windowREALtit +'</TITLE>                                          									'+ '\n'+
'</HEAD>                                                                        								'+ '\n'+
'<script> 																	'+ '\n'+
'mainloaded = false																'+ '\n'+
'function generatetitle() { 															'+ '\n'+
'	if( window.frames["chromewint"] && window.frames["chromewinl"] && window.frames["chromewinb"] && window.frames["chromewinr"] ) {	'+ '\n'+
'		chromewint.document.open();													'+ '\n'+
'		chromewint.document.write( "'+ quitasaltolinea(chromeTIThtml) +'" );								'+ '\n'+
'		chromewint.document.close();													'+ '\n'+
'		chromewinl.document.bgColor="'+ windowBORDERCOLOR +'"										'+ '\n'+
'		chromewinb.document.bgColor="'+ windowBORDERCOLOR +'"										'+ '\n'+
'		chromewinr.document.bgColor="'+ windowBORDERCOLOR +'"										'+ '\n'+
'	} else {																'+ '\n'+
'		setTimeout("generatetitle()",200)												'+ '\n'+
'	}																	'+ '\n'+
'}																		'+ '\n'+
'generatetitle()																'+ '\n'+
'</script>																	'+ '\n'+
'<frameset border=0 framespacing=0 frameborder=0 rows="22,100%,1" onload="mainloaded=true" onreadystatechange="generatetitle()">		'+ '\n'+
'	<frame name=chromewint src="about:blank" scrolling=no noresize>  									'+ '\n'+
'	<frameset border=0 framespacing=0 frameborder=0 cols="1,100%,1">        								'+ '\n'+
'		<frame name=chromewinl src="about:blank" scrolling=no noresize> 								'+ '\n'+
'		<frame name=main       src="'+theURL+'" scrolling='+scroll+' noresize>                   									'+ '\n'+
'		<frame name=chromewinr src="about:blank" scrolling=no noresize> 								'+ '\n'+
'	</frameset>                                                             								'+ '\n'+
'	<frame name=chromewinb src="about:blank" scrolling=no noresize>         								'+ '\n'+
'</frameset>                                                                    								'+ '\n'+
'</HTML>                                                                        								'

		splashWin = window.open( "" , wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"+s);

		splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) );
		splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) );

		splashWin.document.open();
		splashWin.document.write( chromeFRMhtml );
		splashWin.document.close();

	}
	else    {
		var splashWin = window.open(theURL, wname, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+((scroll=='yes')?"1":"0")+",resizable=1"+s, true);
		splashWin.moveTo(windowX,windowY);
	}

	splashWin.focus();
}                                                                               
                                                                                
function quitasaltolinea(txt) {

  var salida = txt.toString()
  var re     = /\\/g; var salida = salida.replace(re, "\\\\");
  var re     = /\//g; var salida = salida.replace(re, "\\\/");
  var re     = /\"/g; var salida = salida.replace(re, "\\\"");
  var re     = /\'/g; var salida = salida.replace(re, "\\\'");
  var re     = /\n/g; var salida = salida.replace(re, "\\n");
  var re     = /  /g; var salida = salida.replace(re, "");
  var re     = /\t/g; var salida = salida.replace(re, "");
  var re     = /\r/g; var salida = salida.replace(re, "");

  return salida

}

function openTextoLegal(){
	laURL='textolegal.html';
	wname ="textolegal"
	W=180;
	H=300;
	windowCERRARa="/al/images/close_a.gif";
	windowCERRARd="/al/images/close_d.gif";
	windowCERRARo="/al/images/close_o.gif";
	windowNONEgrf="/al/images/null.gif"
	windowCLOCK="/al/images/clock.gif"
	windowTIT="<font face=verdana size=1>&nbsp; XXXXXXXX</font>";
	windowREALtit="  XXXXXXX"
	windowBORDERCOLOR   	= "#808080"
	windowBORDERCOLORsel	= "#333333"
	windowTITBGCOLOR    	= "#cdc7bb"
	windowTITBGCOLORsel 	= "#ffffff"
	openchromeless(laURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,'','no',30,160);
}

function openDetalle(laURL,titulo,W,H,scroll){
	scroll=scroll?scroll:'no';
	wname='';
	windowCERRARa="/tt/images/close_a.gif";
	windowCERRARd="/tt/images/close_d.gif";
	windowCERRARo="/tt/images/close_o.gif";
	windowNONEgrf="/tt/images/none.gif"
	windowCLOCK="/images/clock.gif"
	windowTIT="<font face=verdana size=1>"+titulo+"</font>";
	windowREALtit=titulo;
	windowBORDERCOLOR="black"
	windowBORDERCOLORsel="black"
	windowTITBGCOLOR="#f0ecf0"
	windowTITBGCOLORsel="#00016d"
	if (document.layers && scroll=='yes'){
		W+=4;
	}
	openchromeless(laURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,'',scroll);
}

function GetKWOdQ (datos, url_dest){
//  Funcion para enviar el enlace a la pagina que queremos obteniendo las keywords
	enlace = "http://www.donquijote.org/prueba/dqcookie.asp?kwodq="+datos+"&url="+url_dest;
  window.setTimeout ("window.location.href=enlace", 2);
} 
