// JavaScript Document

var hotspots = document.getElementsByTagName('dt');
var toggles = document.getElementsByTagName('dd');
var activeTab;
var activeTabArea;
var inputs;
var imgFalse = 'imag/false.gif';
var imgTrue = 'imag/true.gif';

function faqonoff()
{
  for (var i = 0; i < hotspots.length; i++)
  {
  hotspots[i].someProperty = i;
  hotspots[i].onclick = function() {toggle(this.someProperty)};
  }

  for (var i = 0; i < toggles.length; i++)
  {
  toggles[i].style.display = 'none';
  }
}

function toggle(i)
{
  toggles[i].style.display=(toggles[i].style.display=='none')?'':'none';
  hotspots[i].className=(hotspots[i].className=='impar')?'menos':'impar';
} 

window.onload=function(){
replaceChecks();
if(!NiftyCheck())
    return;
Rounded("div.blqRdDcha","all","#fff","#008887","smooth");
Rounded("div.blqRdIzda","all","#fff","#008887","smooth");
}



function setActiveTabIDS(tabID,divID)
{
	activeTab = tabID;
	activeTabArea = divID;
}
function changeTabDivs(tabID,divID)
{
	activateTab(activeTab,activeTabArea,false);
	activateTab(tabID,divID,true);
	setActiveTabIDS(tabID,divID);
}
function activateTab(tabID,divID,state)
{
	var tempObj;
	if(document.getElementById)
	{
		if(tabID)
		{
			
			tempObj =  document.getElementById(tabID);
			if(state)
			{
				tempObj.className = 'tabActiveTab';
			}
			else
			{
				tempObj.className = '';
			}
			
		}
		if(divID)
		{
			tempObj =  document.getElementById(divID);
			if(state)
			{
				tempObj.className = 'tabShowDiv';
			}
			else
			{
				tempObj.className = 'tabHideDiv';
			}
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_OptionJump(targ,selObj){ 
  var id=selObj.options[selObj.selectedIndex].value
  if (id!=0) 
  	parent.location=targ+id;    
}

function ToggleDiv()
{
		division = document.getElementById('displaymore');
		division2 = document.getElementById('displayless');
		state = division.style.display;
		//state2 = division.style.display;
		if (state == "none")
		{
			division.style.display = "inline";
			division2.style.display = "none";
		}
		else
		{
			division.style.display = "none";
			division2.style.display = "none";
		}
}

function check_selection(arg, form)
{
	if (arg.options[arg.selectedIndex].disabled == false)
	{
		form.submit();
	}
}

function showElementSection(id)
{
	section = document.getElementById(id);
	state = section.style.display;
	
	if (state == "none" || state == "")
	{
		section.style.display = "inline";
	}
	else
	{
		section.style.display = "none";
	}
}

	function showHideElement(id)
	{
		var contentDiv = document.getElementById(id);
		
		if (contentDiv.className == 'showHideContent')
		{
			contentDiv.className = 'showHideNone';
		}
		else
		{
			contentDiv.className = 'showHideContent';
		}
	}
	
	function showHideElementInline(id)
	{
		var contentDiv = document.getElementById(id);
		
		if (contentDiv.className == 'showHideInline')
		{
			contentDiv.className = 'showHideNone';
		}
		else
		{
			contentDiv.className = 'showHideInline';
		}
	}
	
	function showHideElementAction(id)
	{
		showHideElement('element' + id);
		showHideElementInline('Close' + id);
		showHideElementInline('Open' + id);
	}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function replaceChecks() {
	
	//get all the input fields on the page
	inputs = document.getElementsByTagName('input');

	//cycle trough the input fields
	for(var i=0; i < inputs.length; i++) {

		//check if the input is a checkbox
		if(inputs[i].getAttribute('type') == 'checkbox') {
			
			//create a new image
			var img = document.createElement('img');
			
			//check if the checkbox is checked
			if(inputs[i].checked) {
				img.src = imgTrue;
			} else {
				img.src = imgFalse;
			}

			//set image ID and onclick action
			img.id = 'checkImage'+i;
			//set image 
			img.onclick = new Function('checkChange('+i+')');
			//place image in front of the checkbox
			inputs[i].parentNode.insertBefore(img, inputs[i]);
			
			//hide the checkbox
			inputs[i].style.display='none';
		}
	}
}

//change the checkbox status and the replacement image
function checkChange(i) {

	if(inputs[i].checked) {
		inputs[i].checked = '';
		document.getElementById('checkImage'+i).src=imgFalse;
	} else {
		inputs[i].checked = 'checked';
		document.getElementById('checkImage'+i).src=imgTrue;
	}
}


function sendMail(contacto){
	var nombre   =document.forms[0].Nombre.value;//oblig
	var apellidos=document.forms[0].Apellidos.value;//oblig
	var empresa  =document.forms[0].Empresa.value;
	var cargo    =document.forms[0].Cargo.value;
	var dir      =document.forms[0].Direccion.value;//oblig
	var provincia=document.forms[0].Provincia.value;//oblig
	var cp       =document.forms[0].Cpostal.value;
	var email    =document.forms[0].Email.value;
	var tfno     =document.forms[0].Telefono.value;
	var movil    =document.forms[0].Movil.value;

	var comentario=document.forms[0].textarea.value;

	var tipoComunic='';
	var depart='';
	if(contacto==1){

		var selectDepart=document.forms[0].select;

		for(var i =0;i <selectDepart.length;i++){
			if(selectDepart.options[i].selected==true){
				if(i>0)
					depart=depart+selectDepart.options[i].text+" ";				
			}
		}
		if(depart==''){
			alert("Debe seleccionar al menos un departamento");
			return false;
		}
		
	}
	if(nombre==''){
		alert("El nombre no puede estar vacio");
		return false;
	}
	else if(apellidos==''){
		alert("El apellido no puede estar vacio");
		return false;
	}
	else if(dir==''){
		alert("La dirección no puede estar vacia");
		return false;
	}
	else if(provincia==''){
		alert("La provincia no puede estar vacia");
		return false;
	}
	

	if(document.forms[0].Consulta.checked)
		tipoComunic="Consulta";
	else if(document.forms[0].Sugerencia.checked)
		tipoComunic="Sugerencia";
	else if(document.forms[0].Reclamacion.checked)
		tipoComunic="Reclamación";
	else if(document.forms[0].Otros.checked)
		tipoComunic="Otros";
	else{
		alert("Debe seleccionar un tipo de comunicado");
		return false;
	}
	var cuerpo=" Nombre:"+nombre+" Apellidos:"+apellidos+"\n";

	if(empresa!='')
		cuerpo=cuerpo+" Empresa:"+empresa+"\n";
	if(cargo!='')
		cuerpo=cuerpo+" Cargo:"+cargo+"\n";
	cuerpo=cuerpo+" Direccion:"+dir+" Provincia:"+provincia+"\n";

	if(cp!='')
		cuerpo=cuerpo+" Código postal:"+cp+"\n";
	if(email!='')
		cuerpo=cuerpo+" E-mail:"+email+"\n";
	if(cp!='')
		cuerpo=cuerpo+" Código postal:"+cp+"\n";
	if(tfno!='')
		cuerpo=cuerpo+" Teléfono:"+tfno+"\n";
	if(movil!='')
		cuerpo=cuerpo+" Móvil:"+movil+"\n";
	
	if(contacto==1)
		cuerpo=cuerpo+" Departamento/s:"+depart+"\n";

	cuerpo=cuerpo+" Comentario:"+comentario;

	document.forms[0].action="mailto:info@inlandgeo.com?subject="+tipoComunic+"&body="+cuerpo;
	document.forms[0].submit();
}