// JavaScript Document

var $j = jQuery.noConflict();

$j(document).ready(function(){
						
    //alert("Testing 1...2...3");
	
	//disables right mouse button
	$j(document).bind("contextmenu",function(e){  
         return false;  
     });
	 
	//Remove "Title" attributes from input and text area fields on mouseover but add back on mouse out
	//$j('input').bind('mouseover', function (){ alert("Hello"); });
	//$j('input').bind('mouseout', function (){ alert("Goodbye"); });
	$j('input,textarea').hover(function() {
    	titleMem = this.title;
    	this.title = '';
	},
	function() {
    	this.title = titleMem;
	});
	
	//Performs some validation to make sure that the Update button
	//has been clicked after a discount code was inputted
	$j('input.make_purchase').click(function(){
			var coupon_string = $j('input#coupon_num').val();
			var coupon_value = $j('span.my_coupon_discount').text();
			if(coupon_string&&(coupon_value=='¥0')){alert("あれ？ディスカウントコードを入力したのに再計算ボタンを押していませんね。\n\nでも、大丈夫。OKボタンを押してもらえれば合計金額を再計算しますよ！"); $j('form.update_now').submit(); return false;};
		}
	);
	
	//Various formatting and translation hacks
	$j('.totalhead').filter('span:contains("Shipping:")').text('Postage');
	$j('.totalhead').filter('span:contains("Total:")').text('Total (incl.tax)');
	$j('label:contains("Local Shipping")').text('配送');
	$j('label:contains("Shipping Address same as Billing Address?")').text('送付先はご連絡先と同じですか？');
	$j('td:contains("Enter your coupon number :")').text('ディスカウントコードまたギフトコード');
	$j('td:contains("Please choose a country below to calculate your shipping costs")').css("display","none");
	$j('td:contains("送料を計算するため国を選択します")').css("display","none");
	$j('p:contains("TXT_WPSC_REVIEW_YOUR_ORDER")').css("display","none");
	$j('td:contains("State:")').css("display","none");
	$j('td:contains("Country:")').css("visibility","hidden");
	$j('td:contains("Country * :")').css("visibility","hidden");
	$j('input[value="Calculate"]').css("display","none");
	$j('p.validation-error').css("margin-top","3px");
	$j('a:contains("[View with PicLens]")').css("display","none");
	$j('form#mc_signup_form legend:contains("Newsletter")').text('ニュースレター');
	$j('li.aktt_more_updates a:contains("More updates...")').text('もっと読む...');
	$j('#mc-indicates-required').text('* = 必須');
	
			
	//gets all image links with ref to the "product_images" directory
	$j("a[href*='product_images/']").each(function() {
			//gets the existing href attribute		
			var linkhref = $j(this).attr("href");
			//writes the new link reference to the anchor link element
			$j(this).attr("href", linkhref.replace(".png", "a.png"));
			newfile = $j(this).attr("href").split('/').pop();
			$j(this).attr("href", ("http://www.thestickerfamily.jp/wp-content/uploads/" + newfile));
	 });//ends "each" function
	 
	//helps out the validation script above by adding the necessary classes to the checkout
	$j('#wpsc_shopping_cart_container table.productcart:eq(1) span.pricedisplay:eq(0)').addClass('my_coupon_discount');
	$j('input#coupon_num').parent().addClass('update_now');
	
	$j('img.special-promotion').hover(function(){$j(this).css("cursor","pointer")});
	
    //special promotion button message
	//$j('img.special-promotion').hover(function(){$j(this).css("cursor","pointer")}).click(function ()
	//{ alert("おめでとうございます！\n\n1500円分無料チケットが当たりました！\n\nウェブサイトを御覧頂き、お好きなキャラクターを選んで下さい。\nチェックアウト時、下記ディスカウントコードを入力すればOKです。\n\n\tDISCOUNT1500\n\n 差額をお支払い頂ければ、1500円分以上買えますよ。  "); });
	
	
	//Browser sniffing to fix non-IE CSS bugs
	//var userAgent = navigator.userAgent.toLowerCase();
    //$j.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
    // Is this a version of IE?
    //if($j.browser.msie){
        //$j('body').addClass('browserIE');
        
        // Add the version number
        //$j('body').addClass('browserIE' + $j.browser.version.substring(0,1));
		//var usingBrowser = $j.browser.version.substring(0,1); 
		//alert("IE "+usingBrowser);
		
    //}
    
    
    // Is this a version of Chrome?
    //if($j.browser.chrome){
    
        //$j('body').addClass('browserChrome');
        
        //Add the version number
        //userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
        //userAgent = userAgent.substring(0,1);
        //$j('body').addClass('browserChrome' + userAgent);
		        
        // If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
        //$j.browser.safari = false;
		//var usingBrowser = userAgent; 
		//alert("Chrome "+usingBrowser);
    //}
    
    // Is this a version of Safari?
    //if($j.browser.safari){
        //$j('body').addClass('browserSafari');
        
        // Add the version number
        //userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
        //userAgent = userAgent.substring(0,1);
        //$j('body').addClass('browserSafari' + userAgent);
		//var usingBrowser = userAgent; 
		//alert("Safari "+usingBrowser);
    //}
    
    // Is this a version of Mozilla?
    //if($j.browser.mozilla){
        
        //Is it Firefox?
        //if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1){
           // $j('body').addClass('browserFirefox');
            
            // Add the version number
            //userAgent = userAgent.substring(userAgent.indexOf('firefox/') +8);
            //userAgent = userAgent.substring(0,1);
            //$j('body').addClass('browserFirefox' + userAgent);
			//var usingBrowser = userAgent; 
		    //alert("FireFox "+usingBrowser);
        //}
        // If not then it must be another Mozilla
        //else{
            //$j('body').addClass('browserMozilla');
        //}
    //}
    
    // Is this a version of Opera?
    //if($j.browser.opera){
        //$j('body').addClass('browserOpera');
		
		//alert("Opera");
    //}

    //Adds a promotional gallery to the DOM using jQuery Cycle Plugin
	//be sure to add <div id="cycleplugin" class="pics" style="float:left; clear:left; position:relative;">.</div><div id="cyclesidebanner">.</div>
	//to the content page where you want the cycle gallery to appear.
	//Also relies on pluginstyle.css file and adding some option parameters to the document.ready script in the header.php file
	//Dont forget the placeholder between the Div tags
	
$j('#cycleplugin').empty();

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/boys/jb07-baseball-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jb07.jpg" width="260" height="175" class="nojavascript"/></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/older-girls/jog13-casual-older-girl/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jog13.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/older-boys/job13-baseball-older-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_job13.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/girls/jg07-gamer-girl/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jg07.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/baby-boy/jbb01-baby-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jbb01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/pets/jc01-sleepy-cat/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jc01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/pets/jd01-frisbee-dog/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jd01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/pets/jd02-plain-dog/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jd02.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/pets/jd03-bone-dog/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jd03.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/fathers/jf01-plain-dad/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jf01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/mothers/jm01-shopping-mom/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jm01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/mothers/jm03-simple-mom/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jm03.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/older-girls/jog03-ipod-older-girl/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jog03.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/young-girls/jyg01-doll-younger-girl/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jyg01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/boys/jb01-soccer-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jb01.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/boys/jb03-skateboard-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jb03.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/fathers/jf03-longboard-dad/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jf03.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/fathers/jf08-soccer-dad/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jf08.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/fathers/jf09-diy-dad/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jf09.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/girls/jg03-cute-girl/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jg03.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/mothers/jm09-surfer-mom/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jm09.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/mothers/jm12-charinko-mom/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jm12.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/young-boys/jyb02-toys-younger-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jyb02.jpg" width="260" height="175" /></a>');

$j('#cycleplugin').append('<a href="http://www.thestickerfamily.jp/products-page/young-boys/jyb03-superhero-younger-boy/"><img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/gallery_jyb03.jpg" width="260" height="175" /></a>');


    $j('#cyclesidebanner').empty();

    $j('#cyclesidebanner').append('<img src="http://www.thestickerfamily.jp/wp-content/themes/ecomm/plugingallery/cyclesidebanner.jpg" />');
});



	

