// JavaScript Document

$(document).ready(function() {

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

});
// JavaScript Document

// ------- For Tab Content in TOUR page ----- //
$(document).ready(function() {
    $("a.scrollTo").click(function() { $.scrollTo($(this).attr("href"), 1000); return false; });
    var sel = readCookie("lan");
    if (sel != null && sel != undefined && sel != "") {
        if (sel == "English") {
            document.getElementById("websites4").selectedIndex = 0;
        }
        if (sel == "Swedish") {
            document.getElementById("websites4").selectedIndex = 1;
        }
        else {
            document.getElementById("websites4").selectedIndex = 2;
        }
    }
    else {
        var defaultlan = "Norwegian";
        if (defaultlan == "English") {
            document.getElementById("websites4").selectedIndex = 0;
        }
        if (sel == "Swedish") {
            document.getElementById("websites4").selectedIndex = 1;
        }
        else {
            document.getElementById("websites4").selectedIndex = 2;
        }
    }
});
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";

}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function eraseCookie(name) {
    createCookie(name, "", -1);
}

function ChangeStatus(id) {
    var obj = $j("#status-text-" + id);
    var action = $j("#status-" + id).attr('value');
    var seltext = $j("#status-" + id + " option:selected").text();
    obj.html('');
    $j("#status-" + id).css('display', 'none');
    obj.addClass("fade");
    $j.post("listings-quickupdate.aspx", { type: 'status', action: action, id: id }, function(data) {
        obj.html(seltext);
        $j("#status-" + id).show();
        obj.removeClass("fade");
    });
}

function ChangeLanguage(sel) {
    var newlanguage = sel.options[sel.selectedIndex].value;
    var oldlanguage = readCookie("lan");
    if (oldlanguage == null || oldlanguage == undefined || oldlanguage == "") {
        if (newlanguage != "Norwegian") {
            eraseCookie("lan");
            createCookie("lan", newlanguage, 100);
            window.location.href = window.location.href;
        }
    }
    else {
        if (oldlanguage != newlanguage) {
            eraseCookie("lan");
            createCookie("lan", newlanguage, 100);
            window.location.href = window.location.href;
        }
    }
}




