//setup onload
window.onload=function(){onl();}

function adsense_tracking(totalcart){document.getElementById("trakimg").src="http://www.googleadservices.com/pagead/conversion/1057238335/imp.gif?value=totalcart&label=purchase&script=0"}

//general javascript functions
function af(name){

//window.external.AddFavorite(location.href,name)
if (window.sidebar) { 
window.sidebar.addPanel(name, location.href,""); 
} else if( document.all ) {
window.external.AddFavorite( location.href, name);
} else if( window.opera && window.print ) {
return true;
}

}
function ap(){window.print();}
function cD(el) {if (el.defaultValue==el.value) el.value = "";}
function ires(gall) { 
window.open('http://www.tangkoko.co.uk/c/gallery.php?id='+gall,'tangkokogallery','left=20,top=20,width=550,height=420,toolbar=0,resizable=0');
}
function hom(){
window.location.href="http://www.tangkoko.co.uk";
}

function so1(){
document.getElementById("q2").style.border="2px solid #7a996f";
document.getElementById("q2").style.height="19px";
document.getElementById("q2").style.width="250px";
document.getElementById("q2").style.padding="3px 0px 0px 6px";
}

function so2(){
document.getElementById("q2").style.border="2px solid #96b28c";
document.getElementById("q2").style.height="19px";
document.getElementById("q2").style.width="250px";
document.getElementById("q2").style.padding="3px 0px 0px 6px";
}

function show_guide(){

navt=document.getElementById("guides");
if (navt) {
navt.style.display="block";
navt.style.visibility="visible";
}

}

function onl() {

navt=document.getElementById("guides");
if (navt) {
navt.style.display="none";
navt.style.visibility="hidden";
}


navt=document.getElementById("nv7");
if (navt) {AttachEvent(navt, "mouseover",function(){ys('menu1','nv7');})
AttachEvent(navt, "mouseout",function(){yh('menu1','nv7');})
}

navt=document.getElementById('nv8');
if (navt) {AttachEvent(navt, "mouseover",function(){ys('menu2','nv8');})
AttachEvent(navt, "mouseout",function(){yh('menu2','nv8');})
}

navt=document.getElementById('nv9');
if (navt) {AttachEvent(navt, "mouseover",function(){ys('menu3','nv9');})
AttachEvent(navt, "mouseout",function(){yh('menu3','nv9');})
}

navt=document.getElementById('nv10');
if (navt) {AttachEvent(navt, "mouseover",function(){ys('menu4','nv10');})
AttachEvent(navt, "mouseout",function(){yh('menu4','nv10');})
}

//now check for add to basket buttons that need fixing
var browser=navigator.appName;
go=1;
n=0;
while (go==1) { 
  pn=document.getElementById("atb"+n);
  if (pn){
			
	if (browser=="Microsoft Internet Explorer"){

    AttachEvent(pn, "click",function(){atbc(event);});
    AttachEvent(pn, "mouseover",function(){atbm(event);})
  } else {
    AttachEvent(pn, "click",function(){atbc(this);});
    AttachEvent(pn, "mouseover",function(){atbm(this);})
  
  }
  	
	} else { go=0;}

n=n+1;
}

//check for images
go=1;
n=0;

while (go==1) { 
  pn=document.getElementById("pic"+n);
  if (pn){
		
	if (browser=="Microsoft Internet Explorer"){

    AttachEvent(pn, "click",function(){atbd(event);});
    AttachEvent(pn, "mouseover",function(){fw2(event);});
    AttachEvent(pn, "mouseout",function(){fv2(event);})
  } else {
    AttachEvent(pn, "click",function(){atbd(this);});
    AttachEvent(pn, "mouseover",function(){fw2(this);});
    AttachEvent(pn, "mouseout",function(){fv2(this);})
  
  }
  	
	} else { go=0;}

n=n+1;
}

}

function atbm(e) {

  var browser=navigator.appName;
 
	if (browser=="Microsoft Internet Explorer"){		
	var targ;
	
	targ=doSomething(e);
	
   targ.style.cursor="hand";
   targ.style.cursor="pointer";
   targ.mozopacity = ".99";
  targ.style.opacity = ".99";   
   
   } else {
   
   
   e.style.cursor="hand";
   e.style.cursor="pointer";
   
   }
}

function doSomething(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	return targ;
}


//product link
function atbd (e) {

var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer"){		
			
		targ=doSomething(e);
var urlb=targ.title;

} else {
urlb=e.title;

}

urlb=urlb.replace("-","/");
urlb=urlb.replace("-","/");
urlb=urlb.replace(" ","-");
urlb=urlb.replace(" ","-");
urlb=urlb.replace(" ","-");
urlb=urlb.replace(" ","-");
urlb=urlb.replace(" ","-");
urlb=urlb+".htm";
location.href = "http://www.tangkoko.co.uk"+urlb;
}

function atbf (item) {

}

//adds item to basket
function atbc (e) {
	
  var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer"){		
			
		targ=doSomething(e);
		//targ = targ.parentNode;
urchinTracker('/clicks/add-to-basket/'+targ.title);
location.href = "http://www.tangkoko.co.uk/cart/basket.php?pid="+targ.title; 
   } else {
urchinTracker('/clicks/add-to-basket/'+e.title);
location.href = "http://www.tangkoko.co.uk/cart/basket.php?pid="+e.title; }
}

function afc(){
document.filt1.funiquename2.value=document.filt2.funiquename.value;}

function rm(){
item=document.getElementById("rm1");
item.style.visibility="visible";
item.style.display="block";

item=document.getElementById("rm2");
item.style.visibility="hidden";
item.style.display="none";
}


function fv2(e){var browser=navigator.appName;
 
	if (browser=="Microsoft Internet Explorer"){		
  	var targ;
  	targ=doSomething(e);
    targ.style.filter = "alpha(opacity=70)";
	  
    targ.mozopacity = ".70";
    targ.style.opacity = ".70";   
   } else {
    e.style.mozopacity = ".70";
    e.style.opacity = ".70";
    
   }
}

function fw2(e){var browser=navigator.appName;
 
	if (browser=="Microsoft Internet Explorer"){		
  	var targ;
  	targ=doSomething(e);
    targ.style.filter = "alpha(opacity=99)";
	  targ.mozopacity = ".99";
	  targ.style.cursor="hand";
    targ.style.cursor="pointer";
    targ.style.opacity = ".99";   
   } else {
   
   e.style.opacity = ".99";
    e.style.mozopacity = ".99";
    e.style.cursor="hand";
    e.style.cursor="pointer";
       
   }
}

function fw(tag){
document.getElementById(tag).style.filter = "alpha(opacity=100)";
document.getElementById(tag).mozopacity = ".99";
document.getElementById(tag).style.opacity = ".99";
}

function fv(tag){
document.getElementById(tag).style.filter = "alpha(opacity=70)";
document.getElementById(tag).mozopacity = ".70";
document.getElementById(tag).style.opacity = ".70";
}


//attach event
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
//new code for events
function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else{
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
} 

//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
	if (!obj.myEvents) obj.myEvents={};
	if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	var evts = obj.myEvents[evt];
	evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
}

/* --- BoxOver ---
/* --- v 2.1 17th June 2006
By Oliver Bryant with help of Matthew Tagg
http://boxover.swazz.org */

if (typeof document.attachEvent!='undefined') {
   window.attachEvent('onload',init);
   document.attachEvent('onmousemove',moveMouse);
   document.attachEvent('onclick',checkMove); }
else {
   window.addEventListener('load',init,false);
   document.addEventListener('mousemove',moveMouse,false);
   document.addEventListener('click',checkMove,false);
}

var oDv=document.createElement("div");
var dvHdr=document.createElement("div");
var dvBdy=document.createElement("div");
var windowlock,boxMove,fixposx,fixposy,lockX,lockY,fixx,fixy,ox,oy,boxLeft,boxRight,boxTop,boxBottom,evt,mouseX,mouseY,boxOpen,totalScrollTop,totalScrollLeft;
boxOpen=false;
ox=10;
oy=10;
lockX=0;
lockY=0;

function init() {
	oDv.appendChild(dvHdr);
	oDv.appendChild(dvBdy);
	oDv.style.position="absolute";
	oDv.style.visibility='hidden';
	oDv.style.zIndex='920';
	document.body.appendChild(oDv);	
}

function defHdrStyle() {
	dvHdr.innerHTML='<img  style="vertical-align:middle"  src="info.gif">&nbsp;&nbsp;'+dvHdr.innerHTML;
	dvHdr.style.fontWeight='bold';
	dvHdr.style.width='150px';
	dvHdr.style.fontFamily='arial';
	dvHdr.style.border='1px solid #A5CFE9';
	dvHdr.style.padding='3';
	dvHdr.style.fontSize='11';
	dvHdr.style.color='#4B7A98';
	dvHdr.style.background='#D5EBF9';
	dvHdr.style.filter='alpha(opacity=85)'; // IE
	dvHdr.style.opacity='0.85'; // FF
}

function defBdyStyle() {
	dvBdy.style.borderBottom='1px solid #A5CFE9';
	dvBdy.style.borderLeft='1px solid #A5CFE9';
	dvBdy.style.borderRight='1px solid #A5CFE9';
	dvBdy.style.width='150px';
	dvBdy.style.fontFamily='arial';
	dvBdy.style.fontSize='11';
	dvBdy.style.padding='3';
	dvBdy.style.color='#1B4966';
	dvBdy.style.background='#FFFFFF';
	dvBdy.style.filter='alpha(opacity=85)'; // IE
	dvBdy.style.opacity='0.85'; // FF
}

function checkElemBO(txt) {
if (!txt || typeof(txt) != 'string') return false;
if ((txt.indexOf('header')>-1)&&(txt.indexOf('body')>-1)&&(txt.indexOf('[')>-1)&&(txt.indexOf('[')>-1)) 
   return true;
else
   return false;
}

function scanBO(curNode) {
	  if (checkElemBO(curNode.title)) {
         curNode.boHDR=getParam('header',curNode.title);
         curNode.boBDY=getParam('body',curNode.title);
			curNode.boCSSBDY=getParam('cssbody',curNode.title);			
			curNode.boCSSHDR=getParam('cssheader',curNode.title);
			curNode.IEbugfix=(getParam('hideselects',curNode.title)=='on')?true:false;
			curNode.fixX=parseInt(getParam('fixedrelx',curNode.title));
			curNode.fixY=parseInt(getParam('fixedrely',curNode.title));
			curNode.absX=parseInt(getParam('fixedabsx',curNode.title));
			curNode.absY=parseInt(getParam('fixedabsy',curNode.title));
			curNode.offY=(getParam('offsety',curNode.title)!='')?parseInt(getParam('offsety',curNode.title)):10;
			curNode.offX=(getParam('offsetx',curNode.title)!='')?parseInt(getParam('offsetx',curNode.title)):10;
			curNode.fade=(getParam('fade',curNode.title)=='on')?true:false;
			curNode.fadespeed=(getParam('fadespeed',curNode.title)!='')?getParam('fadespeed',curNode.title):0.04;
			curNode.delay=(getParam('delay',curNode.title)!='')?parseInt(getParam('delay',curNode.title)):0;
			if (getParam('requireclick',curNode.title)=='on') {
				curNode.requireclick=true;
				document.all?curNode.attachEvent('onclick',showHideBox):curNode.addEventListener('click',showHideBox,false);
				document.all?curNode.attachEvent('onmouseover',hideBox):curNode.addEventListener('mouseover',hideBox,false);
			}
			else {// Note : if requireclick is on the stop clicks are ignored   			
   			if (getParam('doubleclickstop',curNode.title)!='off') {
   				document.all?curNode.attachEvent('ondblclick',pauseBox):curNode.addEventListener('dblclick',pauseBox,false);
   			}	
   			if (getParam('singleclickstop',curNode.title)=='on') {
   				document.all?curNode.attachEvent('onclick',pauseBox):curNode.addEventListener('click',pauseBox,false);
   			}
   		}
			curNode.windowLock=getParam('windowlock',curNode.title).toLowerCase()=='off'?false:true;
			curNode.title='';
			curNode.hasbox=1;
	   }
	   else
	      curNode.hasbox=2;   
}


function getParam(param,list) {
	var reg = new RegExp('([^a-zA-Z]' + param + '|^' + param + ')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]');
	var res = reg.exec(list);
	var returnvar;
	if(res)
		return res[2].replace('[[','[').replace(']]',']');
	else
		return '';
}

function Left(elem){	
	var x=0;
	if (elem.calcLeft)
		return elem.calcLeft;
	var oElem=elem;
	while(elem){
		 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderLeftWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderLeftWidth);
		 x+=elem.offsetLeft;
		 elem=elem.offsetParent;
	  } 
	oElem.calcLeft=x;
	return x;
	}

function Top(elem){
	 var x=0;
	 if (elem.calcTop)
	 	return elem.calcTop;
	 var oElem=elem;
	 while(elem){		
	 	 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderTopWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderTopWidth); 
		 x+=elem.offsetTop;
	         elem=elem.offsetParent;
 	 } 
 	 oElem.calcTop=x;
 	 return x;
 	 
}

var ah,ab;
function applyStyles() {
	if(ab)
		oDv.removeChild(dvBdy);
	if (ah)
		oDv.removeChild(dvHdr);
	dvHdr=document.createElement("div");
	dvBdy=document.createElement("div");
	CBE.boCSSBDY?dvBdy.className=CBE.boCSSBDY:defBdyStyle();
	CBE.boCSSHDR?dvHdr.className=CBE.boCSSHDR:defHdrStyle();
	dvHdr.innerHTML=CBE.boHDR;
	dvBdy.innerHTML=CBE.boBDY;
	ah=false;
	ab=false;
	if (CBE.boHDR!='') {		
		oDv.appendChild(dvHdr);
		ah=true;
	}	
	if (CBE.boBDY!=''){
		oDv.appendChild(dvBdy);
		ab=true;
	}	
}

var CSE,iterElem,LSE,CBE,LBE, totalScrollLeft, totalScrollTop, width, height ;
var ini=false;

// Customised function for inner window dimension
function SHW() {
   if (document.body && (document.body.clientWidth !=0)) {
      width=document.body.clientWidth;
      height=document.body.clientHeight;
   }
   if (document.documentElement && (document.documentElement.clientWidth!=0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) {
      width=document.documentElement.clientWidth;   
      height=document.documentElement.clientHeight;   
   }   
   return [width,height];
}


var ID=null;
function moveMouse(e) {
   //boxMove=true;
	e?evt=e:evt=event;
	
	CSE=evt.target?evt.target:evt.srcElement;
	
	if (!CSE.hasbox) {
	   // Note we need to scan up DOM here, some elements like TR don't get triggered as srcElement
	   iElem=CSE;
	   while ((iElem.parentNode) && (!iElem.hasbox)) {
	      scanBO(iElem);
	      iElem=iElem.parentNode;
	   }	   
	}
	
	if ((CSE!=LSE)&&(!isChild(CSE,dvHdr))&&(!isChild(CSE,dvBdy))){		
	   if (!CSE.boxItem) {
			iterElem=CSE;
			while ((iterElem.hasbox==2)&&(iterElem.parentNode))
					iterElem=iterElem.parentNode; 
			CSE.boxItem=iterElem;
			}
		iterElem=CSE.boxItem;
		if (CSE.boxItem&&(CSE.boxItem.hasbox==1))  {
			LBE=CBE;
			CBE=iterElem;
			if (CBE!=LBE) {
				applyStyles();
				if (!CBE.requireclick)
					if (CBE.fade) {
						if (ID!=null)
							clearTimeout(ID);
						ID=setTimeout("fadeIn("+CBE.fadespeed+")",CBE.delay);
					}
					else {
						if (ID!=null)
							clearTimeout(ID);
						COL=1;
						ID=setTimeout("oDv.style.visibility='visible';ID=null;",CBE.delay);						
					}
				if (CBE.IEbugfix) {hideSelects();} 
				fixposx=!isNaN(CBE.fixX)?Left(CBE)+CBE.fixX:CBE.absX;
				fixposy=!isNaN(CBE.fixY)?Top(CBE)+CBE.fixY:CBE.absY;			
				lockX=0;
				lockY=0;
				boxMove=true;
				ox=CBE.offX?CBE.offX:10;
				oy=CBE.offY?CBE.offY:10;
			}
		}
		else if (!isChild(CSE,dvHdr) && !isChild(CSE,dvBdy) && (boxMove))	{
			// The conditional here fixes flickering between tables cells.
			if ((!isChild(CBE,CSE)) || (CSE.tagName!='TABLE')) {   			
   			CBE=null;
   			if (ID!=null)
  					clearTimeout(ID);
   			fadeOut();
   			showSelects();
			}
		}
		LSE=CSE;
	}
	else if (((isChild(CSE,dvHdr) || isChild(CSE,dvBdy))&&(boxMove))) {
		totalScrollLeft=0;
		totalScrollTop=0;
		
		iterElem=CSE;
		while(iterElem) {
			if(!isNaN(parseInt(iterElem.scrollTop)))
				totalScrollTop+=parseInt(iterElem.scrollTop);
			if(!isNaN(parseInt(iterElem.scrollLeft)))
				totalScrollLeft+=parseInt(iterElem.scrollLeft);
			iterElem=iterElem.parentNode;			
		}
		if (CBE!=null) {
			boxLeft=Left(CBE)-totalScrollLeft;
			boxRight=parseInt(Left(CBE)+CBE.offsetWidth)-totalScrollLeft;
			boxTop=Top(CBE)-totalScrollTop;
			boxBottom=parseInt(Top(CBE)+CBE.offsetHeight)-totalScrollTop;
			doCheck();
		}
	}
	
	if (boxMove&&CBE) {
		// This added to alleviate bug in IE6 w.r.t DOCTYPE
		bodyScrollTop=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
		bodyScrollLet=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;
		mouseX=evt.pageX?evt.pageX-bodyScrollLet:evt.clientX-document.body.clientLeft;
		mouseY=evt.pageY?evt.pageY-bodyScrollTop:evt.clientY-document.body.clientTop;
		if ((CBE)&&(CBE.windowLock)) {
			mouseY < -oy?lockY=-mouseY-oy:lockY=0;
			mouseX < -ox?lockX=-mouseX-ox:lockX=0;
			mouseY > (SHW()[1]-oDv.offsetHeight-oy)?lockY=-mouseY+SHW()[1]-oDv.offsetHeight-oy:lockY=lockY;
			mouseX > (SHW()[0]-dvBdy.offsetWidth-ox)?lockX=-mouseX-ox+SHW()[0]-dvBdy.offsetWidth:lockX=lockX;			
		}
		oDv.style.left=((fixposx)||(fixposx==0))?fixposx:bodyScrollLet+mouseX+ox+lockX+"px";
		oDv.style.top=((fixposy)||(fixposy==0))?fixposy:bodyScrollTop+mouseY+oy+lockY+"px";		
		
	}
}

function doCheck() {	
	if (   (mouseX < boxLeft)    ||     (mouseX >boxRight)     || (mouseY < boxTop) || (mouseY > boxBottom)) {
		if (!CBE.requireclick)
			fadeOut();
		if (CBE.IEbugfix) {showSelects();}
		CBE=null;
	}
}

function pauseBox(e) {
   e?evt=e:evt=event;
	boxMove=false;
	evt.cancelBubble=true;
}

function showHideBox(e) {
	oDv.style.visibility=(oDv.style.visibility!='visible')?'visible':'hidden';
//	oDv.style.zIndex="980";
}

function hideBox(e) {
	oDv.style.visibility='hidden';
}

var COL=0;
var stopfade=false;
function fadeIn(fs) {
		ID=null;
		COL=0;
		oDv.style.visibility='visible';
		fadeIn2(fs);
}

function fadeIn2(fs) {
		COL=COL+fs;
		COL=(COL>1)?1:COL;
		oDv.style.filter='alpha(opacity='+parseInt(100*COL)+')';
		oDv.style.opacity=COL;
		if (COL<1)
		 setTimeout("fadeIn2("+fs+")",20);		
}


function fadeOut() {
	oDv.style.visibility='hidden';
	
}

function isChild(s,d) {
	while(s) {
		if (s==d) 
			return true;
		s=s.parentNode;
	}
	return false;
}

var cSrc;
function checkMove(e) {
	e?evt=e:evt=event;
	cSrc=evt.target?evt.target:evt.srcElement;
	if ((!boxMove)&&(!isChild(cSrc,oDv))) {
		fadeOut();
		if (CBE&&CBE.IEbugfix) {showSelects();}
		boxMove=true;
		CBE=null;
	}
}

function showSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
}

function hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
   elements[i].style.visibility='hidden';
   }
}

function showhide(id,final){

	final++;

	for (i=0;i<final;i++){

		//make combo visible
		objb=document.getElementById(id+i);
		objb.style.visbility = "visible";
		objb.style.display = "block";

		//make add buttons invisible
		objb=document.getElementById(id+"b"+i);
		objb.style.visbility = "hidden";
		objb.style.display = "none";
	}

	//make final add button visible, if found <9
	if (final<12) {
		final=final-1;
		objb=document.getElementById(id+"b"+final);
		objb.style.visbility = "visible";
		objb.style.display = "block";
	}
}

function ConversionCount()
{
_uacct = 'UA-183928-2';
urchinTracker("/1050110221/goal");
return true;

}


var opac = 60;
var boxopac =0;
var maximages = 4;
var currimage=1;
var haltfade=0;
var boxfades=0;
var currfade='0';

function f2(){
document.getElementById('mc4').cursor="pointer";
if (currfade=='0'){
currfade='2';
dofade('2');
} else { window.setTimeout("f2()",2000);}


}

function f1(){
document.getElementById('mc4').cursor="pointer";
if (currfade=='0'){
currfade='1';
dofade('1');
} else { window.setTimeout("f1()",2000);}
}

function dofade(mcp){
opac=opac-3;
document.getElementById("mc"+mcp).style.filter = "alpha(opacity="+opac+")";
document.getElementById("mc"+mcp).mozopacity = "0."+opac;
document.getElementById("mc"+mcp).style.opacity = "0."+opac;
//alert(mcp);

if (opac<13) { 
//alert(opac);

	if (mcp=="2") { mcp2="1"; }
	if (mcp=="1") { mcp2="2"; }
	cont=document.getElementById("mc"+mcp).innerHTML;
	document.getElementById("mc"+mcp).innerHTML=document.getElementById("mc"+mcp2).innerHTML;
	document.getElementById("mc"+mcp2).innerHTML=cont;
	window.setTimeout("infade('"+mcp+"')",20); 
} else { 
//	alert(currfade);
//	alert(mcp);
	if (currfade==mcp) { window.setTimeout("dofade('"+mcp+"')",15); }
}

}


function infade(mcp){
opac=opac+3;
document.getElementById("mc"+mcp).style.filter = "alpha(opacity="+opac+")";
document.getElementById("mc"+mcp).mozopacity = "0."+opac;
document.getElementById("mc"+mcp).style.opacity = "0."+opac;;
	//alert(opac);
	if (opac>70) { currfade='0';}
	else { if (currfade==mcp) { window.setTimeout("infade("+mcp+")",5); }
	}	
}

function yh(id,id2){
ypSlideOutMenu.hideMenu(id);
document.getElementById(id2).style.color="#FFFFFF";
}
function ys(id,id2){
ypSlideOutMenu.showMenu(id);
document.getElementById(id2).style.color="#96b28c";
}

ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 250
ypSlideOutMenu.hideDelay = 200
ypSlideOutMenu.minCPUResolution = 10

// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	this.css = "";

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0

		// global reference to this object
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this

		var d = document

		var strCSS = "";
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		strCSS += 'left:' + left + 'px; '
		strCSS += 'top:' + top + 'px;z-index:900; '
		strCSS += 'overflow:hidden; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += 'width:' + width + 'px;z-index:900; '
		strCSS += 'height:' + height + 'px; '
		strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
		strCSS += '}'

		this.css = strCSS;

		this.load()
	}
}

ypSlideOutMenu.writeCSS = function() {
	document.writeln('<style type="text/css">');

	for (var id in ypSlideOutMenu.Registry) {
		document.writeln(ypSlideOutMenu.Registry[id].css);
	}

	document.writeln('</style>');
}

ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")

		//set initial state
		this.endSlide()
	}
}
	
ypSlideOutMenu.showMenu = function(id)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	
	if (obj.container) {
		obj.over = true

		// close other menus.
		for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu)

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		// if this menu is closed, open it.
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}

ypSlideOutMenu.hideMenu = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = ypSlideOutMenu.Registry[id]
	if (obj.container) {
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	}
}

ypSlideOutMenu.hideAll = function()
{
	var reg = ypSlideOutMenu.Registry
	for (menu in reg) {
		ypSlideOutMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}

ypSlideOutMenu.hide = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()	
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}

ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

    // events
    ypSlideOutMenu.prototype.onactivate		= function() { }
    ypSlideOutMenu.prototype.ondeactivate	= function() { }

	  // the number you pass to initLeft doesn't matter since it will get
		// changed onactivate
		var myMenu1 = new ypSlideOutMenu("menu1", "down", -1000, 135, 180, 130)
		var myMenu2 = new ypSlideOutMenu("menu2", "down", -1000, 135, 180, 295)
		var myMenu3 = new ypSlideOutMenu("menu3", "down", -1000, 135, 180, 88)
		var myMenu4 = new ypSlideOutMenu("menu4", "down", -1000, 135, 180, 128)
     
    // for each menu, we set up the onactivate event to call repositionMenu with the amount offset from center, in pixels
        
    if (navigator.userAgent.indexOf("Firefox")!=-1) {	myMenu1.onactivate = function() { repositionMenu(myMenu1, -449); } 
    	myMenu2.onactivate = function() { repositionMenu(myMenu2, -393); } 
      myMenu3.onactivate = function() { repositionMenu(myMenu3, -317); }
      myMenu4.onactivate = function() { repositionMenu(myMenu4, -257); }
    } else {
    myMenu1.onactivate = function() { repositionMenu(myMenu1, -441); } 
    myMenu2.onactivate = function() { repositionMenu(myMenu2, -385); }
    myMenu3.onactivate = function() { repositionMenu(myMenu3, -309); }
    myMenu4.onactivate = function() { repositionMenu(myMenu4, -249); }
    }
    
    // this function repositions a menu to the speicified offset from center
		function repositionMenu(menu, offset)
		{
    // the new left position should be the center of the window + the offset

		if (getWindowWidth()>1000) { 
			var newLeft = (getWindowWidth() / 2) + offset;
		} else {
			if (navigator.userAgent.indexOf("Firefox")!=-1) {var newLeft = 513+ offset;
			} else { 	var newLeft = 505+ offset; }
		}		

    // setting the left position in netscape is a little different than IE
		menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
		}
		 
    // this function calculates the window's width - different for IE and netscape
		function getWindowWidth()
		{
			return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
		}	

ypSlideOutMenu.writeCSS();
