var up=true;
var isInformacionTitular = true;

function onecareLogin(){
	if (up){
		$("#onecare-login").slideDown("slow");
		up=false;
	}else{
		$("#onecare-login").slideUp("slow");
		up=true;
	}
}

function isExplorer(){
	if ((window.navigator.userAgent).indexOf('IE')!=-1){
		return true;	
	}
	return false;
}



function loadPage(url,div){
			new Ajax.Updater(div,url,{evalScripts:true});
			new Effect.Appear(div);
}

function loadDestiny(url){
try{// Internet Explorer
	xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); 

}catch(e){
  try {//Firefox, Mozilla, Opera, etc.
	xmlDoc=document.implementation.createDocument("","",null);
   }catch(e){alert(e.message); return;}
}

xmlDoc.async=false;
xmlDoc.load(url+'a/f/destiny.xml');
	
var textSearch = (document.forms[0].isearch.value).toLowerCase();
var colorRow = false;
var finded=0;
var html = '<table class="destinosxml">';
html += '<tr"><th>Pa&iacute;s</th><th>Tel&eacute;fono fijo</th><th>Tel&eacute;fono m&oacute;vil</th></tr>'
	
//Extrae Contenido XML
x=xmlDoc.documentElement;
y=x.childNodes;
for (i=0;i<y.length;i++){
	if (y[i].childNodes.length>2){	
//	alert(y[i].childNodes.length);
		 if (y[i].childNodes[3].nodeType==1){ 
			if (!isExplorer()){			 
				name		=y[i].childNodes[1].childNodes[0].nodeValue;
				status		=y[i].childNodes[3].childNodes[0].nodeValue;		
				fix_zone	=y[i].childNodes[5].childNodes[0].nodeValue;		
				fix_rate	=y[i].childNodes[7].childNodes[0].nodeValue;
				mobile_zone	=y[i].childNodes[9].childNodes[0].nodeValue;
				mobile_rate	=y[i].childNodes[11].childNodes[0].nodeValue;		
				country_flag=url+'a/i/flags/'+y[i].childNodes[13].childNodes[0].nodeValue;
				clean_name	=y[i].childNodes[15].childNodes[0].nodeValue;		
			}else{
				name		=y[i].childNodes[0].childNodes[0].nodeValue;
				status		=y[i].childNodes[1].childNodes[0].nodeValue;		
				fix_zone	=y[i].childNodes[2].childNodes[0].nodeValue;		
				fix_rate	=y[i].childNodes[3].childNodes[0].nodeValue;
				mobile_zone	=y[i].childNodes[4].childNodes[0].nodeValue;
				mobile_rate	=y[i].childNodes[5].childNodes[0].nodeValue;		
				country_flag=url+'a/i/flags/'+y[i].childNodes[6].childNodes[0].nodeValue;
				clean_name	=y[i].childNodes[7].childNodes[0].nodeValue;						
			}
			
			if(((clean_name).toLowerCase()).indexOf(textSearch.toLowerCase())!=-1){
				finded++;
				html += '<tr class="'+ ((colorRow==true)?'odd':'even')   +'"><td><table><tr><td width="30px"><img src="'+country_flag+'" onerror="this.src=\''+country_flag+'\';"></td><td align="left"> '+name+'</td></tr></table></td><td>'+ ((parseInt(fix_zone)!=-1)?'<table><tr><td><strong>zona</strong> '+fix_zone+'</td><td>'+fix_rate+'</td></tr></table>':'&nbsp;') +'</td><td>'+       ((parseInt(mobile_zone)!=-1)?'<table><tr><td><b>zona</b> '+mobile_zone+'</td><td>'+mobile_rate+'</td></tr></table>':'&nbsp;')         +'</td></tr>'
				if(colorRow){
					colorRow = false;
				}else{
					colorRow = true;
				}
			}
		 }
	}
}

if(finded==0){
	html += '<tr><td colspan="3">no se encontraron coincidencias</td></tr>';
}
html += '</table>';
	
document.getElementById("boxDestinos").innerHTML=html;
document.getElementById("boxDestinos").style.display="";
//alert(html);
//new Effect.Appear("boxDestinos");

}
//lista de sectores
function listSectores(obj,baseURL){
	if((obj.options[obj.selectedIndex].value).length!=0){
		url="index.php/cobertura/sectores/"+document.getElementById('city_id').value;
		$("#divSelectores").load(baseURL+escape(url));
	}
}

function loadPageDocument(obj,baseURL,documentName){
	var page = "";
	switch(documentName){
		case 'CEDULA': page = 'formulariocedula';break;
		case 'RNC': page = 'formulariornc';break;
		case 'PASSPORT': page = 'formulariopasaporte';break;
	}
	url="index.php/webhosting/"+page;
	$("#divDocument").load(baseURL+escape(url));
}

function loadInformaciontitular(obj,baseURL){
	if(isInformacionTitular){
		url="informaciontitular";
		$("#informacionOtherTitular").load(baseURL+escape(url));
	}else{
		document.getElementById('informacionOtherTitular').innerHTML = '';
	}	
	isInformacionTitular = (isInformacionTitular)?false:true;
}















