﻿$(document).ready(function() {    
    rc = $('#rpList');
    rch = 964;
    containerWrp = 218;
    $('.rareprints .dragBar').draggable({
        axis: 'x',
        containment: 'parent',
        drag: function(event, ui) {
            var rpmove = rch - containerWrp;
            var rppos = $('.dragBar').css("left").replace("px", "");
            rc.css('left', -rppos / containerWrp * rpmove + "px")
        }
    });
    $('.switchHero').live("click", function() {
        var switchSrc = $(this).attr("name");
        var switchContent = $(this).attr("href");
        $('#galleryHero').attr("src", switchSrc);
        /*var stuff = $(switchContent).html();
        $('#contentTab').html(stuff);*/
        Cufon.replace('#contentTab h3', { fontFamily: 'QuicksandBook' });
        $('.switchHero img').css("border-color", "transparent");
        $('.switchHero img').removeClass("selected");
        $(this).children('img').addClass("selected");
        $(this).children('img').css("border-color", "#c0c0c0");
        $("#ulTabs li").children().removeClass("active");
        Cufon.replace('#ulTabs li', { fontFamily: 'Quicksand Bold' });
        //
        var byline_author = $(this).attr('author') == null ? $("h3:first", switchContent).text() : $(this).attr('author');

        $("#rareprints_byline").fadeOut('1000', function() {
            if (byline_author != "") {
                $("#byline_author").text(byline_author);
                Cufon.replace('#byline_author', { fontFamily: 'QuicksandBook' });


                $("#rareprints_byline").fadeIn('1000');
            }
        });   
        //       
        return false;
    });
    $('.switchHero img').hover(function() {
        $(this).css("border-color", "#c0c0c0");
    }, function() {
        if ($(this).hasClass("selected")) {

        } else {
            $(this).css("border-color", "transparent");
        }
    }); 
});
function clickTab(no) {
    var i = 0;
    /*for (i = 1; i <= 2; i++) {
        if (document.getElementById('tab' + i) != null) {
            alert("found");
            document.getElementById('tab' + i).className = "";
        }
    }*/
    $("#ulTabs li").children().removeClass("active");
    $("#ulTabs li a:eq(" + "tab" + no + ")").addClass("active");
    //alert($("#ulTabs li a:eq(" + "tab" + no + ")").attr('class'));
    //document.getElementById('tab' + no).className = "active";
    Cufon.replace('#ulTabs li', { fontFamily: 'Quicksand Bold'});
    document.getElementById('contentTab').innerHTML = document.getElementById('contentTab' + no).innerHTML;
    document.getElementById('hero').innerHTML = '<img id="galleryHero" src="/_repository/_resources/_cutwater/_rareprints/images/rareprints_hero1.jpg" alt="Rare Prints" />'
    $('.switchHero img').removeClass("selected").css("border-color", "transparent");
    Cufon.replace('#contentTab h3', { fontFamily: 'QuicksandBook' });
}

function getLocalUrl(urlString) {
    var domain = window.location.href.replace('http://', '');
    var nation = domain.split('/')[1];
    var location = "/" + nation + urlString;
    //alert(location);
    window.location = location;
}
