// Services
// JavaScript Document
<!--

//CONFIG
 function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }
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 MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function changeImgSrc(obj,target) {
	if (document.getElementById){
		document.getElementById(obj).src = target;
		//alert(document.getElementById(obj).src);
	}
}

function SetItem(id) {
	var code,obj;
	
	if ( id>=0 && id<items_count){
		// ***** reset current thumb style HERE
		
		newclass='thumb';
		/* not used by cutup - to determine column of a particular thumbnail
		if ((item_current+4)%4==0) {
			newclass+='T1';
		}else{
			newclass+='T2';			
		}
		*/
		//alert('thumb'+item_current+' '+document.getElementById('thumb'+item_current).className);
		document.getElementById('thumb'+item_current).className = newclass;
		
		
		obj = document.getElementById('itmImg'+item_current);
		code = 'MM_showHideLayers(\'itemOver'+item_current+'\',\'\',\'show\');';
		obj.onmouseover = new Function (code);

		
		obj = document.getElementById('thumblink'+item_current);
		code = 'MM_showHideLayers(\'itemOver'+item_current+'\',\'\',\'hide\');';
		obj.onmouseout = new Function (code);
		
		MM_showHideLayers('itemOver'+item_current,'','hide');
		changeImgSrc('maskImg'+item_current,'/images/gallery/items/over.gif');

	
		//alert(document.getElementById('img'+item_current).className);		
		item_current = id;
		
		document.getElementById('itmImg'+item_current).onmouseover = "";
		document.getElementById('thumblink'+item_current).onmouseout = "";

		
		changeImgSrc('maskImg'+item_current,'/images/gallery/items/current.gif');
		MM_showHideLayers('itemOver'+item_current,'','show');


		
		// ***** set new thumb style HERE
		
		newclass='';
		/* not used by cutup - to determine column of a particular thumbnail
		if ((item_current+4)%4==0) {
			newclass+='T1Current';
		}else{
			newclass+='T2Current';			
		}
		*/
		newclass+='itemCurrent';
		
		document.getElementById('thumb'+item_current).className = newclass;
		
		
		
	
	
		//replace rollover imageswap code
		var obj = document.getElementById('mainItm');
		if (obj) {
			
			//calculate margins for image and replace styles
			/*
			var img 	= new Image();
			img.src 	= items[id][1];
			//wait?  necessary if images sizes vary...since it may break the layout.
			if (img.complete==false) { return;}  //image not loaded yet, so margin calcs will be wrong... just drop out... it 
			//alert('img.onload:'+img.onload+' img.complete'+img.complete);
			imgh 		= img.height;
			imgh 		= img.height;
			if (imgh>441) { //portrait/squarw
				margin_top		= 477-imgh;
				margin_bottom	= 0;
			} else if (imgh>405) { //landscape
				//calculate bottom margin ... up to 36 px
				margin_top		= 36; //hold it there until the gaps are equal to the bottom
				margin_bottom	= 477-margin_top-imgh;
			} else { //landscape
				margin_top		= 36+Math.floor((441-imgh)/2);
				margin_bottom	= 477-margin_top-imgh;
			}
			*/
			
			//replace main image source and rollover code
			changeImgSrc('mainItm',items[id][1]);
			
			//use if main image has a rollover
			/*
			var code 		= 'MM_swapImage(\'mainItm\',\'\',\''+items[id][2]+'\',1)';
			obj.onmouseover = new Function (code);
			*/
			
			//change margins 
			/*
			obj.style.marginTop 	= margin_top+'px';
			obj.style.marginBottom 	= margin_bottom+'px';
			*/
			
			//alert(img.height);
			//alert(obj.onmouseover);
		}
	
	
		//Set Item text
		//*not used in cutup - to set main item text ....
		MM_setTextOfLayer('itemName','',unescape(items[id][0]));
		MM_setTextOfLayer('itemDescription','',unescape(items[id][2]));

		// set forward and back button styles
	
		if (id==0) { //first item - disable prev button
			// not used by cutup...document.getElementById('prev').style.display = 'none';
			//changeImgSrc('prev','/images/i/arrowL_0.jpg');
			// not used by cutup...document.getElementById('prev-spacer').style.display = 'block';
			//document.getElementById('prev').onmouseover = "";
			//document.getElementById('prev').onmouseout = "";
			//changeImgSrc('prev','/items/i/b.gif');
		} else {
			// not used by cutup...document.getElementById('prev').style.display = "block";
			//changeImgSrc('prev','/items/i/prev_0.gif');
			// not used by cutup...document.getElementById('prev-spacer').style.display = "none";
			//document.getElementById('prev').onmouseover = function() {changeImgSrc('prev','/items/i/prev_1.gif');}
			//document.getElementById('prev').onmouseout = function() {changeImgSrc('prev','/items/i/prev_0.gif');}
			//changeImgSrc('prev','/items/i/prev_0.gif');
		}
		
		if (id==(items_count-1)) { //last item
			// not used by cutup...document.getElementById('next').style.display = "none";
			//changeImgSrc('next','/images/i/arrowR_0.jpg');
			// not used by cutup... document.getElementById('next-spacer').style.display = "block";			
			//document.getElementById('next').onmouseover = "";
			//document.getElementById('next').onmouseout = "";
			//changeImgSrc('next','/items/i/b.gif');
		} else {
			// not used by cutup...document.getElementById('next').style.display = "block";
			//changeImgSrc('next','/items/i/next_0.gif');
			// not used by cutup...document.getElementById('next-spacer').style.display = "none";			
			//document.getElementById('next').onmouseover = function() {changeImgSrc('next','/items/i/next_1.gif');}
			//document.getElementById('next').onmouseout = function() {changeImgSrc('next','/items/i/next_0.gif');}
			//changeImgSrc('next','/items/i/next_0.gif');
		}
	}
}

function replaceLinks() {
	for (i=0;i<items_count;i++) {
		var obj = document.getElementById('thumblink'+i);
		if (obj) {
			obj.href = 'javascript:;';
			var code = 'SetItem('+i+');';
			obj.onclick = new Function (code);
		}
	}
	/* use if prev and next links change the image, not the pages.. used in lol
	var obj = document.getElementById('prevlink');
	if (obj) {
		obj.href = 'javascript:;';
		//alert(obj.onclick);
		obj.onclick = function () {SetItem(item_current-1) }
	}
	var obj = document.getElementById('nextlink');
	if (obj) {
		obj.href = 'javascript:;';
		//alert(obj.onclick);
		obj.onclick = function () {SetItem(item_current+1) }
	}
	*/
}

// OVERRIDE GOOGLE AUTOFILL
  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }
// -->