/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
window.onload = initRollovers;


function show_name(id,name,status){
	var doc;
//	alert( id + " " + name + " " + status );
	if(status=="on"){
		jQuery( "#people_name" ).html( name );
		//getElement("people_name").innerHTML = name;
		jQuery( "#" + id ).css( "display", "block" );
		//document.getElementsByTagName("div").item(id).style.display='block';
		jQuery( "#profile" ).css( "display", "none" );
		
		//images
		var img=id+"_o";
		jQuery( "#" + img ).attr( "src", "images/people/"+img+".jpg" );
		if(id!='lezlie'){
		//	getElement('lezlie_o').src = "images/people/"+'lezlie'+".jpg";
			jQuery( "#lezlie_o" ).attr( "src", "images/people/lezlie.jpg" );
		}

	}else{

		jQuery( "#people_name" ).html( "Lezlie Mearns, Managing Director" );
		jQuery( "#profile" ).css( "display", "block" );
		//document.getElementsByTagName("div").item(id).style.display='none';
		jQuery( "#" + id ).css( "display", "none" );
		
		//getElement('lezlie').style.display='block';
		//getElement("people_name").innerHTML = 'Lezlie Mearns, Managing Director';
		//getElement(img).src = "images/people/"+'lezlie'+".jpg";
		//images
		var img=id+"_o";
		//getElement(img).src = "images/people/"+id+".jpg";
		jQuery( "#" + img ).attr( "src", "images/people/"+id+".jpg" );
			//if(id!='lezlie'){
			//getElement('lezlie_o').src = "images/people/"+'lezlie_o'+".jpg";
			jQuery( "#lezlie_o" ).attr( "src", "images/people/lezlie_o.jpg" );
		//}

	}
}

function show_namex(id,name,status){
	var doc;
	if(status=="on"){
		element=document.getElementById
	//	getElement("people_name").innerHTML = name;
		getElement(id).style.display='block';
		//document.getElementsByTagName("div").item(id).style.display='block';
		getElement("profile").style.display = 'none';
		
		//images
		var img=id+"_o";
		getElement(img).src = "images/people/"+img+".jpg";
				fetchPage('index.php?m=aboutus&file=fetch&name='+id);


	}else{

		//getElement("people_name").innerHTML = '';
		getElement("profile").style.display = 'block';
		//document.getElementsByTagName("div").item(id).style.display='none';
		getElement(id).style.display='none';
		//images
		var img=id+"_o";
		getElement(img).src = "images/people/"+id+".jpg";

	}
}



 function getElement(id){
 	var doc
	var browser=navigator.appName
	if (browser=="Netscape"){
		doc=document.getElementById(id);
	}else if(browser=="Microsoft Internet Explorer"){
		if(document.getElementsByTagName("div").item(id)){
			doc=document.getElementsByTagName("div").item(id);
		}else{
			doc=document.getElementById(id);
		}

	}else{
		doc=document.getElementById(id);
	}
	return doc

}


// 4.10.07 Che
// Mouseover for 4D's navigation

function changeD( element, image ){
	//alert(element);
	//var obj = document.all? document.all.element : document.getElementById(element);
	var obj = getElement(element)
	obj.src = image;
}

// End mouseover for 4D's navigation

// 5.10.07 Che
// Animation for 4D's navigation

function animate4Ds(){
	//changeD( '4d1', 'images/howwework/approach1_on.gif' );
	/*
	setTimeout("changeD( '4d1', 'images/howwework/approach1_on.gif' )", 3000);
	setTimeout("changeD( '4d1', 'images/howwework/approach1_off.gif' )", 3300);
	setTimeout("changeD( '4d2', 'images/howwework/approach2_on.gif' )", 3400);
	setTimeout("changeD( '4d2', 'images/howwework/approach2_off.gif' )", 3700);
	setTimeout("changeD( '4d3', 'images/howwework/approach3_on.gif' )", 3800);
	setTimeout("changeD( '4d3', 'images/howwework/approach3_off.gif' )", 4100);
	setTimeout("changeD( '4d4', 'images/howwework/approach4_on.gif' )", 4200);
	setTimeout("changeD( '4d4', 'images/howwework/approach4_off.gif' )", 4500);
	*/
}

function pausecomp(millis){
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < millis);
}

// End animation for 4D's navigation

function shownote(content,event,people){
	//$('notes2').addClassName('peoplebg');	
	//alert(people);
	if(people){
		getElement("notes-content").innerHTML='<div id="notes2-people" class="innerdiv" > </div>';
		getElement("notes2-people").innerHTML=content;
	}else{
		if (getElement("notes-content")){
		  getElement("notes-content").innerHTML='<div id="notes2" class="innerdiv" > </div>';
		}
	}
	if ( document.getElementById('notes2') )
		getElement("notes2").innerHTML=content;
	else if ( document.getElementById('notes3') )
		getElement("notes3").innerHTML=content;
	objDiv=document.getElementById("notes");
	//x= event.clientX+40;
	//y=event.clientY-30;
	//var e = (window.event) ? window.event : event;
	//x=e.clientX;
	//y=e.clientY;
	mouse=getMousePosition(event);
	x=mouse.x+60;
	y=mouse.y-30;
	document.getElementById("notes").style.left =x+'px';
	document.getElementById("notes").style.top = y+'px';
	document.getElementById("notes").style.visibility="visible";
	
}

function getMousePosition(e) { return e.pageX ? {'x':e.pageX, 'y':e.pageY} : {'x':e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, 'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop}; }


function changeClass() {
    elements = document.getElementsByClassName("red");
    elements.each(function(e) {
      e.setClass("green");
    });
  }



function hidenote(){
	document.getElementById("notes").style.visibility="hidden";

}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}


function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}



function confirm_box(url1,url2,msg){
  // msg=msg
   var agree=confirm(msg);
   if (agree)
	window.location=url1;
   else
	window.location=url2;
}

/* Toggle effect in Contact Us page using prototype and scripacoulous */

function toggleAddr(id){

	Effect.toggle(id,'slide');
	/*if(getElement('p-'+id).innerHTML=="+"){
		getElement('p-'+id).innerHTML='+';
	}else{
		getElement('p-'+id).innerHTML='+'
	}
	*/
}


/* slide show */


// =======================================
// Javascript for the Slideshow
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 2500

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/slideshow/christine_walking.jpg'
Pic[1] = 'images/slideshow/dom_and_nikki.jpg'
Pic[2] = 'images/slideshow/dom_and_pencil.jpg'
Pic[3] = 'images/slideshow/george_on_phone.jpg'
Pic[4] = 'images/slideshow/libby_with_work.jpg'
Pic[5] = 'images/slideshow/liz_in_corridor.jpg'
Pic[6] = 'images/slideshow/lucy_at_reception.jpg'
Pic[7] = 'images/slideshow/maxim_building.jpg'
Pic[8] = 'images/slideshow/odea_behind_monitor.jpg'
Pic[9] = 'images/slideshow/robin_at_light.jpg'
Pic[10] = 'images/slideshow/studio_group.jpg'
Pic[11] = 'images/slideshow/syed_at_computer.jpg'
Pic[12] = 'images/slideshow/warren_through_glass.jpg'
Pic[13] = 'images/slideshow/wip_on_table.jpg'
Pic[14] = 'images/slideshow/wip_on_wall_and_katie.jpg'

var t
var j = 0
j = Math.round(14*Math.random());
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()
   }

   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}




   function showtooltip(e,text)
   {
  
     // Get the click location
     var height = e.clientY + 5;
     // Get the height inside the clicked image
     var offsetHeight = e.offsetY;
     height = height - offsetHeight;
   
     // Get the click location(width)
     var width = e.clientX
     // Get the width inside the clicked image
     var offsetWidth = e.offsetX;
     width = width - offsetWidth;
    // alert(e.clientY);
     var div = getElement('tooltip');
    // div.style.position = 'absolute';

     // Set the div top to the height
     div.style.top = height + 20;

     // Set the div Left to the height
     div.style.left = width + 20;
     
     // Show the div layer
     div.style.display = 'block';

     // Set its Text to your desired text
     div.innerText = text;
   }
	function hidetooltip(){
		getElement('tooltip').style.visibility="hidden";
		
	}



function roll(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
   
   
  
  /* Hight Secondary menu when clicked */
  
  function highlight_sm(div){
  		var d = $(div);
		for(i=1;i<=8;i++){
			//sorry I had to use this way, I assumed there will be max 8 div anc1..anc8 div
			dv="sm"+i;

			if(div==dv){
			add_highlight_sm(div);
			}else{
			remove_highlight_sm(dv);

			}
		}
		d.addClassName('active_sm');
  
  }
  
  function remove_highlight_sm(elementId){
	if(theElement = $(elementId)){
		if(theElement.hasClassName('active_sm')) {
			theElement.removeClassName('active_sm');
			theElement.addClassName('notactive_sm');
		}
	}

}

function add_highlight_sm(elementId){
	var theElement = $(elementId);
	if(theElement.hasClassName('active_sm')) {
		theElement.removeClassName('active_sm');
		theElement.addClassName('notactive_sm');
	} else if(theElement.hasClassName('notactive_sm')) {
		theElement.removeClassName('notactive_sm');
		theElement.addClassName('active_sm');
	} else {
		theElement.addClassName('active_sm');
	}

}

/* Hight light secondary menu end */
  
   