function AgregarAlCarro(){
	document.forms['ComprarProductosForm'].submit();
}

function AgregarAlCarro(){
	var i; var cuenta = 0;
	var obj_Radio = document.getElementsByName('wh_periodo');
	for (i=0;i<obj_Radio.length;i++){
		if(obj_Radio[i].checked){ cuenta = cuenta + 1; }
	}
	if((xGetElementById('PlataformaHosting').value == '') && (cuenta > 0)){
		setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_1');
		alert('Por favor, seleccione una plataforma para su web hosting.\n\nSi tiene dudas respecto a que plataforma es más conveniente para Usted, haga click en el ícono de ayuda del bloque Selección de Plataforma o consulte con nuestros operadores de Asistencia en Línea.');
	}else{
		document.forms['ComprarProductosForm'].submit();
	}
}

function CambiarPlataforma(Plataforma){
	xGetElementById('PlataformaHosting').value = Plataforma;
	setClass(xGetElementById('select_plataforma_div_Windows'),'select_plataforma_0');
	setClass(xGetElementById('select_plataforma_div_Linux'),'select_plataforma_0');
	setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_0');
	xGetElementById('select_plataforma_ic_Windows').src = Images_Protocolo+':\/\/'+Images_HostName+'/'+idiomaActual+'/imagenes/select_plataforma_ic_w_0.jpg';
	xGetElementById('select_plataforma_ic_Linux').src = Images_Protocolo+':\/\/'+Images_HostName+'/'+idiomaActual+'/imagenes/select_plataforma_ic_l_0.jpg';
	setClass(xGetElementById('select_plataforma_div_'+Plataforma),'select_plataforma_1');
	xGetElementById('select_plataforma_ic_'+Plataforma).src = Images_Protocolo+':\/\/'+Images_HostName+'/'+idiomaActual+'/imagenes/select_plataforma_ic_'+(Plataforma.toLowerCase()).charAt(0)+'_1.jpg';
}

function MarcarSeleccion(id,periodo){
	ResetearSeleccion();
	setClass(xGetElementById('wh_plan_head_'+id),'wh_plan_head_selected');
	setClass(xGetElementById('wh_plan_content_'+id),'wh_plan_content_selected');
	if(xGetElementById('wh_masvendido_td_'+id)){
		if(xGetElementById('wh_masvendido_td_'+id).className == 'wh_masvendido_td_0'){
			setClass(xGetElementById('wh_masvendido_td_'+id),'wh_masvendido_td_1');
		}
	}
	setClass(xGetElementById('wh_periodo_tr_'+id+'--'+periodo),'wh_periodo_tr_selected');
	show('bt_comprarhosting_container_'+id);
}

function ResetearSeleccionInicial(){
	ResetearSeleccion();
	var obj_Radio = document.getElementsByName('wh_periodo'); var i; var Datos=''; var Datos2='';
	for (i=0;i<obj_Radio.length;i++){
		if(obj_Radio[i].checked){ obj_Radio[i].checked = false; }
	}
}

function ResetearSeleccion(){
	var obj_Radio = document.getElementsByName('wh_periodo'); var i; var Datos=''; var Datos2='';
	for (i=0;i<obj_Radio.length;i++){
		Datos = obj_Radio[i].id;
		Datos = Datos.substring(15);
		Datos2 = Datos.split("--");
		if(xGetElementById('bt_comprarhosting_container_'+Datos2[0]).style.display!="none"){
			hide('bt_comprarhosting_container_'+Datos2[0]);
		}
		if(xGetElementById('wh_plan_head_'+Datos2[0]).className == 'wh_plan_head_selected'){
			setClass(xGetElementById('wh_plan_head_'+Datos2[0]),'wh_plan_head');
		}
		if(xGetElementById('wh_periodo_tr_'+Datos).className == 'wh_periodo_tr_selected'){
			setClass(xGetElementById('wh_periodo_tr_'+Datos),'wh_periodo_tr');
		}
		if(xGetElementById('wh_masvendido_td_'+Datos2[0])){
			if(xGetElementById('wh_masvendido_td_'+Datos2[0]).className == 'wh_masvendido_td_1'){
				setClass(xGetElementById('wh_masvendido_td_'+Datos2[0]),'wh_masvendido_td_0');
			}
		}
		if(xGetElementById('wh_plan_content_'+Datos2[0]).className == 'wh_plan_content_selected'){
			setClass(xGetElementById('wh_plan_content_'+Datos2[0]),'wh_plan_content');
		}
	}
}

function SelectSugerido(producto) {
	var ClickDefault = '';
	if(xGetElementById('compra_sugerido_cbx_'+producto).checked){
		setClass(xGetElementById('compra_sugerido_div_'+producto),'wh_sugerido_compra_selected');
		show('compra_sugerido_periodo_'+producto);
		switch(producto){
			case 'SSL':
				ClickDefault = wh_SSL_periodo_selected;
				break;
			case 'DATTARADIO':
				ClickDefault = wh_DATTARADIO_periodo_selected;
				break;
			case 'IP':
				ClickDefault = wh_IP_periodo_selected;
				break;
			default:
				ClickDefault = '';
				break;
		}
		xGetElementById(ClickDefault).click();
	}else{
		setClass(xGetElementById('compra_sugerido_div_'+producto),'wh_sugerido_compra');
		hide('compra_sugerido_periodo_'+producto);
		ResetSugerido(producto);
	}
}

function ResetSugerido(producto) {
	var obj_Radio = document.getElementsByName('wh_'+producto+'_periodo');
	var prod = '';
	switch(producto){
				case 'SSL':
					prod = 'HTTPS / Certificado SSL';
					break;
				case 'DATTARADIO':
					prod = 'DattaRadio';
					break;
				case 'IP':
					prod = 'IP Propia';
					break;
				default:
					prod = '';
					break;
		}
		DattaCalc.Del(prod);
	for (i=0;i<obj_Radio.length;i++){
		if(obj_Radio[i].checked){ obj_Radio[i].checked = false; }
	}
}

//Manejo de camparativos de planes
//*******************************************************************************
var AllPlans = new Array('plan_resellers','plan_resellers_2','server_virtual_1','server_virtual_2','server_virtual_3');

function verComparativoTodos(){
	if(xGetElementById('PlataformaHosting').value == ''){
		setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_1');
		alert('Por favor, seleccione una plataforma para ver el comparativo.');
		return false;
	}else{
		var PlataformaCompare = ((xGetElementById('PlataformaHosting').value).toLowerCase()).charAt(0);
		openTab((xGetElementById('PlataformaHosting').value).toLowerCase());
		ShowAllPlans();
		return true;
	}
}

function ShowPlan(id_plan){
	if(xGetElementById('PlataformaHosting').value == ''){
		setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_1');
		alert('Por favor, seleccione una plataforma para ver el comparativo.');
	}else{
		var PlataformaCompare = ((xGetElementById('PlataformaHosting').value).toLowerCase()).charAt(0);
		xGetElementById('compara_'+PlataformaCompare+'_'+id_plan).style.display=visible;
	}
}

function ShowPlanPlat(id_plan){
	xGetElementById('compara_'+id_plan).style.display=visible;
}

function HidePlan(id_plan){
	if(xGetElementById('PlataformaHosting').value == ''){
		setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_1');
		alert('Por favor, seleccione una plataforma para ver el comparativo.');
	}else{
		var PlataformaCompare = ((xGetElementById('PlataformaHosting').value).toLowerCase()).charAt(0);
		hide('compara_'+PlataformaCompare+'_'+id_plan);
	}
}

function HidePlanPlat(id_plan){
	hide('compara_'+id_plan);
}

function ShowAllPlans(){ //Llamada desde afuera
 var i;
	for (i=0;i<AllPlans.length;i++){
		ShowPlan(AllPlans[i]);
	}
}

function ShowAllPlansPlat(Plat){
 var i;
	for (i=0;i<AllPlans.length;i++){
		ShowPlanPlat(Plat+'_'+AllPlans[i]);
	}
}

function HideAllPlans(){ //Llamada desde afuera
	var i;
	for (i=0;i<AllPlans.length;i++){
		HidePlan(AllPlans[i]);
	}
}

function ComparePlans(){ //Llamada desde afuera
	var formCbx = document.forms['ComprarProductosForm'];
	var cuenta = 0;
	var i;
	for (i=0; i<formCbx.length; i++) {
		if((formCbx.elements[i].type == 'checkbox') && (formCbx.elements[i].checked == true) && ((formCbx.elements[i].id).indexOf('comparar_', 0) != -1)){
			cuenta = cuenta + 1;
		}
	}
	if(cuenta > 0){
		if(xGetElementById('PlataformaHosting').value == ''){
			setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_1');
			alert('Por favor, seleccione una plataforma para comparar los planes.');
			return false;
		}else{
			HideAllPlans();
			for (i=0; i<formCbx.length; i++) {
				if((formCbx.elements[i].type == 'checkbox') && (formCbx.elements[i].checked == true) && ((formCbx.elements[i].id).indexOf('comparar_', 0) != -1)){
					ShowPlan(formCbx.elements[i].value);
				}
			}
			return true;
		}
	}else{
		if(xGetElementById('PlataformaHosting').value == ''){
			setClass(xGetElementById('select_plataforma_tb'),'select_plataforma_tb_1');
			alert('Por favor, seleccione los planes que desea comparar y una plataforma.');
		}else{
			alert('Debe seleccionar los planes que desea comparar...');
		}
		return false;
	}
}