// JavaScript Document

//	---------
// LOAD SITE
// ---------
// this function loads the popup and then the website
//


	function loadAdhoc(){

		  window.open('index_em.html', '', 'width=320, height=700, menubar=no, status=no');

		  window.location = 'index_site.html';

	}


//  ---------
//  SHOWOLOGO
//  ---------
//  this function sets a time for the Adhoc Logo to appear and disappear
//

  function showLogo() {

    var temp = document.getElementById('logoDiv').className;

    if(temp == "on") {

      document.getElementById('logoDiv').className = "off"

     // document.getElementById('logoDiv2').className = "off"

      window.setTimeout("showLogo()", 25000);

    }
    else{

      document.getElementById('logoDiv').className = "on"

     // document.getElementById('logoDiv2').className = "on"

      window.setTimeout("showLogo()", 2000);

    }


  }


 window.setTimeout("showLogo()", 500); //2000



//  this function enable internet explorer to the div:hover
//


sfHover = function() {

	var sfEls = document.getElementById("front-part").getElementsByTagName("div");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			this.className+="-over";

		}

		sfEls[i].onmouseout=function() {

			this.className=this.className.replace(new RegExp("-over\\b"), "");

		}

	}

	sfEls="";

	var sfEls = document.getElementById("box-countdown").getElementsByTagName("p");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			this.className+="-over";

		}

		sfEls[i].onmouseout=function() {

			this.className=this.className.replace(new RegExp("-over\\b"), "");

		}

	}

	sfEls="";

	var sfEls = document.getElementById("people-part").getElementsByTagName("div");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			this.className = "color-over";

		}

		sfEls[i].onmouseout=function() {

			this.className=this.className = "";

		}

	}

	sfEls="";

	var sfEls = document.getElementById("location-part").getElementsByTagName("div");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			this.className = "color-over";

		}

		sfEls[i].onmouseout=function() {

			this.className=this.className = "";

		}

	}
/*
	sfEls="";

	var sfEls = document.getElementById("sponsor-part").getElementsByTagName("img");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			if(this.Id == "sony") this.src = "_images/sponsor_sony.jpg";
			else this.src = "_images/sponsor_corian.jpg";

		}

		sfEls[i].onmouseout=function() {

			this.src = "_images/sponsor.jpg";

		}

	}
	*/
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

var timer = 0;
var delay = 10; //msec


function backTo(){

  //
  //  lets see where we are with the screen position
  //

  docBody = document[getDocElName()];

  var x = docBody.scrollLeft; // this is the actual position

  var targetXPos = 1;

  //
  //  moving, only if the position of the screen is not as the one we want
  //


  if (x>targetXPos){

  if(x<100) window.scrollBy(-10, 0);
  if(x<20)  window.scrollBy(-1, 0);
  if(x>100) window.scrollBy(-50, 0);

  timer = setTimeout('backTo()', delay);

  }

  else{

  clearTimeout(timer);


  }

return false;


}

function scrollTo(anchor){

  //
  // lets set how much should we scroll
  //


  switch(anchor)
  {
    case 1 : targetXPos = 2650; break;  //youtube case
    case 2 : targetXPos = 2450; break;  //flickR case
    case 3 : targetXPos = 2250; break;  //blog case
    case 4 : targetXPos = 1300; break;  //information case

    default: targetXPos = 1500; break;

  }


  //
  // which is the widht of the browser?
  //


  var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }

  var y = myWidth; // this is the screen width



  //
  //  lets see where we are with the screen position
  //

  docBody = document[getDocElName()];

  var x = docBody.scrollLeft; // this is the actual position


  //
  //  changing target to fit smaller screens
  //


  if(y<1280 && anchor != 4) {

  targetXPos = targetXPos + (1250-y);

  }

  if(y>1280)
  {

  targetXPos = targetXPos + (1250-y);

  }


  //
  //  moving, only if the position of the screen is not as the one we want
  //

  var value = x-targetXPos;



  if (x<targetXPos){

  //alert(x);

  if(x<20)  window.scrollBy(1, 0);
  else
    if(x<100) window.scrollBy(10, 0);
    else if(x<200) window.scrollBy(20, 0);
    else if(x<300) window.scrollBy(30, 0);
    else window.scrollBy(50, 0);


  timer = setTimeout('scrollTo('+anchor+')', delay);

  }

  else{

  clearTimeout(timer);


  }

return false;


}

function getDocElName(){
return (document.compatMode && document.compatMode == "CSS1Compat") ? "documentElement" : "body";
}


//  -----------
//  STAFF POPUP
//  -----------
//  this function opens the staff window
//


function popStaff(what){

  var myWidth = 0, myHeight = 0, winWidth = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
      winWidth = 400;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
      winWidth = 400;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
      winWidth = 400;
    }

  var positionX = myWidth / 2 - 250; // this is the screen width


	window.open('../adhoc/_staff'+what+'/index.html', '', 'width='+winWidth+', height=170, top=150px, left='+positionX+'px, toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');

}


// Preloading Staff Images and Logo
function preLoad(){

      preload_image_object = new Image();


         preload_image_object.src = "http://www.garthglobal.com/adhoc/_images/adhoc_logo_2.jpg.jpg";

    }

