/* jquery
----------------------------------------------- */
$(document).ready(function() {

	//target_blank
	$('a[href^="http"]').not('[href^="http://www.mielizia.jp/"]').click(function() {
		window.open(this.href, '');
		return false;
	});
	$('a[href^="http"]').not('[href^="http://www.mielizia.jp/"]').addClass("exLink");
	
	//pdf
	$('a[href$=".pdf"]').click(function() {
		window.open(this.href, '');
		return false;
	});
	
	//link block
	$(".linkBlock li").click(function() {
		window.location = $(this).find("a").attr("href");
		return false;
	});

	//pageTop
	$("#pageTop a").click(function() {
		var targetOffset = $("#container").offset().top;
		$("html,body").animate({scrollTop: targetOffset}, 1000);
		return false;
	});
	
	//product thumbnail
    $(".thumbnail img").click( function() {
        var changeSrc = this.src;
        $("#target").fadeOut(
            "fast",
            function() {
                $(this).attr("src", changeSrc);
                $(this).fadeIn();
            }
        );
		$(this).addClass("selected");
    });

});


//tooltip
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});



/* form
----------------------------------------------- */
window.onload = function() {
    if ( document.getElementById("btn2") ) {  
        with(document) {  
            getElementById("btn2").disabled = true;  
            getElementById("btn2").setAttribute("src","/mielizia_contact/images/btn_check_off.gif");  
            getElementById("no").onclick = function() { bt_transrate(this,"btn2"); }  
            getElementById("yes").onclick = function() { bt_transrate(this,"btn2"); }  
        }  
        if ( document.getElementById("yes").checked ) {  
            bt_transrate(document.getElementById("yes"),"btn2");  
        }  
    }  
}  
  
function bt_transrate(obj,inp) {  
    var radioBT = obj.value;  
    var subBT = document.getElementById(inp);  
    if ( radioBT == "yes" ) {  
        with(document) {  
            subBT.disabled = false;  
            subBT.setAttribute("src","/mielizia_contact/images/btn_check.gif");  
        }  
        return true;  
    }  
    if ( radioBT == "no" ) {  
        with(document) {  
            subBT.disabled = true;  
            subBT.setAttribute("src","/mielizia_contact/images/btn_check_off.gif");  
        }  
        return true;  
    }  
}
