window.addEvent('domready', function() {
	// Search Field onFocus onBlur
	if($('q_search') != null){
		var textarea = $('q_search');
		
		// is a custom one we've made
		textarea.addEvents({
			focus: function() {
				// When focusing, if the textarea contains value "Type here", we
				// simply clear it.
				if (textarea.value.contains('Search Products')) textarea.value = '';
			},
			blur: function() {
				// When focusing, if the textarea contains value "Type here", we
				// simply clear it.
				if (textarea.value == '') textarea.value = 'Search Products';
			}
		});
	}
	if($('q_search2') != null){
		var textarea2 = $('q_search2');
		
		// is a custom one we've made
		textarea2.addEvents({
			focus: function() {
				// When focusing, if the textarea contains value "Type here", we
				// simply clear it.
				if (textarea2.value.contains('Search Products')) textarea2.value = '';
			},
			blur: function() {
				// When focusing, if the textarea contains value "Type here", we
				// simply clear it.
				if (textarea2.value == '') textarea2.value = 'Search Products';
			}
		});
	}
	
	//Nikken Select Country Language
	$('nik_sel_opt').setStyle('display','none');
	$('sel_action').addEvent('click', function(){	$('nik_sel_opt').setStyle('display',''); return false; });
	$('nik_sel_all').addEvent('mouseleave', function(){ $('nik_sel_opt').setStyle('display','none'); return false; });
	
	//Add to Cart Options window - close window function
	if(Browser.Engine.trident && $('top_bar') != null){
		$('top_bar').addEvent('click', function(){ hideOptionsWindow(); });
	}
	//Category Page Item Container - Removes all empty item DIVs.
	if($('categorypage_item_container') != null){
		var empty_catpage_items = $$('.categorypage_item');
		empty_catpage_items.each(function(item, index){
			if(item.innerHTML.clean() == ""){
				item.dispose();
			}
		});
	}
});

var currentimageheight = 254;
var trailimage = ["", 443, 254]; //image path, plus width and height
var offsetfrommouse = [16,16]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration = 0; //duration in seconds image should remain visible. 0 for always.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename){
	document.onmousemove=followmouse;
	newHTML = '<div style="background-color:#fff; border: 3px solid #ccc;">';
	newHTML = newHTML + '<div>';
	newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
	newHTML = newHTML + '</div>';
	$('trailimageid').innerHTML = newHTML;
	$('trailimageid').setStyle('display','inline');
}


function hidetrail(){
	$('trailimageid').innerHTML = '';
	$('trailimageid').setStyle('display','none');
	document.onmousemove="";
	$('trailimageid').setStyle('left','-500px');

}

function followmouse(e){
	var xcoord = offsetfrommouse[0];
	var ycoord = offsetfrommouse[1];
	
	var docwidth = document.all? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15;
	var docheight = document.all? Math.min(truebody().scrollHeight,truebody().clientHeight) : Math.min(window.innerHeight);
	
	//alert(docheight);
	
	if(typeof e != "undefined"){
		if(docwidth - e.pageX < 443){
			xcoord += e.pageX - xcoord - 463;
		}else{
			xcoord += e.pageX;
		}
		if(docheight - e.pageY < (currentimageheight + 100)){
			if(document.body){
				scrollTop = Math.max(truebody().scrollTop,document.body.scrollTop);
				//alert(scrollTop);
			}else{
				scrollTop = truebody().scrollTop;
			}
			ycoord += e.pageY - Math.max(0,(100 + currentimageheight + e.pageY - docheight - scrollTop));
		}else{
			ycoord += e.pageY;
		}
	}else if(typeof window.event != "undefined"){
		if(docwidth - event.clientX < 443){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 463;
		}else{
			xcoord += truebody().scrollLeft + event.clientX;
		}
		if(docheight - event.clientY < (currentimageheight + 100)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(100 + currentimageheight + event.clientY - docheight));
		}else{
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	if(ycoord < 0){
		ycoord = ycoord *- 1;
	}
	$('trailimageid').setStyle('left', xcoord + "px");
	$('trailimageid').setStyle('top', ycoord + "px");
}


//********* Dreamweaver Code for Gina **********

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



