

$().ready(function(){
   $(function() {
		$('.exampleButton').mouseover(function() {
			var offset = $(this).offset();
			var height = $(this).next().height();
			var tops = offset.top - height - 30;
			var lefts = offset.left - 70;
		  $(this).next().css({top:tops+'px', left:lefts+'px'}).fadeIn('fast');
		});
		$('.exampleButton').mouseout(function() {
		  $(this).next().fadeOut('fast');
		});
		$("input").focus(function() {
                $(this).addClass("focus");
        });
		$("input").blur(function() {
                $(this).removeClass("focus")
        });
		$("#getback, #getback2").click(function() {
			var val = $(this).val();
			if(val == 1)
				$("#emailDiv").slideDown();
			else
				$("#emailDiv").slideUp();
		});
		
		if($("#topDivD h1")) {
			var chars = $("#topDivD h1").html();
			if(chars) {
				if(chars.length > 40) $("#topDivD h1").css("margin-left", "50px");
			}
		}
		if($("#timezone")) setTimeZone();	
   })
});

function setTimeZone() {
	//if($("#timezone").val() == "x") {
		var rightNow = new Date();
		var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
		var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
		var temp = date1.toGMTString();
		var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")));
		var temp = date2.toGMTString();
		var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")));
		var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
		//return hoursDiffStdTime;
		//var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
		ajaxRunning = true;
		var cct = $.cookie('ci_csrf_token');
		$.post("/common/autoselectTimezone", {offset: ""+hoursDiffStdTime+"", 'ci_csrf_token': cct}, function(data){
			ajaxRunning = false;
			$("#timezone").val(data);
		});
	//}
}

function setHomepage(){
 if (document.all)    {
        document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.favsync.com');

    }
    else if (window.sidebar)    {
		if(window.netscape)    {
         try   {  
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
         }  
         catch(e)          {  
            alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");  
         }
    } 
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','http://www.favsync.com');
 }
}
