jQuery.preloadImages=function(){
for(var i=0;i<arguments.length;i++){
jQuery("<img>").attr("src",arguments[i]);}}
$(function(){
var tab_li=$('.tabs li');
if(tab_li.length>0){
var pages=$('.pages > div');
tab_li.each(function(index){
$(this).click(function(){
pages.hide();
pages.eq(index).show();
$('.tabs li').eq(indexTab).removeClass('current');
$(this).addClass('current');
indexTab=index;});});
$('.tabs li').eq(indexTab).click();}});
$(function(){
var a_countrySelector=$('select[name=country]');
var b_countrySelector=$('select[name=a_country]');
if(a_countrySelector.length>0){
var countrySelector=a_countrySelector;
var stateSelector='state';}else if(b_countrySelector.length>0){
var countrySelector=b_countrySelector;
var stateSelector='a_state';}
if(countrySelector){
$(countrySelector).change(function(){
var countryId=$(this).val();
if(parseInt(countryId)<=0)return;
var loading=$('<span id="loading">Loading...</span>');
var stateZone=$('#stateZone');
loading.appendTo(stateZone);
stateZone.empty();
$.getJSON('get_zones_'+countryId+'.json',function(data){
if(data.length>0){
var state=$('<select name="'+stateSelector+'" id="state" class="required"></selete>');
$.each(data,function(i,item){
state.append('<option value="'+item.zone_name_encode+'">'+item.zone_name+'</option>');});}else{
var state=$('<input type="text" name="'+stateSelector+'" class="required"/>');}
stateZone.append(state);
loading.remove();
if(''!=stateVal){stateZone.find('select[name="'+stateSelector+'"]').val(stateVal);stateZone.find('input[name="'+stateSelector+'"]').val(stateVal);}});});
var countryBox=countrySelector;
function countryUp(id){
var opt=countryBox.find('option[value="'+id+'"]');
opt.prependTo(countryBox);}
countryBox.prepend('<option value="-1">-----</option>');
countryUp(13);
countryUp(222);
countryUp(38);
countryUp(223);
countryBox.prepend('<option value="-1">-----</option>');
countryBox.prepend('<option value="0">Please Select...</option>');
countryBox.val(countryVal).change();}
$('.ad_banner').AdBanner();
var topBar='<a class="topBar" style="position:absolute;right:-60px;padding:2px 10px;border:1px solid #ccc;font-weight:bold;color:#c00;" href="#top">Top</a>';
$('#banggood').append(topBar);
var topBar=$('a.topBar');
topBar.click(function(){window.scrollTo(0,0);return false;}).hide();
$(window).scroll(function(){
if($(window).scrollTop()>$(window).height()/2){
var topBar_top=$(window).scrollTop()+$(window).height()-30+"px";
if(topBar.is(':hidden')){topBar.css('top',topBar_top);topBar.fadeIn(1000);}else{topBar.animate({top:topBar_top},{duration:600,queue:false});}}else{topBar.hide();}});
$('.toggleSpan').toggle(function(){var el=$(this);el.prev('span').removeClass('hide');return false;},function(){var el=$(this);el.prev('span').addClass('hide');return false;});});
function selectAddr(id){
$('input[name="address"]').val(id);
$('#frmAddress').submit();
return false;}
$(function(){
var pageSelector=$('select[name=pagestart]');
if(pageSelector.length>0){
if('undefined'!=typeof(search_page)){
pageSelector.change(function(){
location.href=search_page+'&pagestart='+this.value;});}else{
pageSelector.change(function(){
location.href=this.value;});}}
$('#menu_btn').magicMenu();
$('.help a').liveBox();
$('#ad').Ad();
$('.CRselectBox').selectBox();
var plist=$('.list_products');
if(plist.length>0){
if(plist.height()-$('.category_box').height()-$('.left_bar').height()>100)
$('.category_box').floatBar({min:$('.left_bar').height(),className:'float_left',offset:-160});
$('.list_bar').floatBar({min:$('.list_bar').position().top});}
if('undefined'!=typeof(c_index)){
$('.btn.left').click(function(){
if(c_index>1)
c_index--;
else
c_index=c_count;
parent=$(this).parent('div');
changePage('ul',c_items,c_index);});
$('.btn.right').click(function(){
if(c_index<c_count)
c_index++
else
c_index=1;
parent=$(this).parent('div');
changePage('ul',c_items,c_index);});}
$('.close_btn').click(function(){
$(this).parent('.tip_popup').hide();
$('select').show();});
$('ul.tip li').click(function(){
$('.tip_popup').hide();
$('select').hide();
var popup=$('.tip_popup.'+$(this).attr('class'));
var offset=$(this).offset();
var pOffset=$(this).parent().offset();
var x=parseInt(offset.left-480);
var y=parseInt(offset.top-120);
popup.css('left',x+'px');
popup.css('top',y+'px');
popup.show();});
$('#switch_tab ul li').each(function(index){
$(this).hover(function(){
$('#switch_page div').css('display','none');
$('#switch_page div:eq('+index+')').css('display',!jQuery.support.hrefNormalized?'block':'inherit');
$(this).parent('ul').find('li').removeClass('on');
$(this).addClass('on');});});
$('#recent_sold_items').scrollBar();
var zooms=$('.picture_box a');
if(zooms.length>0){
var zoom=$('.picture_box a')[0];
zoom.related=$('.picture_box a img')[0];
zoom.textlink=$('.picture_box center a')[0];
$('.picture_box li').each(function(){
$(this).click(function(){
$('.picture_box li.current').removeClass('current');
$(this).addClass('current');
zoom.href=this.getAttribute('href');
zoom.related.src=$(this).attr('big');
if('undefined'!=typeof(zoom.textlink))zoom.textlink.href=this.getAttribute('href');});});}});
var parent;
function changePage(obj,items,index){
obj=$(obj,parent);
obj.hide();
obj.empty();
$('#c_p').text(index);
index--;
var n=items[index].length;
for(var i=0;i<n;i++){
var item=items[index][i];
if(''==item['6'])
var itemString='<li><a href="'+item[2]+'" title="'+item[1]+'"><img src="'+item[3]+'" alt="'+item[1]+'" title="'+item[1]+'"/><span>'+item[0]+'</span></a><a href="'+item[2]+'"><em>'+item[4]+'</em></a></li>';
else
var itemString='<li><a href="'+item[2]+'" title="'+item[1]+'"><img src="'+item[3]+'" alt="'+item[1]+'" title="'+item[1]+'"/><span>'+item[0]+'</span></a><a href="'+item[2]+'"><em>'+item[4]+'</em></a><a href="'+item[7]+'"><em>'+item[6]+'</em></a></li>';
if('undefined'!==typeof(productId)){
if(''==item['6'])
var itemString='<li><a href="'+item[2]+'" title="'+item[1]+'"'+((item[8]==productModel)?' class="current"':'')+'><img src="'+item[3]+'" alt="'+item[1]+'" title="'+item[1]+'"/><span>'+item[0]+'</span></a><a href="'+item[2]+'"><em>'+item[4]+'</em></a></li>';
else
var itemString='<li><a href="'+item[2]+'" title="'+item[1]+'"'+((item[8]==productModel)?' class="current"':'')+'><img src="'+item[3]+'" alt="'+item[1]+'" title="'+item[1]+'"/><span>'+item[0]+'</span></a><a href="'+item[2]+'"><em>'+item[4]+'</em></a><a href="'+item[7]+'"><em>'+item[6]+'</em></a></li>';}
obj.append(itemString);}
obj.fadeIn();}
function checkForm(){
var error=0;
var error_message="";
var review=document.product_reviews_write.review.value;
if(review.length<5){
error_message=error_message+"The 'Review Text' must have at least 5 characters.";
error=1;}
if(error==1){
alert(error_message);
return false;}else{
return true;}}

