/* js/procargo.js
  *	
  *
  *	author: Daniel VALDA
  *      created: 20-10-2007
  *
  *
 */




var delayD=20;
var delayR=0;
var dsteps=66;
var rsteps=0;
var DtimerRunning =false;
var DtimerID = null;
var RtimerRunning =false;
var RtimerID = null;
var start_top=0;
var start_left=450;
var gallery= new Array();
var top_gallery=17;
var arrowup;
var arrowdown;
var ancor;
var timer = null;;
var worldFx = {
	country: null,
         shadermap: null,
    	transitionFx: null,
         transitionHeaderFx:null,
         transitionFooterFx:null,
         switchToCountry: function(c) {
         this.transitionFx=new Fx.Style('shadingmap','opacity',{duration: 500});
         //this.transitionHeaderFx=new Fx.Style('header','opacity',{duration: 1000});
         //this.transitionFooterFx=new Fx.Style('footer','opacity',{duration: 1000});
         this.shadermap=document.getElementById('shadingmap');
         this.country=c;
         ancor="#continent-";
		 switch(this.country) {
          
		  case "europe": ancor+="EU"; break;
          case "northamerica":ancor+="NA"; break;
		  case "southamerica":ancor+="SA"; break;
          case "asia": 
		  case "middleeast":ancor+="AS";break;
		  
		  case "africa":ancor+="AF"; break;
          case "australia": ancor+="AU";
               		break;

         }
       
         this.shadermap.src="../images/map/" + this.country + "_shading.gif";
         this.transitionFx.start(0,0.4);
		 self.setTimeout("openWWPC()",750);
		 
         //this.transitionHeaderFx.start(0,0.8);
         //this.transitionFooterFx.start(0,0.8);
	}};
	
function flipbox(eid) {
	
	
	if( document.getElementById("n"+eid).className == "hidden") {
           document.getElementById("n"+eid).className= "visible";
		   document.getElementById("s"+eid).className= "hidden";
	 	}
         else {
           document.getElementById("n"+eid).className= "hidden";
		   document.getElementById("s"+eid).className= "visible";
		       
         }


}

	
function openWWPC() {

	 window.open('http://www.wwpc.eu.com/directory.asp?page=directory' + ancor);

}

function initGallery() {

        for(var i=0;i<18;i++) {
	gallery[i]=document.getElementById("p" + (i+1));
		if(i < 14) {
        		gallery[i].style.display="none";
                 gallery[i].style.visibility="hidden";
       		  }
                 else {
                 gallery[i].style.display="block";
                 gallery[i].style.visibility="visible";
                 }

	}
         arrowup=document.getElementById("arrowup");
         arrowdown=document.getElementById("arrowdown");
}

function SwitchUp() {
  arrowdown.src="../../images/arrowdown.gif";

if(top_gallery == 16) {
  arrowup.src="../../images/arrowup_grey.gif";

}


if( top_gallery < 17) {

gallery[top_gallery-3].style.visibility="hidden";
gallery[top_gallery-3].style.display="none";
top_gallery++;
gallery[top_gallery].style.visibility="visible";
gallery[top_gallery].style.display="block";

}

}

function SwitchDown() {

arrowup.src="../../images/arrowup.gif";

 if(top_gallery == 4) {
  arrowdown.src="../../images/arrowdown_grey.gif";

}

 if( top_gallery > 3) {

gallery[top_gallery].style.visibility="hidden";
gallery[top_gallery].style.display="none";
top_gallery--;
gallery[top_gallery-3].style.visibility="visible";
gallery[top_gallery-3].style.display="block";

}

}




function movedown() {

StopTimerD();
StopTimerR();
MoveBlockDown();

}

function StopTimerD() {

if(DtimerRunning)
   clearTimeout(DtimerID);
DtimerRunning=false;

}

function StopTimerR() {

if(RtimerRunning)
   clearTimeout(RtimerID);
RtimerRunning=false;

}

function MoveBlockRight() {

if(rsteps == 0)
{
	StopTimerR();

}
else
{
   rsteps=rsteps-1;
   start_left=start_left+1;
   timerRunning=true;
   document.getElementById("quick_link").style.left=start_left+"px";
   timerID = self.setTimeout("MoveBlockRight()",delayR);

}

}

function MoveBlockDown() {

if(dsteps == 0)
{
	StopTimerD();
         MoveBlockRight();

}
else
{
   dsteps=dsteps-1;
   start_top=start_top+5;
   timerRunning=true;
   document.getElementById("quick_link").style.top=start_top+"px";
   timerID = self.setTimeout("MoveBlockDown()",delayD);
   //alert(document.getElementById("quick_link").style.top);

}

}

function switchTo(url, pageElement) {
     document.getElementById(pageElement).innerHTML = "<img style=\"height:32px;width:32px;margin-left:50%;margin-top:30%;\" src=\"../images/loading.gif\" />";
     errorMessage="<p>Element konnte nicht geladen werden</p>";
     try {
     req = new XMLHttpRequest();
     /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");
       /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");
         /* some versions IE */
         } catch (E) {
          req = false;
         }
       }
     }
     req.onreadystatechange
        = function() {response(pageElement, errorMessage);};
     req.open("GET",url,true);
     req.send(null);
  }

function response(pageElement, errorMessage) {
   if(req.readyState == 4) {
      if(req.status == 200) {
         output = req.responseText;
         document.getElementById(pageElement).innerHTML
            = output;
         } else {
         document.getElementById(pageElement).innerHTML
            = errorMessage+"\n"+responseText;
         }
   }
}






