// JavaScript Document

// **************** PORTFOLIO SECTION DISPLAY FUNCTIONS *********************

function get_param( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
} //end get_param


function ma_MoveSpacer (spacing) {  //move the footer spacing on the Portfolio page based on spacing parameter
	
	if ((obj=MM_findObj('portfolio_spacer'))!=null) { 
		if (obj.style) 
		{ 
			obj=obj.style; 
			obj.height=spacing + "px";
		}
  	}  		
	
} // end ma_MoveSpacer


function ma_BrowserCheck() {
	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
	
		 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 var obj;
		 
		 if (ieversion<7) {
			  //alert("You're using an outdated IE browser");
			  if ((obj=MM_findObj('fade_left'))!=null)
			  { 
				if (obj.style) 
				{ 
					obj=obj.style; 
					obj.visibility="hidden";
				}
			  }  
			  if ((obj=MM_findObj('fade_right'))!=null)
			  { 
				if (obj.style) 
				{ 
					obj=obj.style; 
					obj.visibility="hidden";
				}
			  }  
		
		 }
	
	}
} // end ma_BrowserCheck



function ma_HideLayers (pre_txt) { //v1.0 hide all layers of the paramter's name 

	var obj, i;
	
	i=1;
	
	nr = pre_txt + i;
	
   while ((obj=MM_findObj(nr))!=null)
   {
	if (document.layers)
	{document.layers[nr].visibility = 'hide';}
	else if (document.all)
	{document.all[nr].style.visibility = 'hidden';}
	else if (document.getElementById)
	{document.getElementById(nr).style.visibility = 'hidden';}
	
	i++;
	nr = pre_txt + i;

   } //end whileloop

} // end ma_HideLayers


function ma_ShowLayer (showthis) { //show the given layer
	
  var obj;
  
  if ((obj=MM_findObj(showthis))!=null)
  { 
  	if (obj.style) 
  	{ 
		obj=obj.style; 
		obj.visibility='visible';
	}
  }    
	
}  //end ma_ShowLayer


function ma_DisplayOneLayer(showthis, display_type) { //v1.0 show a 'project' layer and hide the rest
  var obj,pre_text;
   
  if (display_type == 'rows')
  { pre_text = 'project_row'; }
  else if (display_type== 'blocks')
  { pre_text = 'project_block'; } 
  else if (display_type== 'headers')
  { pre_text = 'project_header'; } 
   
  
  if (showthis == 'project_row1') 
  {
  	ma_HideLayers ('project_block');
	ma_ShowLayer ('project_block23');
	
	ma_HideLayers (pre_text);
	ma_ShowLayer (showthis);
	
	ma_MoveSpacer (310);	  	  
	
  } else if (showthis == 'project_row2' ) {
	  
  	ma_HideLayers ('project_block');	
	ma_ShowLayer ('project_block11');
	
	ma_HideLayers (pre_text);
	ma_ShowLayer (showthis);	
	
	ma_MoveSpacer (310);
	
  } else if (showthis == 'project_row3' ) {

	ma_HideLayers ('project_block');	 
	ma_ShowLayer ('project_block22');
	
	ma_HideLayers (pre_text);
	ma_ShowLayer (showthis);
		
	ma_MoveSpacer (420);
	
  } else {
	  
  	ma_HideLayers (pre_text);
  	ma_ShowLayer (showthis);  
	
  }  
  
  
} // end ma_DisplayOneLayer



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;
}


// **************** MENU FUNCTIONS *********************

function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
} //end MM_changeProp

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}//end MM_showHideLayers

function clear_menu(id) {
	
	document.getElementById(id).style.visibility='hidden';

} //end clear_menu

var a,b,c,d,e;

function timedClear(id)
{

	switch (id) {
	   case 'dropmenu-company':  a=setTimeout("clear_menu('dropmenu-company')",400); break;
	   case 'dropmenu-services': b=setTimeout("clear_menu('dropmenu-services')",400); break;
	   case 'dropmenu-portfolio': c=setTimeout("clear_menu('dropmenu-portfolio')",400); break;
	   case 'dropmenu-news': d=setTimeout("clear_menu('dropmenu-news')",400); break;
	   case 'dropmenu-contact': e=setTimeout("clear_menu('dropmenu-contact')",400); break;
	}	
} //end timedClear


function clearTimer(id)
{
	switch (id) {
	   case 'dropmenu-company': clearTimeout(a); break;
	   case 'dropmenu-services': clearTimeout(b); break;
	   case 'dropmenu-portfolio': clearTimeout(c); break;
	   case 'dropmenu-news': clearTimeout(d); break;
	   case 'dropmenu-contact': clearTimeout(e); break;
	}
} //end clearTimer



// ****************** CUSTOM SCROLL BAR FUNCTIONS ******************************

// Custom Scroll Bar Tutorial (08-10-2005)
// by Vic Phillips http://www.vicsjavascripts.org.uk

// Functional Code - No Need to Change

var zxcDir,TO,zxcScrollObj,zxcScrollObjS,zxcSliderObj,zxcSliderObjS;
var zxcButWH,zxcSliderTravel,zxcScrollTravel,zxcRatio;
var zxcOffSetX,zxcOffSetY,zxcMseX,zxcMseY;


// Horizontal Functions

function zxcHInitialise(id){
 divobjs=document.getElementById(id).getElementsByTagName('DIV');
 for (i=0;i<divobjs.length;i++){
  if (divobjs[i].className=='Display'){
   displaywidth=divobjs[i].offsetWidth;
  }
  if (divobjs[i].className=='Scroll'){
   scrollobj=divobjs[i];
   scrollobjs=scrollobj.style;
   scrollobjs.position='absolute';
   scrollobjs.top='0px';
  }
  if (divobjs[i].className=='HBar'){
   bar=divobjs[i];
   bar.style.overflow='hidden';
   barwidth=bar.offsetWidth;
  }
  if (divobjs[i].className=='HLeft'){
   divobjs[i].style.position='absolute';
   divobjs[i].style.overflow='hidden';
   divobjs[i].style.left='0px';
   divobjs[i].style.top='0px';
   divobjs[i].style.height=bar.offsetHeight+'px';
   //divobjs[i].onmousedown=function(){ zxcLeftRight(this,0); } //adds this value to horiz position (moves right)
   //divobjs[i].onmouseup=function(){ clearTimeout(TO); }
   divobjs[i].scroll=scrollobj;
  }
  if (divobjs[i].className=='HRight'){
   divobjs[i].style.position='absolute';
   divobjs[i].style.overflow='hidden';
   buttwh=divobjs[i].offsetWidth;
   divobjs[i].style.top='0px';
   divobjs[i].style.left=(barwidth-buttwh)+'px';
   divobjs[i].style.height=bar.offsetHeight+'px';
   //divobjs[i].onmousedown=function(){ zxcLeftRight(this,0); } //subtracts this value from horiz position (moves left)
   //divobjs[i].onmouseup=function(){ clearTimeout(TO); }
   divobjs[i].scroll=scrollobj;
  }
  if (divobjs[i].className=='HSlider'){
   sliderobj=divobjs[i];
   sliderobj.onmousedown=function(event){ zxcHMseDown(this,event); }
   sliderobjs=sliderobj.style;
   sliderobjs.position='absolute';
   sliderobjs.overflow='hidden';
   sliderobjs.top='0px';
   sliderobjs.left=buttwh+'px';
   sliderobjs.height=bar.offsetHeight+'px';
   sliderobj.scroll=scrollobj;
  }
 }
 scrollobj.hslider=sliderobj;
 scrollobj.hbuttwh=buttwh;
 scrollobj.hslidertravel=barwidth-buttwh*2-sliderobj.offsetWidth;
 scrollobj.hscrolltravel=scrollobj.offsetWidth-displaywidth;
 scrollobj.hratio=scrollobj.hslidertravel/scrollobj.hscrolltravel;
}

function zxcLeftRight(obj,dir){
 if (obj){
  zxcDir=dir;
  zxcHAssignGlobals(obj);
 }
 zxcScrollObjS.left=(parseInt(zxcScrollObjS.left)+zxcDir)+'px';
 zxcSliderObjS.left=(Math.abs(parseInt(zxcScrollObjS.left))*zxcRatio+zxcButWH)+'px';
 if (zxcDir<5){ zxcDir=zxcDir*1.05; }
 if ((zxcDir<0&&Math.abs(parseInt(zxcScrollObjS.left))<zxcScrollTravel)||(zxcDir>0&&parseInt(zxcScrollObjS.left)<0)){
  TO=setTimeout('zxcLeftRight()',200);
 }
 else {
  if (zxcDir>0){ zxcScrollObjS.left='0px'; }
  if (zxcDir<0){ zxcScrollObjS.left=-zxcScrollTravel+'px'; }
 }
}

function zxcHMseDown(obj,event){
 zxcHAssignGlobals(obj);
 document.onmousemove=function(event){zxcHDrag(event);}
 document.onmouseup=function(event){zxcHMseUp(event);}
 zxcHMse(event);
 zxcOffSetX=zxcMseX-zxcSliderObj.offsetLeft;
}

function zxcHDrag(event) {
 zxcHMse(event);
 zxcSliderObjS.left=(zxcMseX-zxcOffSetX)+'px';
 if (parseInt(zxcSliderObjS.left)<zxcButWH-2){ zxcSliderObjS.left=zxcButWH+'px'; }
 if (parseInt(zxcSliderObjS.left)>zxcSliderTravel+zxcButWH+2){ zxcSliderObjS.left=(zxcSliderTravel+zxcButWH)+'px'; }
 zxcScrollObjS.left=(-(parseInt(zxcSliderObjS.left)-zxcButWH)/zxcRatio)+'px';
}

function zxcHMseUp(event) {
 document.onmousemove=null;
 document.onmouseup=null;
 if (parseInt(zxcSliderObjS.left)<=zxcButWH){
  zxcSliderObjS.left=zxcButWH+'px';
  zxcScrollObjS.left='0px';
 }
 if (parseInt(zxcSliderObjS.left)>=zxcSliderTravel+zxcButWH){
  zxcSliderObjS.left=(zxcSliderTravel+zxcButWH)+'px';
  zxcScrollObjS.left=(-zxcScrollTravel)+'px';
 }
}

function zxcHAssignGlobals(obj){
 zxcScrollObjS=obj.scroll.style;
 zxcSliderObj=obj.scroll.hslider;
 zxcSliderObjS=obj.scroll.hslider.style;
 zxcScrollTravel=obj.scroll.hscrolltravel;
 zxcSliderTravel=obj.scroll.hslidertravel;
 zxcButWH=obj.scroll.hbuttwh;
 zxcRatio=obj.scroll.hratio;
}


function zxcHMse(event){
 if(!event) var event=window.event;
 if (document.all){ zxcMseX=event.clientX; }
 else {zxcMseX=event.pageX; }
}






