var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");        

var isIE=navigator.userAgent.indexOf("IE")>0;

var isIE5=navigator.userAgent.indexOf("IE 5.0")>0;

var isIE6=navigator.userAgent.indexOf("IE 6.0")>0;

var isNav=(navigator.appName.indexOf("Netscape")!=-1);

var FRIENDLY_URLS=true;

var element;

function jq(obj){

	return typeof(obj) == "string" ? document.getElementById(obj) : obj;

}

String.prototype.trim=function(){

	return this.replace(/(^[\s]*)|([\s]*$)/g, "");

};



function toggle(el) {
    el = jq(el);

	if(el.style.display=="none"){

		el.style.display='block';

	}else{

		el.style.display='none';

	}

}



function selectTag(showContent,selfObj){

	// ²Ù×÷±êÇ©

	var tag = document.getElementById("tags").getElementsByTagName("li");

	var taglength = tag.length;

	for(i=0; i<taglength; i++){

		tag[i].className = "";

	}

	selfObj.parentNode.className = "selectTag";

	// ²Ù×÷ÄÚÈÝ

	for(i=0; j=document.getElementById("tagContent"+i); i++){

		j.style.display = "none";

	}

	document.getElementById(showContent).style.display = "block";	

}





/*==================================================*/



function scrollup(o,h,d){	

	timer_flg = false;

	if(d==h){

	   var t = o.firstChild;

	   o.appendChild(t);

	   t.style.marginTop=o.firstChild.style.marginTop='0px';

	   d=0;

	   timer_flg = true;

	}

	else{

	   var s=3,d=d+s,l=(d>=h?d-h:0);

	   o.firstChild.style.marginTop=-d+l+'px';

	   window.setTimeout(function(){scrollup(o,h,d-l)},20);

	}

}





function scrollup_online(o,h,d){

	online_timer_flg = false;

	if(d==h){

	   var t = o.firstChild;

	   o.appendChild(t);

	   t.style.marginTop=o.firstChild.style.marginTop='0px';

	   d=0;

	   online_timer_flg = true;

	}

	else{

	   var s=3,d=d+s,l=(d>=h?d-h:0);

	   o.firstChild.style.marginTop=-d+l+'px';

	   window.setTimeout(function(){scrollup_online(o,h,d-l)},20);

	}

}



///////////////

function addListener(element, type, expression, bubbling)

{

  bubbling = bubbling || false;

  if(window.addEventListener)	{ // Standard

    element.addEventListener(type, expression, bubbling);

    return true;

  } else if(window.attachEvent) { // IE

    element.attachEvent('on' + type, expression);

    return true;

  } else return false;

}



var ImageLoader = function(url){

  this.url = url;

  this.image = null;

  this.loadEvent = null;

};



ImageLoader.prototype = {

  load:function(){

    this.image = document.createElement('img');

    var url = this.url;

    var image = this.image;

    var loadEvent = this.loadEvent;

    addListener(this.image, 'load', function(e){

      if(loadEvent != null){

        loadEvent(url, image);

      }

    }, false);

    this.image.src = this.url;

  },

  getImage:function(){

    return this.image;

  }

};



function loadImage(objId,urls){

var loader = new ImageLoader(urls);

loader.loadEvent = function(url){

 obj = jq(objId);

 obj.src = url;

}

loader.load();

}



function hide_select(what){	

  var anchors = document.getElementsByTagName("select");

  if (what=="in") {

 	 for (var i=0; i<anchors.length; i++) {

 	 	if(anchors[i].getAttribute("rel")=="dropdown"){

 			anchors[i].style.visibility="hidden";

 	 	}

 	 }

  } 

  else {

 	for (var i=0; i<anchors.length; i++) {

 		if(anchors[i].getAttribute("rel")=="dropdown"){

 	    	anchors[i].style.visibility="visible";

 		}

	}

  }

}



function back(num){

	history.go(num);

	return false;

}





function rewrite_url(pname , pid){

	if(pid == null || pid == "undefined" ) {return ""};

	var re = /[^a-zA-Z0-9]/ig;

	var url = "";

	if(FRIENDLY_URLS != null && FRIENDLY_URLS == 'true'){

		url = baseURL + pname.replace(re,"-") + "-p-" + pid + ".html";

	}

	else{

		url = linkURL+pid;

	}

	return url;

}



function page_go(id,num, c,t,cid){

	var Prev = id + "Prev";

	var Next = id + "Next";	

	var pageId ="recent_flash_smallPage";//id + "Page"

	var Page = 0;

	var currentPage = 1;

	var PageNumber = Math.ceil(t/num);

	var activeClick = true;

	var gopage = 0;



	if(num>t){activeClick = false;}

	if(c >= num){

		if(t!=null){

			gopage = Math.ceil(c/num);

			if(c % num == 0) gopage++; 		

		}

		updateProduct('goto', gopage);

	}

	

	function updateProduct(type, gopage) {

		if(type=='pre') {Page -= parseInt(num);currentPage--};

		if(type=='next') {Page += parseInt(num);currentPage++};

		if(type=='goto' && gopage != null) {Page = (gopage-1) * num ; currentPage = gopage;}

		if(Page<0) {

			Page=num*(PageNumber-1);

			currentPage=PageNumber;

		}

		if(Page>=t) {

			Page=0;

			currentPage=1;

		}

		

		jq(pageId).innerHTML = currentPage +'/'+PageNumber;

		

		for(i=0;i<num;i++){

			if(i >= productPrice.length){

				break;

			}

			n_page = i + Page;

			jq('cell_price'+i).innerHTML=productPrice[n_page];

			jq('cell_link'+i).href = rewrite_url(productName[n_page], productID[n_page]);

			jq('cell_link'+i).title = productName[n_page];

			

			jq('li'+i).style.display='block';

			if(productID[n_page] == null){

				jq('li'+i).style.display='none';

				continue;

			}

			if(num==4)jq('cell_img'+i).src=baseURL+"images/root/loading_img_b.gif";

			if(num==8)jq('cell_img'+i).src=baseURL+"images/root/loading_img_s.gif";

			jq('cell_img'+i).alt=productName[n_page];

			jq('cell_img'+i).title=productName[n_page];

			loadImage('cell_img'+i,imgURL+productIMG[n_page]);

			if(cid != null){

				if(cid == productID[n_page]){

					jq('cell_img'+i).className = 'allborder';

				}

				else{

					jq('cell_img'+i).className = '';

				}

			}

			

			if(productSourcePrice != null){

				jq('cell_source_price'+i).innerHTML=productSourcePrice[n_page];

			}

			if(productSubName != null && productName != null){

				jq('cell_name_link'+i).innerHTML=productSubName[n_page];

				jq('cell_name_link'+i).href=rewrite_url(productName[n_page], productID[n_page]);

				jq('cell_name_link'+i).title=productName[n_page];

			}

			if(productFlg != null){

				var tmp = productFlg[n_page].split('#');

				if(tmp.length < 4) continue;

				jq('sold_out_s'+i).style.display = (tmp[0] > 0) ? 'block' : 'none';

				jq('almost_sold_out_s'+i).style.display = (tmp[1] > 0) ? 'block' : 'none';				

				if(tmp[2] > 0){

					jq('product_count_s'+i).innerHTML=tmp[2];

				}

				jq('product_count_s'+i).style.display = (tmp[2] > 0) ? 'block' : 'none';				

				jq('sale_item_s'+i).style.display = (tmp[3] > 0) ? 'block' : 'none';				

			}

		}

	}



	jq(pageId).innerHTML = currentPage +'/'+PageNumber;

	jq(Prev).onclick = function () {

		if(!activeClick) return false;

		updateProduct('pre');

	}

	jq(Next).onclick = function () {

		if(!activeClick) return false;

		updateProduct('next');

	}	

}





function HoverLi(n){	

	for(var i=1;i<=4;i++){ 

		jq('tbc_0'+i).className='undis'; 

		jq('tb_'+i).className= 'off'; 

	}

	jq('tbc_0'+n).className='dis';

	jq('tb_'+n).className= 'on';

}

function toggle(el, over)
{
 var ul=$(el).find("ul");
 if (over) {
  ul.show();
 }
 else {
 ul.hide();
 }
}

function showCatvert(display){
	var temp="#"+display;

    element = jq(display);
	
	view_element = jq('view_all_'+display.split('_')[2]);
	

	if(element.style.display == "none" ){
		$(temp).slideDown();
		view_element.innerHTML = view_element.innerHTML.replace('View All...','Click to Hide...');
	}
	else {
		$(temp).slideUp();
		view_element.innerHTML = view_element.innerHTML.replace('Click to Hide...','View All...');
	}
}

/* Bgiframe
 * Version 2.1.2
 */
(function(a){a.fn.bgiframe=(a.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(d){d=a.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:true,src:"javascript:false;"},d);var c='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+d.src+'"style="display:block;position:absolute;z-index:-1;'+(d.opacity!==false?"filter:Alpha(Opacity='0');":"")+"top:"+(d.top=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":b(d.top))+";left:"+(d.left=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":b(d.left))+";width:"+(d.width=="auto"?"expression(this.parentNode.offsetWidth+'px')":b(d.width))+";height:"+(d.height=="auto"?"expression(this.parentNode.offsetHeight+'px')":b(d.height))+';"/>';return this.each(function(){if(a(this).children("iframe.bgiframe").length===0){this.insertBefore(document.createElement(c),this.firstChild)}})}:function(){return this});a.fn.bgIframe=a.fn.bgiframe;function b(c){return c&&c.constructor===Number?c+"px":c}})(jQuery);



jQuery(function() {
  $(".level2").bgiframe();
 jQuery('#productMainImage a').lightBox();

for(var i=0; i<document.links.length; i++)

document.links[i].onfocus=function(){this.blur()}

 jQuery("#currencies ul li a").hover(

  function () {

    jQuery("#other_currencies").css("visibility","visible");

  },

  function () {

    jQuery("#other_currencies").css("visibility","hidden");

  }

);

});



//-
