ï»¿//Sección menú izquierdo
function div_toggle(name){
	divElem = document.getElementById(name);
	if (divElem.style.display == 'block')
	{
		divElem.style.display = 'none';
	}
	else if (divElem.style.display == 'none')
	{
		divElem.style.display = 'block';
	}
}

function tiene_punto(){

var texto= document.getElementsByName("att_input_231_295")[0].value;
   textoB = texto.toLowerCase();
   textoA = texto.toUpperCase();
   
document.getElementsByName("att_input_231_295")[0].value = tratamiento(textoB); //texto;

var texto= document.getElementsByName("att_input_235_295")[0].value;
   textoB = texto.toLowerCase();
   textoA = texto.toUpperCase();
   
document.getElementsByName("att_input_235_295")[0].value = tratamiento(textoB); //texto;
}
   
function tratamiento(textoB){   
   var punto='.';
   var i=0;
   var texto=' ';
   texto = textoA.charAt(i);
   for(i=1;i<=textoB.length; i++){
      if (textoB.charAt(i)==punto){
		 texto += textoB.charAt(i);
		for(i=i+1;textoB.charAt(i)==" " || textoB.charAt(i)=="\n";i++){
           texto += textoB.charAt(i);}
        texto += textoA.charAt(i);
      }
      else
      { texto += textoB.charAt(i);}
   }
   return texto;
}

function tiene_punto_dem(){

var texto= document.getElementsByName("att_input_248_305")[0].value;
   textoB = texto.toLowerCase();
   textoA = texto.toUpperCase();
   
document.getElementsByName("att_input_248_305")[0].value = tratamiento(textoB); //texto;

var texto= document.getElementsByName("att_input_249_305")[0].value;
   textoB = texto.toLowerCase();
   textoA = texto.toUpperCase();
   
document.getElementsByName("att_input_249_305")[0].value = tratamiento(textoB); //texto;

var texto= document.getElementsByName("att_input_251_305")[0].value;
   textoB = texto.toLowerCase();
   textoA = texto.toUpperCase();
   
document.getElementsByName("att_input_251_305")[0].value = tratamiento(textoB); //texto;
}

function div_change_class(name)
{
	divElem = document.getElementById(name);
	if(divElem.className == 'menu_no_select')
	{
		divElem.className = 'menu_select';
	}
	else if(divElem.className == 'menu_select')
	{
		divElem.className = 'menu_no_select';
	}
}

function top_level_menu_click(menu_id, submenu_id, hide_all_first)
{
	if(hide_all_first)//Ocultar todos los menús para que sólo se vea desplegado el que se selecciona. 
	{
		var num_menus = 9;
		var divElem;
		for(i = 1; i <= num_menus; i++)
		{
			divElem = document.getElementById('submenu_div_' + i);
			if(divElem != null)
			{
				divElem.style.display = 'none';
			}
			divElem = document.getElementById('menu_item_' + i);
			if(divElem != null)
			{
				divElem.className = 'menu_no_select';
			}
		}
	}
	div_change_class(menu_id);
	div_toggle(submenu_id);
}
//fin sección menu izquierdo

//Eliminar inscritos de los cursos
function DeleteInsc(sVerId)
{
	if (!confirm("¿Eliminar del curso actual?")) return;
	var oAjax = new WBE_AjaxClass();
	oAjax.clear();
	oAjax.addPostParameter("ver_id", sVerId);
	oAjax.throwEvent2("cms_delete_version");
	document.location.reload();
}

//Si no hay categoría seleccionada se obliga a que se seleccione una
function ComprobarURL_Categorias(cat_select)
{
	var s = window.location.href;
	if(s.match(/cat_id/) == null)
	{
		window.location.href += '?cat_id=' + cat_select;
	}
		
}

function DescargaProgTrimestral()
{
	var sel = document.getElementById('selProv');
	var dir = sel[sel.selectedIndex].value;
	var win = window.open(dir,'Programacion','');
	if(win == null)
	{
		alert('La descarga no se ha iniciado. Posiblemente su explorador bloquee las ventanas emergentes. Debe permitir las ventanas emergentes del sitio IVAFE para continuar con la descarga.');
	}
}

//PARA LA SECCIÓN SERVICIOS
function Servicio_Click(serv_id)
{
	var num_serv = 7;
	var divElem;
	for(i = 1; i <= num_serv; i++)
	{
		divElem = document.getElementById('serv_div_' + i);
		if(divElem != null)
		{
			divElem.style.display = 'none';
		}
		divElem = document.getElementById(serv_id);
		if(divElem != null)
		{
			divElem.style.display = 'block';
		}
	}
}

//PARA LA FICHA
function Cont_Prog_clic(div)
{
	
	if(div == 'div_cont')
	{
		if(document.getElementById('div_cont').style.display == 'block')
		{
			document.getElementById('div_cont').style.display = 'none';
			document.getElementById('div_cont_info').style.display = 'block';
		}
		else
		{
			document.getElementById('div_cont').style.display = 'block';
			document.getElementById('div_cont_info').style.display = 'none';
			document.getElementById('div_prog').style.display = 'none';
			document.getElementById('div_prog_info').style.display = 'block';
		}
	}
	else
	{
		if(document.getElementById('div_prog').style.display == 'block')
		{
			document.getElementById('div_prog').style.display = 'none';
			document.getElementById('div_prog_info').style.display = 'block';
		}
		else
		{
			document.getElementById('div_cont').style.display = 'none';
			document.getElementById('div_cont_info').style.display = 'block';
			document.getElementById('div_prog').style.display = 'block';
			document.getElementById('div_prog_info').style.display = 'none';
		}
	}
}

//PARA MOSTRAR MENSAJE EN CATEGORÍAS QUE QUIERE EL CLIENTE EN VEZ DE RESULTADOS DE BUSQUEDA
function Cat_Pers(cat)
{
	alert(cat);
	if(cat == 37)
	{
		document.getElementById('texto_categorias').style.display = 'none';
		document.getElementById('mensaje_medida').style.display = 'block';
	}	
}


/*function Put_prog_on_form(cur, tipo, horas, fini, ffin, fin_mat, prov)
{
	document.getElementById('text_136_133').style.display = 'none';
	document.getElementById('att_input_136_133').style.display = 'none';
	document.getElementById('att_input_136_133').value = 'Curso: ' + cur + ' | Tipo: ' + tipo + ' | Horas: ' + horas + ' | Inicio: ' + fini + ' | Fin: ' + ffin + ' | Fin matriculacion: ' + fin_mat + ' | Provincia: ' + prov  ;	
	
}*/


//Pone en el form de pre-inscripción a qué programación se está matriculando el alumno para que llegue en el e-mail
function Put_prog_on_form()
{
	var cur = document.getElementById('h_curso').value;
	var tipo = document.getElementById('h_tipo').value;
	var horas = document.getElementById('h_horas').value;
	var fini = document.getElementById('h_ini').value;
	var ffin = document.getElementById('h_fin').value;
	var fin_mat = document.getElementById('h_mat').value;
	var prov = document.getElementById('h_prov').value;
	var oObj = document.getElementById('text_136_133');
	if (oObj) oObj.style.display = 'none';
	oObj = document.getElementById('att_input_136_133');
	if (oObj) oObj.style.display = 'none';
	oObj = document.getElementById('att_input_136_133');
	if (oObj) oObj.value = 'Curso: ' + cur + ' | Tipo: ' + tipo + ' | Horas: ' + horas + ' | Inicio: ' + fini + ' | Fin: ' + ffin + ' | Fin matriculacion: ' + fin_mat + ' | Provincia: ' + prov  ;	
}

/*function Trans(text)
{
	var resul = text.replace(/%20/g, ' ');
	resul = resul.replace(/%C3%81/g, 'A');//Á
	resul = resul.replace(/%C3%A1/g, 'a');//á
	resul = resul.replace(/%C3%89/g, 'E');//É
	resul = resul.replace(/%C3%A9/g, 'e');//é
	resul = resul.replace(/%C3%8D/g, 'I');//Í
	resul = resul.replace(/%C3%AD/g, 'i');//í
	resul = resul.replace(/%C3%93/g, 'O');//Ó
	resul = resul.replace(/%C3%B3/g, 'o');//o
	resul = resul.replace(/%C1/g, 'O');//Ó
	resul = resul.replace(/%C3%9A/g, 'U');//Ú
	resul = resul.replace(/%C3%BA/g, 'u');//ú
	resul = resul.replace(/%C3%91/g, 'N');//Ñ
	resul = resul.replace(/%C3%B1/g, 'n');//ñ	
	
	return resul;
}*/

//Ocultar buscador y listado para las categorias que ha mandado el cliente
function Show(num)
{
	//Comprobar null porque dependiendo del listado hay elementos que estan o no
	var span_aux = document.getElementById('cat_36');
	if(span_aux != null) span_aux.className = 'not_selected';
	
	span_aux = document.getElementById('cat_37');
	if(span_aux != null) span_aux.className = 'not_selected';
	
	//El 38 y 39 en realidad no haria falta porque siempre estan
	span_aux = document.getElementById('cat_38');
	if(span_aux != null) span_aux.className = 'not_selected';
	
	span_aux = document.getElementById('cat_39');
	if(span_aux != null) span_aux.className = 'not_selected';
	
	span_aux = document.getElementById('cat_42');
	if(span_aux != null) span_aux.className = 'not_selected';
	
	span_aux = document.getElementById('cat_43');
	if(span_aux != null) span_aux.className = 'not_selected';
	
	document.getElementById('buscador_cursos').style.display = 'none';
	
	
	if(num == 1)
	{
		document.getElementById('cat_38').className = 'cat_actual';
		document.getElementById('texto_categorias').innerHTML = '<div id="men_pers"><p><strong>Los programas de Formaci&oacute;n IN COMPANY se desarrollan a medida<br /> para la empresa.</strong></p><p><strong><a href="formacion_empresarial.html?cat_id=31">M&aacute;s informaci&oacute;n</a></strong></p></div>';
	}
	else
	{
		document.getElementById('cat_39').className = 'cat_actual';
		document.getElementById('texto_categorias').innerHTML = '<div id="men_pers"><p><strong>Los programas de Formaci&oacute;n ONE TO ONE  se desarrollan a medida<br /> para la empresa.</strong></p><p><strong><a href="formacion_empresarial.html?cat_id=32">M&aacute;s informaci&oacute;n</a></strong></p></div>';
	}
}

/*Sección para vídeos streaming*/
function pon_video_repeat(video,div, ancho, alto)
{
	AC_FL_RunContent(div,'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width',ancho,'height',alto,'src','/config/flvideo/flvplayer','quality','high','wmode','transparent','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','/config/flvideo/flvplayer','flashvars','file='+video+'&autostart=false&repeat=false');
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
 if (src.indexOf('?') != -1)
 return src.replace(/\?/, ext+'?');
 else
 return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs,div)
{
 var str = '<object ';
 for (var i in objAttrs)
 str += i + '="' + objAttrs[i] + '" ';
 str += '>';
 for (var i in params)
 str += '<param name="' + i + '" value="' + params[i] + '" /> ';
 str += '<embed ';
 for (var i in embedAttrs)
 str += i + '="' + embedAttrs[i] + '" ';
 str += ' ></embed></object>';
 if (div=='') {
 document.write(str);
 }
 else {
 document.getElementById(div).innerHTML=str;
 }

}

function AC_FL_RunContent(){
 var ret =
 AC_GetArgs
 ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 , "application/x-shockwave-flash"
 );
 var div=arguments[0];
 AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs,div);
}

function AC_SW_RunContent(){
 var ret =
 AC_GetArgs
 ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
 , null
 );
 var div=arguments[0];
 AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs,div);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
 var ret = new Object();
 ret.embedAttrs = new Object();
 ret.params = new Object();
 ret.objAttrs = new Object();

 for (var i=1; i < args.length; i=i+2){
 var currArg = args[i].toLowerCase();

 switch (currArg){
 case "classid":
 break;
 case "pluginspage":
 ret.embedAttrs[args[i]] = args[i+1];
 break;
 case "src":
 case "movie":
 args[i+1] = AC_AddExtension(args[i+1], ext);
 ret.embedAttrs["src"] = args[i+1];
 ret.params[srcParamName] = args[i+1];
 break;
 case "onafterupdate":
 case "onbeforeupdate":
 case "onblur":
 case "oncellchange":
 case "onclick":
 case "ondblClick":
 case "ondrag":
 case "ondragend":
 case "ondragenter":
 case "ondragleave":
 case "ondragover":
 case "ondrop":
 case "onfinish":
 case "onfocus":
 case "onhelp":
 case "onmousedown":
 case "onmouseup":
 case "onmouseover":
 case "onmousemove":
 case "onmouseout":
 case "onkeypress":
 case "onkeydown":
 case "onkeyup":
 case "onload":
 case "onlosecapture":
 case "onpropertychange":
 case "onreadystatechange":
 case "onrowsdelete":
 case "onrowenter":
 case "onrowexit":
 case "onrowsinserted":
 case "onstart":
 case "onscroll":
 case "onbeforeeditfocus":
 case "onactivate":
 case "onbeforedeactivate":
 case "ondeactivate":
 case "type":
 case "codebase":
 ret.objAttrs[args[i]] = args[i+1];
 break;
 case "width":
 case "height":
 case "align":
 case "vspace":
 case "hspace":
 case "class":
 case "title":
 case "accesskey":
 case "name":
 case "id":
 case "tabindex":
 ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
 break;
 default:
 ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
 }
 }
 ret.objAttrs["classid"] = classid;
 if (mimeType) ret.embedAttrs["type"] = mimeType;
 return ret;
}

/*Recoger parametros de la URL y relacionar formulario con contenido programación
function InfoCursoRel()
{
	/*var Url = window.location.href;
	if(Url.match(/formulario_de_inscripcion/) != null)
	{
		
		//Recoger variables de la url (variables id, ref, cur, fini, fin, prov)
		Url = Url.replace(/.*\?(.*?)/,"$1");
		Variables = Url.split ("&");
		for (i = 0; i < Variables.length; i++)
		{
			Separ = Variables[i].split("=");
			eval ('var '+Separ[0]+'="'+Separ[1]+'"');
		}
		//fin recoger variables
		cur = Format_Url_Text(cur);
		prov = Format_Url_Text(prov);
		//obj.relationshipContentId = id;
		var info = 'Se est&aacute; inscribiendo al siguiente curso:<br />';
		info += 'Nombre del curso: <strong>' + cur + '</strong><br />';
		//info += 'Referencia: <strong>' + ref + '</strong>';
		info += 'Fecha inicio<strong> ' + fini + '</strong>  Fecha fin<strong> ' + ffin + '</strong>  Provincia<strong> ' + prov + '</strong>';alert(info);
		//document.getElementById('info_curso_form').innerHTML = info;
	}
}*/
/*
function __BtnPrivacidad(obj)
	divButton = document.getElementById('div_2_hide');
	inputButton = document.getElementById('input_send');
	
	if (obj.checked) inputButton.disabled = '';
	else inputButton.disabled = 'disabled';
}
*/
// Contenidos Padre, si los hay
function __saveInscripcionRelations (oFormBuilder, oAjax) {
	oAjax.addPostParameter('cnt_parent_relship', this.relationshipContentId);
	// Attributo de precio
	oAjax.addPostParameter('att_input_268', this.price);
}

function __inscribirseCurso(objJS, iPrice, iParent) {
	var oSelect = document.forms[0].sel_pais;

	// Pone el precio de inscripción en el formulario
	var iFinalPrice = (iPrice!=null) ? iPrice : 0;
	
	if (document.forms[0].att_input_266_133[0].selected){
		alert('Por favor, debe seleccionar una opciÃ³n de cÃ³mo conociÃ³ el curso.');
		document.forms[0].att_input_266_133[0].focus();							
		return false;
	}

	// aÃ±ade el precio como valor de atributo y el curso seleccionado.
	objJS.setContentParents = __saveInscripcionRelations;
	objJS.relationshipContentId = iParent;
	 
	if (iFinalPrice>0) {
		var iPP = '' + (iFinalPrice/100);
		objJS.price = iPP;
		iPP = iPP.replace('.',',');
		objJS.useEvent='cms_content_save_subscription_dont_pub';
		objJS.saveSubscription(iPP, null);
	} else {
		objJS.saveAndGo('preinscripcion_ok.html');
	}
	
}
