function silentErrorHandler() {return true;}
window.onerror=silentErrorHandler;

function switch_details()
{
	var cart = document.getElementById('cart_detail');
	var _cur_state = cart.style.display;
	if (_cur_state == 'none')
		cart.style.display = "block";
	else
		cart.style.display = "none";
}


function save_state()
{
	var cart = document.getElementById('cart_detail');
	var cookiename = 'detail_state';
	var cookievalue = cart.style.display;
	document.cookie = cookiename+"="+cookievalue;
}


function load_state()
{
	var cart = document.getElementById('cart_detail');
	var search = 'detail_state' + "=";
	var returnvalue = "";
	if (document.cookie.length > 0);
	{
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end));
		}
	}

	if (returnvalue != 'none') returnvalue = 'block';
	cart.style.display=returnvalue;
}


function iecompattest()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
}

function showall()
{
	var category = document.getElementById('all_category');
	category.style.left = startX;
	category.style.top = startY;
	var _cur_state = category.style.display;
	if (_cur_state == 'none')
		category.style.display = "block";
	else
		category.style.display = "none";
}

var ie5=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;
var startX=ns6 ? ((window.innerWidth-750) / 2 + 250)+"px" : ((iecompattest().clientWidth-750) / 2 + 250)+"px";
var startY=ns6 ? "48px" : "55px";

window.onload = load_state;
window.onunload = save_state;

/* Slideshow */

var SlideShowSpeed = 3000
var crossFadeDuration = 5
var Pic = new Array()

Pic[0] = 'skins/default/images/slide_1.jpg'
Pic[1] = 'skins/default/images/slide_2.jpg'
Pic[2] = 'skins/default/images/slide_3.jpg'
Pic[3] = 'skins/default/images/slide_4.jpg'
Pic[4] = 'skins/default/images/slide_5.jpg'
Pic[5] = 'skins/default/images/slide_6.jpg'

var t
var j = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   
	 if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   
	 if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', SlideShowSpeed)
}

/*########################################### ROTATOR WITH LINK ###########################################*/

var interval = 3;
var random_display = 0;
interval *= 1000;
 
var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("rotator/ex.gif", "detail.php?item_id=513");
image_list[image_index++] = new imageItem("rotator/gaga.gif", "detail.php?item_id=507");
image_list[image_index++] = new imageItem("rotator/gelee.gif", "detail.php?item_id=493");
image_list[image_index++] = new imageItem("rotator/ramp.gif", "detail.php?item_id=509");
image_list[image_index++] = new imageItem("rotator/raydiant.gif", "detail.php?item_id=517");
image_list[image_index++] = new imageItem("rotator/reef.gif", "detail.php?item_id=511");
image_list[image_index++] = new imageItem("rotator/sol.gif", "detail.php?item_id=515");
image_list[image_index++] = new imageItem("rotator/tattoo.gif", "detail.php?item_id=519");
 
var number_of_image = image_list.length;
 
function imageItem(image_location, link) {
  this.image_item = new Image();
  this.image_item.src = image_location;
  this.image_item.link = link; 
}
 
function getNextImage() {
if (random_display) {
  image_index = Math.floor(Math.random() * image_list.length);
}
else {
  image_index = (image_index+1) % number_of_image;
}
 
  var new_image = image_list[image_index];
  return(new_image);
}
 
function rotateImage(rImage, link) {
  var new_image = getNextImage();
  document.getElementById('rImage').src = new_image.image_item.src;
  document.getElementById('rLink').href = new_image.image_item.link; 
 
  setTimeout("rotateImage()", interval);
}

