/*
Content-Type: text/javascript
*/

$(function () {
    var base = $("#html-base").attr("href");
    //   if (base == "") base = "/";
    var siteUrl = $("#homepage").text();
    if (!siteUrl) siteUrl = window.location.protocol + "//" + window.location.host + "/";
    var b = $("#makeHome");
    var platform = navigator.platform.toLowerCase();
    var path;
    if (/win/.test(platform))
        path = "win";
    else if (/mac/.test(platform))
        path = "mac";
    else
        path = "unknown";

    if (path != "unknown") {
        if (/chrome/.test(navigator.userAgent.toLowerCase()))
            path += "-chrome";
        else if ($.browser.mozilla)
            path +=  "-firefox";
        else if ($.browser.opera)
            path +=  "-opera";
        else if ($.browser.safari)
            path +=  "-safari";
        else if ($.browser.msie)
            path +=  "-msie";
        else
            path = "unknown";
    }
    var url = base + "skin/makehome/" + path + ".html";
    if ($.browser.msie) {
        b.click(function(){
		   this.style.behavior='url(#default#homepage)';
		   this.setHomePage(siteUrl);
                   return false;
		});   
	}
	else {
		b.click(function(){
			var d = $("#makeHomeText");
			d.find("div.text").load(url, function(){
				$("#siteurl").text(siteUrl);
				d.show();
				d.find("div.box").css({
					"z-index": "100"
				}).animate({
					left: "-550px",
					width: "400px",
					height: "0px",
					padding: "10px"
				}, 500).animate({
					left: "-550px",
					height: "250px"
				}, 1000);
			});
			d.find("button").click(function(){
				d.find("div.box").animate({
					height: "0px"
				}, 200).animate({
					left: "0px",
					top: "0px",
					width: "0px",
					padding: "0px"
				}, 500, null, function(){
					d.hide();
				})
			});
			return false;
		});
	}	
});
