

	var globalX;

	

	function filterSubcategory(id){

			

			// document.getElementById('rsWaiting').style.display='block'; // inserta cartel cargando

			x_getSubcategories(id, putSubcategories);

	}

	

	function putSubcategories(arr)

	{

		var tmp;

		tmp = arr.replace(/\+\:/,'');

		//tmp         = arr.substring(1); //Parche por que z viene con ":" adelate.

		eval("var customarray = " + tmp); // customarray se llama el arreglo mejorado

      

		controlToPopulate = 	window.document.getElementById('gdsId_gender');



		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

		

		for ( x = 0 ; x < customarray['arr_id'].length  ; x++ )

		{

			if (typeof(customarray['arr_id']) != "undefined" &&  customarray['arr_id']!="")

			{



				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(customarray['arr_values'][x],customarray['arr_id'][x]);

			}

		}				

		//document.getElementById('rsWaiting').style.display='none'; // quita cartel cargando

	}

	

	function selectChange2(control, x)

	{

		if(arrDetails[x])
			document.getElementById("details").innerHTML=arrDetails[x];
		else
		{
			document.getElementById('rsWaiting').style.display='block';
			globalX = x;
			x_select_detail(x, do_detail_cb);
		}

	}

	var globalX;
	function detailProductCart(control, x)
	{

		if(arrDetails[x])
			document.getElementById("details").innerHTML=arrDetails[x];
		else
		{
			document.getElementById('rsWaiting').style.display='block';
			globalX = x;
			x_select_detail_cart(x, do_detail_cb);
		}
	}	

	function create_options(){

	    

	    //Genero las opciones del select "memberList"

		controlToPopulate=document.forms['frm_abm'].elements['memberList'];



		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

		

		for ( x = 0 ; x < arrItems.length  ; x++ )

		{

			if (typeof(arrItems[x]) != "undefined" &&  arrItems[x]!="")

			{

				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(arrItems[x],arrItemsGrp[x]);

			//	alert(arrItems[x]);

			}

		}				

		document.getElementById('rsWaiting').style.display='none';

	}

	

	function put_items(z){
	
		tmp = z.replace(/\+\:/,'');
		var tmp;
		tmp         = z.substring(1); //Parche por que z viene con ":" adelate.
        arrItems    = Array();
        arrItemsGrp = Array();

		eval("var customarray = " + tmp);
		//actualizo los arreglos arrItems y arrItemsGrp

		for (i in customarray['val1']) {
		  arrItems[i]    = customarray['val1'][i]; //Palabras claves
		  arrItemsGrp[i] = customarray['val3'][i]; //ID de las palabras claves
		}
		//creo las options en el select
		create_options();

	}

	

	function items_filtrados(z){

        var valor;

	var tmp;

	var arrTmp = new Array();

	var arrTmpGrp = new Array();

		  

		tmp = z.replace(/\+\:/,'');

		//tmp = z.substring(1); //Parche por que z viene con ":" adelate.

		valor = arrItems.lenght;

		

		eval("var customarray = " + tmp);

		for (x in arrItems){

			arrTmp[x] = arrItems[x];

			arrTmpGrp[x] = arrItemsGrp[x];

		}

        arrItems =  Array();

        arrItemsGrp = Array();

		//actualizo los arreglos arrItems y arrItemsGrp

		for (i in customarray['val1']) {

          //verifico que el contenido este en arrItems

          

          for(x=0; x<arrTmp.length; x++){		

			if (customarray['val3'][i] == arrTmpGrp[x]){ 

		  		arrItems[i]    = customarray['val1'][i]; //Palabras claves

		  		arrItemsGrp[i] = customarray['val3'][i]; //ID de las palabras claves

		  	}

		  } 

		}

		

		//creo las options en el select

		create_options();

	}

		

	var globalGroup;
	var categoriesDownloaded = Array();
	function selectChange(group)
	{
        document.getElementById('rsWaiting').style.display='block';
        //busco las palabras claves y cargo los arreglos arrItems y arrItemsGrp
	    select_model(group, put_items);
	}


	var globalGroup;
	var categoriesDownloaded = Array();
	function selectChangeCart(group)
	{
		document.getElementById('rsWaiting').style.display='block';
		globalGroup = group;
		if(group == -1 || (categoriesDownloaded&&categoriesDownloaded[group]))
		{
			changeSelect();
		}else
			x_select_model_cart(group, do_model_cb);
	}

	function ChangeContent(group)
	{ 
        document.getElementById('rsWaiting').style.display='block';

        //busco las palabras claves y cargo los arreglos arrItems y arrItemsGrp

	    x_select_content(group, put_items);
	}

	function deb(msg)

	{

		o = document.getElementById("dConsole");

		if(o){

			dbg= "["+msg+"]"+"\n";

			o.value =o.value+dbg;

		}

	}

	function do_detail_cb(z) 

	{

		z = z.replace(/\+\:/,'');

		eval("var customarray = "+z);

		deb("\n"+'Z:'+z);

		for(i in customarray['index2'])

		{

			arrDetails[customarray['index2'][i]]=customarray['val2'][i];

		}

		if(arrDetails[globalX])

			document.getElementById("details").innerHTML=arrDetails[globalX];

		else

			document.getElementById("details").innerHTML='';

		document.getElementById('rsWaiting').style.display='none';

	}

	function do_model_cb(z) 

	{ 

		z = z.replace(/\+\:/,'');

		eval("var customarray = "+z);

		deb("\n"+'Z:'+z);

		// Show the JSON string just for fun

		for(i in customarray['val1'])

		{

			arrItems[globalGroup][customarray['index12'][i]]=customarray['val1'][i]; //Palabras claves

			arrItemsGrp[globalGroup][customarray['index12'][i]]=customarray['val3'][i];//ID de las palabras claves

			arrItems[0].push(customarray['val1'][i]);

			arrItemsGrp[0].push(customarray['val3'][i]);

		}

		var myEle ;

		var x ;

		changeSelect();

	}

	function changeSelect()

	{

		group=globalGroup;

		controlToPopulate=document.forms['frm_abm'].elements['memberList'];

	  // Empty the second drop down box of any choices

		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;



	  // Now loop through the array of individual items

	  // Any containing the same child id are added to

	  // the second dropdown box

		

		for ( x = 0 ; x < arrItems[group].length  ; x++ )

		{

			if (typeof(arrItems[group][x]) != "undefined" &&  arrItems[group][x]!="")

			{

				controlToPopulate.options[controlToPopulate.options.length] =

	new Option(arrItems[group][x],arrItemsGrp[group][x])

			}

		}

		categoriesDownloaded[group] = 1;

		document.getElementById('rsWaiting').style.display='none';

		myfilter.init();

	}



   /* function do_model_cb_old(z) */

	/*{*/

		// Takes the JSON encoded string and makes a JS array

		/*eval("var customarray = "+z);*/

		// Show the JSON string just for fun

		/*document.getElementById("json").value = z;*/

		/*document.getElementById("json2").value = Dumper(customarray);*/

		/*document.getElementById("dbg1").value = 'arrItems1'+Dumper(arrItems);*/

		/*for(i in customarray['index11']){*/

			/*dbg= "\n1:"+customarray['index11'][i]+'-'+customarray['index12'][i]+'='+customarray['val1'][i];*/

		/*document.getElementById("dbg3").value =document.getElementById("dbg3").value+'-'+dbg;*/

			/*arrItems[customarray['index11'][i]][customarray['index12'][i]]=customarray['val1'][i];*/

			/*dbg= "\n2:"+customarray['index2'][i]+'='+customarray['val2'][i];*/

		/*document.getElementById("dbg3").value =document.getElementById("dbg3").value+'-'+dbg;*/

			/*arrDetails[customarray['index2'][i]]=customarray['val2'][i];*/

			/*dbg= "\n3:"+customarray['index31'][i]+'-'+customarray['index32'][i]+'='+customarray['val3'][i];*/

		/*document.getElementById("dbg3").value =document.getElementById("dbg3").value+'-'+dbg;*/

			/*arrItemsGrp[customarray['index31'][i]][customarray['index32'][i]]=customarray['val3'][i];*/

		/*}*/

	/*document.getElementById('rsWaiting').style.display='none';*/

	  /*document.getElementById("dbg2").value = 'arrItems'+Dumper(arrItems);*/

	/*}*/

	function do_model() 

	{

        // get current value of serial number field

        x = document.getElementById("serial").value;

		x = 1;

		document.getElementById('rsWaiting').style.display='block';

        //if length of autocomplete is zero, send the callback

        //an empty array to fill the autocomplete with-- there

        //is nothing to match.

        if (x.length==0)

           {return;}

        x_select_model(x, do_model_cb);

    }

	

	function appendItem() {
	
	//alert("appenditem");
		var x = 0;
		//var ID = document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].value;		
		var ID = document.forms['frm_abm'].elements['memberList'].value;
		while( x < selecItems.length){
	   		if (selecItems[x] == ID){return;}
	   		x++;
	   	} 
		selecItems[x] = ID;
		if(document.forms['frm_abm'].elements['similar'].length>=0 )
		{
			if (document.forms['frm_abm'].elements['memberList'].selectedIndex != -1) {				
			    document.forms['frm_abm'].elements['similar'].options[document.forms['frm_abm'].elements['similar'].options.length] =
				new Option(document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].text, 
					document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].value);
			} else {
				alert("Debe elegir un producto primero (lista izquierda)");
			}
		}else{
			alert("Error");
		}
	}
	
	function appendItem3() {
	
	//alert("appenditem");
		var x = 0;
		//var ID = document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].value;		
		var ID = document.forms['frm_abm'].elements['memberList2'].value;
		while( x < selecItems.length){
	   		if (selecItems[x] == ID){return;}
	   		x++;
	   	} 
		selecItems[x] = ID;
		if(document.forms['frm_abm'].elements['similar2'].length>=0 )
		{
			if (document.forms['frm_abm'].elements['memberList2'].selectedIndex != -1) {				
			    document.forms['frm_abm'].elements['similar2'].options[document.forms['frm_abm'].elements['similar2'].options.length] =
				new Option(document.forms['frm_abm'].elements['memberList2'].options[document.forms['frm_abm'].elements['memberList2'].selectedIndex].text, 
					document.forms['frm_abm'].elements['memberList2'].options[document.forms['frm_abm'].elements['memberList2'].selectedIndex].value);
			} else {
				alert("Debe elegir un producto primero (lista izquierda)");
			}
		}else{
			alert("Error");
		}
	}
	
	function appendItem2(name) {					//En caso de tener mas de una lista se pasa como parametro el nombre de la lista en donde insertar el item. Valida si ya existe.
	
		var list = document.getElementById(''+name+'');
		var options = list.options;
		var x = 0;

		while (x < options.length){
			if(document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].value == options[x].value){
				alert('Este elemento ya se encuentra asignado');
				return;
			}			
			x++;
		}

		if(document.forms['frm_abm'].elements[''+name+''].length>=0 )
		{
			if (document.forms['frm_abm'].elements['memberList'].selectedIndex != -1) {				
			    document.forms['frm_abm'].elements[''+name+''].options[document.forms['frm_abm'].elements[''+name+''].options.length] =
				new Option(document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].text, 
					document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].selectedIndex].value);
			} else {
				alert("Debe elegir un producto primero (lista izquierda)");
			}
		}else{
			alert("Error");
		}
	}

	

	function deleteItem(){



	if (document.frm_abm['similar[]'].selectedIndex != -1) {

			document.frm_abm['similar[]'].remove(document.frm_abm['similar'].selectedIndex);

			selecItems.splice(document.frm_abm['similar'].selectedIndex, 1);

		} else {

			alert("Debe elegir un elemento de la lista de la derecha para poder quitar"); //(d)

		}

	}

	function deleteItem2(name){
		if (document.frm_abm[''+name+'[]'].selectedIndex != -1) {
			document.frm_abm[''+name+'[]'].remove(document.frm_abm[''+name+''].selectedIndex);
			selecItems.splice(document.frm_abm[''+name+''].selectedIndex, 1);
		} else {
			alert("Debe elegir un elemento de la lista de la derecha para poder quitar"); //(d)
		}
	}
	
	function deleteItem3(){



	if (document.frm_abm['similar2[]'].selectedIndex != -1) {

			document.frm_abm['similar2[]'].remove(document.frm_abm['similar2'].selectedIndex);

			selecItems.splice(document.frm_abm['similar2'].selectedIndex, 1);

		} else {

			alert("Debe elegir un elemento de la lista de la derecha para poder quitar"); //(d)

		}

	}
	
	function append_word(idKeyWord){

	

		var quanty = arrItems.length;

		arrItems[quanty] = document.frm_abm['keyWord'].value;

		arrItemsGrp[quanty] = idKeyWord;

		new Option(document.forms['frm_abm'].elements['memberList'].options[arrItems[quanty]], 

					document.forms['frm_abm'].elements['memberList'].options[arrItemsGrp[quanty]])

	}

	

	function append_word_new(z){

		var tmp;

		var obj, obj1;

		

		tmp = z.replace(/\+\:/,'');

		//tmp = z.substring(1);

		eval("var id = " + tmp);	

	    obj = document.getElementById('memberList');	    

	    var quanty = obj.length;

		document.forms['frm_abm'].elements['memberList'].options[document.forms['frm_abm'].elements['memberList'].options.length] =

				new Option(document.forms['frm_abm'].elements['keyWord'].value,id);		

		document.forms['frm_abm'].elements['keyWord'].value="";			

	}

	

	function newKeyWord(){	

	    var keyWord = window.document.frm_abm.elements['keyWord'].value;

	    if (keyWord == ""){

		    alert("Debe ingresar una Palabra Clave");   

		}else{	

			x_select_detail(keyWord, append_word_new);

		}

	}



    function filtrar_contenidos(texto){		

          document.getElementById('rsWaiting').style.display='block';

          x_filtrar_contenidos(texto, items_filtrados);

	}

	

	function in_array (valor, matriz) {	

	  var texto = "¬" + matriz.join("¬") + "¬";	

	  var er = new RegExp ("¬" + valor + "¬", "gim");	

	  return ( (texto.match (er)) ? true : false );	

	}

	

	function agrup_items(z){

	    var tmp;

		tmp = z.replace(/\+\:/,'');

		//tmp = z.substring(1);		

	    eval("var customarray = "+tmp);   	

        var arr = arrItemsGrp;

    	for(x in customarray['val1']){

	    	if (!in_array(arrItemsGrp, arrItemsGrp)){

	    	     tmp = arrItemsGrp; 

	    		 arrItemsKey.push(customarray['val3'][x]);

	    		 arrItemsNam.push(customarray['val1'][x]);	

	    	}

	    }	

	    mostrar_contenidos();

	}

	

	function mostrar_contenidos(){

	var conf;

	var arrTmp = new Array();

	var arrTmpGrp = new Array();

	var hasta = arrItemsGrp[0];

		

	

		//filtro

		for (x=0; x < hasta; x++){

		    conf = arrItems[x]; 

			arrTmp.push(conf);

			conf = arrItemsGrp[x];

			arrTmpGrp.push(conf);

		}

        arrItems =  Array();

        arrItemsGrp = Array();

		//actualizo los arreglos arrItems y arrItemsGrp

		for (i in arrItemsKey) {

          for(x=0; x<arrTmpGrp.length; x++){		

			if (arrItemsKey[i] == arrTmpGrp[x]){ 

		  		arrItems[i] = arrItemsNam[i]; //Palabras claves

		  		arrItemsGrp[i] = arrItemsKey[i]; //ID de las palabras claves

		  	}

		  } 

		}

	//----		

		create_options();

	}



   function nada(id){

//alert(window.document.forms['frm_abm'].elements['short'].value);

    window.document.forms['frm_abm'].elements['titulo'].value = "";

	window.document.forms['frm_abm'].elements['file'].value = "";

	window.document.forms['frm_abm'].elements['link'].value = "";

	window.document.forms['frm_abm'].elements['short'].value = "";

   }		

	

	function filtrar_palabras(ids){

		  document.getElementById('rsWaiting').style.display='block';

		  arrItemsKey = new Array();

		  arrItemsNam = new Array();

		  //corto el string

		  arrIDs = ids.split(',');

		  for (x=0; x<arrIDs.length; x++){

          	x_filtrar_palabras(arrIDs[x], agrup_items);

          }

	}



	function getBanners(id){

		document.getElementById('rsWaiting').style.display='block';

	   

        //busco las palabras claves y cargo los arreglos arrItems y arrItemsGrp

	    x_select_banners(id, put_items);

	}

   /*

   function setCategoria(arr){

   	var tmp;

		tmp         = arr.substring(1); //Parche por que z viene con ":" adelate.

		eval("var customarray = " + tmp); // customarray se llama el arreglo mejorado



		controlToPopulate = 	window.document.getElementById('subcategoria');



		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

		

		for ( x = 0 ; x < customarray['arr_id'].length  ; x++ )

		{

			if (typeof(customarray['arr_id']) != "undefined" &&  customarray['arr_id']!="")

			{



				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(customarray['arr_values'][x],customarray['arr_id'][x]);

			}

		}			

   }

   */

      function setCategoria(arr){

   	var tmp;

		tmp = arr.replace(/\+\:/,'');

		//tmp = arr.substring(1); //Parche por que z viene con ":" adelate.

		eval("var customarray = " + tmp); // customarray se llama el arreglo mejorado



		controlToPopulate = 	window.document.getElementById('subcategoria');



		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

		

		controlToPopulate.options[0] = new Option("Seleccione una subcategoría","-1");

		

		for ( x = 0 ; x < customarray['arr_id'].length  ; x++ )

		{

			if (typeof(customarray['arr_id']) != "undefined" &&  customarray['arr_id']!="")

			{



				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(customarray['arr_values'][x],customarray['arr_id'][x]);

			}

		}			

   }

   

   function filtroCategoria(id){

   		x_getSubcategories(id, setCategoria);

   }

   

   function setSubCategoria(arr){

	var tmp;

		tmp = arr.replace(/\+\:/,'');

		//tmp = arr.substring(1); //Parche por que z viene con ":" adelate.

		eval("var customarray = " + tmp); // customarray se llama el arreglo mejorado



		controlToPopulate = 	window.document.getElementById('technology');



		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

		

		for ( x = 0 ; x < customarray['arr_id'].length  ; x++ )

		{

			if (typeof(customarray['arr_id']) != "undefined" &&  customarray['arr_id']!="")

			{



				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(customarray['arr_values'][x],customarray['arr_id'][x]);

			}

		}			   

   }

   

   function filtroSubCategoria(id){

   		x_getTechnology(id, setSubCategoria);

   }

      

   function	new_SetSession(){   
   		if (Edit == 'New'){

	   		var block = window.document.forms['frm_abm'].elements['id_block'].value;

	   		var content = window.document.forms['frm_abm'].elements['memberList'].value;

	   		var titulo = window.document.forms['frm_abm'].elements['titulo'].value;

	   		var instance = window.document.forms['frm_abm'].elements['memberList'].options.selectedIndex;

	   		var path = window.document.forms['frm_abm'].elements['file'].value;

	   		var link = window.document.forms['frm_abm'].elements['link'].value;

	   		var sht = document.forms['frm_abm'].elements['short'].value;

	   		var title_content = window.document.forms['frm_abm'].elements['memberList'].options[window.document.forms['frm_abm'].elements['memberList'].options.selectedIndex].text;

   		}else{

	   		var block = window.document.forms['frm_abm'].elements['id_block'].value;

	   		var content = window.document.forms['frm_abm'].elements['similar'].value;

	   		var titulo = window.document.forms['frm_abm'].elements['titulo'].value;

	   		var instance = window.document.forms['frm_abm'].elements['similar'].options.selectedIndex;

	   		var path = window.document.forms['frm_abm'].elements['file'].value;

	   		var link = window.document.forms['frm_abm'].elements['link'].value;

	   		var sht = document.forms['frm_abm'].elements['short'].value;

	   		var title_content = window.document.forms['frm_abm'].elements['similar'].options[window.document.forms['frm_abm'].elements['similar'].options.selectedIndex].text;

   		}

   		/*var nuevo = new Array();   		   		

   		nuevo[0] = block;

   		nuevo[1] = content;

   		nuevo[2] = titulo;

   		nuevo[3] = instance + 1;

   		nuevo[4] = path;

   		nuevo[5] = link;

   		nuevo[6] = sht;
   		
//   		alert(sht);

   		nuevo[7] = title_content;*/

   		

		//x_setSessionVar(nuevo, nada);  asi llemaba cuando habia problemas de coma

		x_setSessionVar(block,content,titulo,instance,path,link,sht,title_content, nada);

   }

 
   function editData(campos){
	
	var tmp;
	var str;
	tmp = campos.replace(/\+\:/,'');	
	tmp = campos.substring(1);
//	tmp = campos.substring(1);
	eval("var customarray = " + tmp);	
	
	window.document.forms['frm_abm'].elements['titulo'].value = replaceSubstring(customarray.tittle,"\\","");

	window.document.forms['frm_abm'].elements['file'].value = customarray.path_image;

	window.document.forms['frm_abm'].elements['link'].value = customarray.link_instance;
	
	window.document.forms['frm_abm'].elements['short'].value =  customarray.description_short;	
//	alert(customarray.description_short);
   }
   
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function


   function loadDataInstance(id){   

		var id = window.document.forms['frm_abm'].elements['similar'].value;   

		var id_block = window.document.forms['frm_abm'].elements['id_block'].value;

 		x_loadDataInstance(id, id_block, editData);  

   }

   

   function postHidded(id){

   	var tmp;

   	var hidden = document.getElementById('ID');

   	var nbrHid = hidden.value;

	tmp = id.replace(/\+\:/,'');

	tmp = id.substring(1);

	eval("var customarray = " + tmp);	

	obj = document.getElementById(nbrHid);

	obj.value = customarray.id_module;

	obj.name = customarray.name_hidden;
	
   }

   

   function defaultFunction(id){

    return false;

   }

   

   function newModule(name){

		  //llamo una funcion que cree un modulo y modifique el valor del hidden

		  x_setHidden(name, postHidded);

   }

   

   function delete_Module(name){

   			var id_module = window.document.forms['frm_preview'].elements['id_module'+name].value;

	   		x_concatIdModule(id_module, defaultFunction);

   }

   

   function checkErrorFields(out){

	 out = out.replace(/\+\:/,'');  

   	out = out.substring(1); 

   	 eval("var out = " + out); 

   	 if (out.length>0){ 

   	 	alert("Error | No se han completados los campos requeridos para los contenidos a publicar:\n Revise los items an la posición nro. "+out);

   	 }

		else{			

			closeWindow();			

		}



   }

   

   function fieldCheck(){

	 var id = window.document.forms['frm_abm'].elements['id_block'].value;	

   	 x_fieldCheck(id, checkErrorFields);

   }



   function create(){

 		controlToPopulate=document.forms['frm_banners'].elements['bnrId'];

		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;		

		for ( x = 0 ; x < arrIdBanner.length  ; x++ )

		{

			if (typeof(arrNameBanner[x]) != "undefined" &&  arrNameBanner[x]!="")

			{

				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(arrNameBanner[x],arrIdBanner[x]);

			//	alert(arrItems[x]);

			}

		}				

		document.getElementById('rsWaiting').style.display='none';

	}

   

   

   function setBanners(z){

   var tmp;

		tmp = z.replace(/\+\:/,'');   

		tmp = z.substring(1); //Parche por que z viene con ":" adelate.

		eval("var customarray = " + tmp);		

		//actualizo los arreglos arrItems y arrItemsGrp

		for (i in customarray['val1']) {

		  arrIdBanner[i]    = customarray['val1'][i]; 

		  arrNameBanner[i]  = customarray['val2'][i];

		  arrTypeBanner[i]  = customarray['val3'][i];

		}

		//creo las options en el select

		create();

   }

   

   function filterCompany(id){

		document.getElementById('rsWaiting').style.display='block';

		x_filterCompany(id, setBanners);

   }	

   

   function filTBanner(){

   		document.getElementById('rsWaiting').style.display='block';

   		IDS = document.getElementById('spoId');

   		IDT = document.getElementById('tbnId');

   		var params = new Array();

   		params[0]= IDT.options[IDT.selectedIndex].value;

   		params[1]= IDS.options[IDS.selectedIndex].value;

		x_filterTypeBanner(params, setBanners);

   }

   

   	//*******************************************************************************

	//Jose

	//*******************************************************************************



	function userExists(userNameyMailyId, email){

		return x_userExistsDB(userNameyMailyId,resultUserExists);

	}


	function resultUserExists(rValue){
	//alert("rvalue (before): "+rValue);
	//rValue = rValue.substring(1);		
	
	if (rValue.substring(1,3)=="+:")	rValue=rValue.substring(3,4);		
	else if (rValue.substring(0,1)==":")   rValue=rValue.substring(1);		
	
	//alert("rValue (after): "+rValue);	
		
	if (rValue == 1)	alert("El nombre de usuario ingresado ya existe o es inválido. Selecciona otro.");
	else if (rValue == 3)	alert("Ya existe un usuario registrado con este correo electronico, por favor ingresa otro.");
	else enviar();	
	
	//multipleSubmit(); //modificado porque no se consulta en el foro para la registracion		
	return false;

	}
	
	function enviar(){				
		//if(document.getElementById("image").value!="") document.getElementById("prfAvatar").value=document.getElementById("image").value;
		var edit = document.getElementById("edit").value;
		var pass = document.getElementById("password_aux").value;
	
		if(edit != "true" || (edit == "true" && pass != "")){
			document.getElementById("usrPassword").value	=	hex_md5(document.getElementById("password_aux").value);
			document.getElementById("password_aux").value	=	"";
			document.getElementById("preusrPassword").value =	"";		
		} 		
		
		document.register_frm.submit();
		
		return false;
	}



	function emailExist(email){

		x_emailExistDB(email,resultEmailExist);

	}	
	function resultEmailExist(rValue){		
		if (rValue==0){
			return true;
			//esta en modules/registration/templates/frontend_registration_gammers.html
		}
		else{	
			alert("Ya existe un usuario registrado con este correo electronico, por favor ingresa otro.");	
			return false;
		}
	}
	/**Envia el arreglo JS de rutas de imagenes*/

	function checkImagesSizes(section,images){

		x_checkImagesSizesPHP(section,images,resultCheckImagesSizesPHP);

	}

	

	function resultCheckImagesSizesPHP(rValue){
		rValue = rValue.replace(/\+\:/,'');	

		if (rValue.substring(1,3)=="+:")
		rValue=rValue.substring(3,4);		
		else
	    if (rValue.substring(0,1)==":")
		rValue=rValue.substring(1);		

		if(rValue.length==0)
		{	window.document.forms[0].submit();
			//document.forms[0].submit();
		}
		else 
			alert(rValue);	
	}

	

	/**Envia el arreglo JS de rutas de imagenes para la creacion de usuario*/

	function checkImagesSizesUser(section,images){

		

		x_checkImagesSizesPHP(section,images,resultCheckImagesSizesUserPHP);

	}

	

	function resultCheckImagesSizesUserPHP(rValue){

		rValue = rValue.replace(/\+\:/,''); 



		/*

		if (rValue.substring(1,3)=="+:")

		rValue=rValue.substring(3,4);		

		else

		    if (rValue.substring(0,1)==":")

		rValue=rValue.substring(1);		

		*/

		if(rValue=="")

			loginForo();

		else 

			alert(rValue);	

	}

		

		

	function create_options2control(controlToPopulate){

	    

		for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

		

		for ( x = 0 ; x < arrItemsRBR.length  ; x++ )

		{

			if (typeof(arrItemsRBR[x]) != "undefined" &&  arrItemsRBR[x]!="")

			{

				controlToPopulate.options[controlToPopulate.options.length] =

				new Option(arrItemsRBR[x],arrItemsGrpRBR[x]);

			}

		}				

		document.getElementById('rsWaiting').style.display='none';

	}

	

	//carga el combo de rubros desde php

	function populate_rubros(z){//agregado

		

		//vacio los rubros actuales:

		remAllSelect(document.getElementById('rbrId'));



		//cargo los rubros nuevos

		var tmp;

		//tmp = z.substring(1); //Parche por que z viene con ":" adelate.

		//if (z.substring(1,3)=="+:")

		//	tmp=z.substring(3);	

		tmp = z.replace(/\+\:/,'');

        arrItemsRBR = Array();

		eval("var customarray = " + tmp);

		

		//actualizo los arreglos arrItems y arrItemsGrp

		for (i in customarray['val1']) {

		  arrItemsRBR[i]    = customarray['val1'][i]; //Palabras claves

		  arrItemsGrpRBR[i] = customarray['val3'][i]; //ID de las palabras claves

		}

				

		//creo las options en el select de rubro

		create_options2control(document.getElementById('rbrId'));

		

		document.getElementById('rsWaitingRubros').style.display='none';

	}

	

	

	function remAllSelect(sel) //agregado

		{ 

		var len=sel.length;

		while(len>=0)  sel[len--] = null;

	}

	

	//**************************************************************************

	//Victoria

	//**************************************************************************

	 function validarUser(user){

	  		x_validar_user(user, llenarMensaje);

		  	

	 }

	  

	 function llenarMensaje(usr){
	 	if(usr.substring(1) == 1){
		  	alert('ERROR: el usuario ya existe');
		  	return;
		}
		//alert('ok');
		//window.document.prueba.usrName.value="index.php";
		window.document.prueba_frm.submit();
	}

	
	//selecciona una categoría  en el combo y carga el combo de rubros de esa categoria
	//JOSE
	function selectChangeCategory(category)
	{ document.getElementById('rsWaitingRubros').style.display='block';
	  x_select_change_category(category, populate_rubros);
	}

