im_path = "assets/images/"

im1 = new Image(); im1.src = im_path + "wait_msg.gif"

function show_wait_msg(x)
{
  image_name = "wait_msg" + x
  document.images[image_name].src = im_path + "wait_msg.gif"
}

buttons1 = new Array('but_home', 'but_about', 'but_contact', 'but_links', 'but_clients')


function goJump(sel)
{
  location.href = sel.options[sel.selectedIndex].value
}

function goJump2(sel)
{
  if (sel.options[sel.selectedIndex].value != "" && sel.options[sel.selectedIndex].value != 0) location.href = "page.php?id=" + sel.options[sel.selectedIndex].value
}

function gload(arr)
{
  im = new Array()
  for (n=0; n<arr.length; n++)
  {
    im[n] = new Image()
    im[n].src = im_path + arr[n] + "_f2.gif"
  }
}

function gmover(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + "_f2.gif"
}

function gmout(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + ".gif"
}

function jload(arr)
{
  im = new Array()
  for (n=0; n<arr.length; n++)
  {
    im[n] = new Image()
    im[n].src = im_path + arr[n] + "_f2.jpg"
  }
}

function jmover(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + "_f2.jpg"
}

function jmout(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + ".jpg"
}


var win1

function newWin(url,w,h) {
if (win1 && win1.open || win1 && !win1.closed){win1.close()}
win1 = window.open(url,"win1","width="+w+",height="+h+",toolbar=no,location=no,menubar=no,status=no,scrollbars=no,resizable=yes")
}

//CUSTOM TOOLTIP
//Copyright 2004, Sandeep Gangadharan
//For more free scripts go to http://sivamdesign.com/scripts/

(document.getElementById) ? dom = true : dom = false;

function hideIt(add) {
  if (dom) {document.getElementById('tooltip'+add).style.visibility='hidden';}
  if (document.layers) {document.layers["tooltip"+add].visibility='hide';}
 }
function showIt(add) {
 if (dom) {
  if (document.getElementById('tooltip'+add).style.visibility=='visible') { hideIt(add); }
  else {document.getElementById('tooltip'+add).style.visibility='visible'} }

 if (document.layers) {
  if (document.layers["tooltip"+add].visibility=='show') { hideIt(add); }
  else {document.layers["tooltip"+add].visibility='show'}  }
 }
 //end custom tool tip
 
 function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function P7_Snap() { //v2.64 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}

//--------------------------------------------------------  Expand DIV
var exp_div_moving = new Array();
var exp_offsetHeights = new Array();
var changeTextArr1 = new Array();
var changeTextArr2 = new Array();
var scrolledAlready = 0;
var screenHeight = 0;
var y_offset = 0;
var using_buttons = 0;
var more_button = im_path + '/show_div.gif'
var less_button = im_path + '/hide_div.gif'

function changeText (link_id, newTextStr) 
{
	elem = document.getElementById(link_id);
	
	if (changeTextArr2[elem])
	{
		elem.innerHTML = changeTextArr1[elem]; //already displaying newTextStr so go back to showing original str
		changeTextArr2[elem] = 0; //unset flag
	}
	else
	{
		changeTextArr1[elem] = elem.innerHTML; //store away original textStr for retrieval when re-clicking
		elem.innerHTML = newTextStr; //show newTextStr
		changeTextArr2[elem] = 1; //set flag to remember we did this
	}
}
	

function uncover (div_id)
{
	link_id = uncover.arguments[1];
	link_txt = uncover.arguments[2];
	if (link_id) changeText (link_id, link_txt);
	expand_div (div_id, 15); //offset of 15 applied to all sliding divs
	return false;
}

function expand_div(div_id)
{
	//vars and arguments
	expanded_height = exp_offsetHeights[div_id]; //height of div when shown fully - array element remembers this between calls
	mode = expand_div.arguments[2];
	if (expand_div.arguments[1]) y_offset = expand_div.arguments[1];
	elem = document.getElementById(div_id);
	if (using_buttons) button = document.getElementById("but_"+div_id);
	
	//initial entry into function - no mode defined
	if (!mode) //&& !exp_div_moving[div_id]
	{
		screenHeight = getScreenHeight()
		if (elem.style.visibility == "visible") mode = "c"; else mode = "e"; //collapse if currently visible, else expand
		if (!exp_offsetHeights[div_id]) exp_offsetHeights[div_id] = parseInt(elem.offsetHeight); //initialise height to expand to - and remember this - height only registered when DIV is relative, not absolute (or something...)
		expanded_height = exp_offsetHeights[div_id];
		scrolledAlready = 0;
		exp_div_moving[div_id] = 1; //signify moving
		
		if (mode == "e")
		{
			elem.style.height = '0px';
			elem.style.position='relative';
			elem.style.visibility='visible';
			if (using_buttons) button.src = less_button;
		}		
		if (mode == "c")
		{
			if (!isNaN(elem.style.height)) elem.style.height = expanded_height; //jump start elem.style-height if initially starting expanded and collapse is first operation - otherwise the current_height line below gets NaN
			if (using_buttons) button.src = more_button;
		}			
	}
	
	if (mode == "e") move_inc = 7; else move_inc = -20;
	current_height = parseInt(elem.style.height);
	current_height += move_inc;

	if (mode == "e" && current_height > expanded_height) //stop expanding
	{
		elem.style.height = expanded_height + "px";
		exp_div_moving[div_id] = 0; //stop moving
	}
	else	if (mode == "c" && current_height < 0) //stop collapsing
	{
		elem.style.height = "0px";
		elem.style.position="absolute"
		elem.style.visibility="hidden"
		exp_div_moving[div_id] = 0; //stop moving
	}
	else if (mode == "c" || mode == "e") //expand or collapse
	{
		elem.style.height = current_height + 'px';
		t1 = setTimeout("expand_div('"+div_id+"', '', '"+mode+"')", 10);
		
		//scroll screen down while expanding if bottom of div disappears off bottom of page. Stop scrolling before top disappears though.
		if (mode == "e" && ((mouseY + y_offset + current_height + move_inc) > screenHeight && (mouseY - scrolledAlready - move_inc) > 0))
		{
			new_scroll_position = getScrollPosition() + move_inc
			window.scroll(0, new_scroll_position);
			scrolledAlready += move_inc;
		}
	}
}

var mouseY = 0;

function getMouseCoords(e) 
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (0) //e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX // + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY // + document.body.scrollTop + document.documentElement.scrollTop;
	}
	mouseY = posy;
}


function getScrollPosition()
{
	pos = window.pageYOffset || document.body.scrollTop || 0;
	return pos
}

function getScreenHeight()
{
	if (window.innerHeight) 
	{
		theHeight=window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		theHeight=document.documentElement.clientHeight;
	}
	else if (document.body) 
	{
		theHeight=document.body.clientHeight;
	}
	return theHeight
}

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.ONCLICK)
document.onclick = getMouseCoords;

//--------------------------------------------------------