var idDiv='';
var Tabs=7;
var Section=0;
var contactState=0;
window.addEvent('domready',function (){
   
	ancho = window.getWidth();
	Alto = window.getHeight();

    SetPropierties();
	
	$('headerContent').style.width=$('content').offsetWidth+"px";
	$('contactContent').style.width=$('content').offsetWidth+"px";
	$('footerContent').style.width=$('content').offsetWidth+"px";
	
	var accordionTab = new Array;
	var accordionContent = new Array;
	for(i=1;i<=Tabs;i++)
	{
	 accordionTab[i] = new Fx.Styles($('accordionTab'+i), {duration:300, wait:false});
	 accordionContent[i] = new Fx.Styles($('accordionContent'+i), {duration:300, wait:false});
	}
	for(i=1;i<=Tabs;i++)
	{
	 $('accordionTab'+i).addEvent('mousedown', function(e){
			id=new String(this.id);
			i=id.substr(id.length-1,id.length);
			 for(j=1;j<=Tabs;j++)
			 {
			  if(j==i)
			  {
			   if(Section!=i)
			   {  
			    Height=$('Table'+j).offsetHeight;
			    accordionContent[j].start({ 'height': Height+'px'});
				Section=i;
			   }
			   else
			   {
				accordionContent[i].start({ 'height': '0px'}); 	
				Section=0;
			   }
			  }
			  else
			  {
			   accordionContent[j].start({ 'height': '0px'});
			  }
			 }
		});
	}
	$('Menu').onselectstart = function() {return false;}
	$('element1').addEvent('mousedown', function(e){
		changeNoticeMenu(1);
	});
	$('element2').addEvent('mousedown', function(e){
		changeNoticeMenu(2);
	});
	$('element3').addEvent('mousedown', function(e){
		changeNoticeMenu(3);
	});
	$('element4').addEvent('mousedown', function(e){
		Contact = new Fx.Styles($('contact'), {duration:300, wait:false});
		if(contactState==0)
		{
		 Contact.start({ 'height': '200px'});
		 contactState=1;
		}
		else
		{
		 Contact.start({ 'height': '0px'});
		 contactState=0;
		}
	});
});
window.addEvent('resize',function (){
    SetPropierties();
});
function SetPropierties(){

	ancho = window.getWidth();
	$('contact').style.height="0px";

}
function changeimg(img)
{
 $('imgPrinc').src=img;	
}
function changeNotice(id, lang)
{
  Value="idProject="+id+"&lang="+lang;
  $('contentMain').innerHTML='';
  var myAjax = new Ajax('mainContent.php', {method: 'post', data: Value, update: $('contentMain'), evalScripts: true});
  myAjax.request();	
  $('contentRecommended').innerHTML='';
  var myAjax = new Ajax('recommended.php', {method: 'post', data: Value, update: $('contentRecommended'), evalScripts: true});
  myAjax.request();
}
function changeNoticeByRecommended(idDiv1, idDivVisible,id)
{
  Value="idProject="+id;
  $(idDiv).style.display='';
  idDiv=idDivVisible;
  $(idDivVisible).style.display='none';
  $('contentMain').innerHTML='';
  var myAjax = new Ajax('mainContent.php', {method: 'post', data: Value, update: $('contentMain'), evalScripts: true});
  myAjax.request();	
}
function changeNoticeMenu(id)
{
  Value="idProject="+0;
  $('contentMain').innerHTML='';
  switch(id)
  {
   case 1:
   		  var myAjax = new Ajax('que_es_venue.php', {method: 'post', data: Value, update: $('contentMain'), evalScripts: true});
	   	  break;
   case 2:
   		  var myAjax = new Ajax('quienes_somos.php', {method: 'post', data: Value, update: $('contentMain'), evalScripts: true});
	   	  break;
   case 3:
   		  var myAjax = new Ajax('servicios_relacionados.php', {method: 'post', data: Value, update: $('contentMain'), evalScripts: true});
	   	  break;
		   
  }
  myAjax.request();
  $('contentRecommended').innerHTML='';
  var myAjax = new Ajax('recommended.php', {method: 'post', data: Value, update: $('contentRecommended'), evalScripts: true});
  myAjax.request();	
}
function sendmail()
{
 Error=0;
 msg="";
 if($('name').value.trim()=='')
 {
  Error=1;
  msg+="Nombre es campo obligatorio.<br>";
 }
 if($('lastname').value.trim()=='')
 {
  Error=1;
  msg+="Apellido es campo obligatorio.<br>";
 }
 if($('email').value.trim()=='')
 {
  Error=1;
  msg+="Email es campo obligatorio.<br>";
 }
 else
 {
  if ($('email').value.indexOf('@')==-1 || $('email').value.indexOf('.')==-1 ) 
  { 
	Error=1;
	msg+="Email no valido.<br>";
  }	 
 }
 if($('comentario').value.trim()=='')
 {
  Error=1;
  msg+="Consulta es campo obligatorio.<br>";
 }
 if(Error==1)
 {
  $('errormsg').innerHTML=msg;
 }
 else
 { 
  var myAjax = new Ajax('sendmail.php', {method: 'post', data: $('form1').toQueryString(), update: $('errormsg'), evalScripts: true});
  myAjax.request();
 }	
}
function MailSended()
{
  $('errormsg').innerHTML='Formulario Enviado';
  var myTimer1 = ResetForm.delay(5000);
  hideform.delay(3000);
}
function ResetForm()
{
  $('form1').reset();
  $('errormsg').innerHTML='';
}
function hideform(){
	Contact = new Fx.Styles($('contact'), {duration:300, wait:false});
	if(contactState==0)
	{
	 Contact.start({ 'height': '200px'});
	 contactState=1;
	}
	else
	{
	 Contact.start({ 'height': '0px'});
	 contactState=0;
	}
}
