$(document).ready(function() {
Cufon.replace('#dhr h2, #den h2, #des h2');
var angle = 0;
setInterval(function(){
      angle+=1;
     $("#rays").rotate(angle);
},50);

$('#dhr').mouseover(function() {
  pulsate('dhr',1);
});

$('#den').mouseover(function() {
  pulsate('den',1);
});

$('#des').mouseover(function() {
  pulsate('des',1);
});

$('#dhr').click(function() {
gg1();
});

$('#den').click(function() {
gg2();
});

$('#des').click(function() {
gg3();
});
});

function setOpacity(domId, val) {
obj = document.getElementById(domId);
obj.style.MozOpacity = val;
obj.style.opacity = val/10;
obj.style.filter = 'alpha(opacity=' + val*10 + ')';

};

function fade(domId){
obj = document.getElementById(domId); //Get the Element

 if(obj.style.display == "none") return false; //Return false if the element is already hidden

 var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
 function f(){ //Internal function

  alpha--; //Decrement the alpha value
  setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha

  if(alpha > -1){ //If alpha is still bigger than -1 then..
   setTimeout(f, 65); //..then call the function again after 100 milliseconds

  }else{ //otherwise..
   obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it

  }
}
setTimeout(f, 100); //This is where we call the f() function for the first time

};

function pulsate(domId, times){
 obj = document.getElementById(domId); //Get the Element
 if(obj.style.display == "none") return false; //Return false if the element is hidden
 if(!times) times = 4; //If the user doesnt specify the no. of times he/she want pulsation
 //Add a default value of 4.
 var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
 var ch = -1; //The rate of change of the opacity
 //Currently negative, as first it'll fade
 times *= 2; //Multiply the 'times' given my user by 2
 function p(){ //Internal function
  alpha += ch;
  /*Change the alpha according to the ch
  variable that could be positive or negative*/
  setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
  if((alpha < 0 || alpha > 10) && times > 0){
   /*If the alpha has gone out of range and times
   and it hasnt pulsated enought number of times...*/
   times--; //Decrement times
   if(ch<0){ //If ch is +ve make it -ve
    ch = 1;
   }else{//If ch is -ve make it +ve
    ch = -1;

   }
  }
  if(times > 0 ) setTimeout(p, 10);

 };
 setTimeout(p, 10); //This is where we call the f() function for the first time
};

function gg1() {
	fade('den');
	fade('des');
	$('#dhr').rotate({ angle:0,animateTo:360,easing: $.easing.easeInOutExpo });
setTimeout('gg0()',1700);
}

function gg2() {
	fade('dhr');
	fade('des');
	$('#den').rotate({ angle:0,animateTo:360,easing: $.easing.easeInOutExpo });
setTimeout('gg00()',1700);
}

function gg3() {
	fade('den');
	fade('dhr');
	$('#des').rotate({ angle:0,animateTo:360,easing: $.easing.easeInOutExpo });
setTimeout('gg000()',1700);
}

function gg0() { location.replace('indexHR.html')};
	function gg00() { location.replace('indexEN.html')};
		function gg000() { location.replace('indexES.html')};
