jQuery(document).ready(function(){
    $("div#sidebar ul#info-panel li#info-area ul").css("display", "block");
    $("div#sidebar ul#info-panel li#info-area").addClass( "selected");
    $('#showme').css("display", 'none');

jQuery("div#menu ul.sub li").hover(
		function(){jQuery("ul", this).css("display", "block");},
		function(){jQuery("ul", this).css("display", "none");}
	);
 jQuery("div#sidebar ul#info-panel li#info-area").click(function(){
     $("div#sidebar ul#info-panel li ul").css("display", "none");
     $("div#sidebar ul#info-panel li#info-area ul").css("display", "block");
     $("div#sidebar ul#info-panel li").removeClass( "selected");
     $("div#sidebar ul#info-panel li#info-area").addClass( "selected");
 }
	);
jQuery("div#sidebar ul#info-panel li#facebook-advanced").click(function(){
    $("div#sidebar ul#info-panel li ul").css("display", "none");
    $("div#sidebar ul#info-panel li#facebook-advanced ul").css("display", "block");
    $("div#sidebar ul#info-panel li").removeClass( "selected");
    $("div#sidebar ul#info-panel li#facebook-advanced").addClass( "selected");
}
	);
jQuery("div#sidebar ul#info-panel li#google-advanced").click(function(){
    $("div#sidebar ul#info-panel li ul").css("display", "none");
    $("div#sidebar ul#info-panel li#google-advanced ul").css("display", "block");
    $("div#sidebar ul#info-panel li").removeClass( "selected");
    $("div#sidebar ul#info-panel li#google-advanced").addClass( "selected");
//}
}
	);
 jQuery("div#sidebar ul#info-panel li#twitter-advanced").click(function(){
    $("div#sidebar ul#info-panel li ul").css("display", "none");
    $("div#sidebar ul#info-panel li#twitter-advanced ul").css("display", "block");
    $("div#sidebar ul#info-panel li").removeClass( "selected");
    $("div#sidebar ul#info-panel li#twitter-advanced").addClass( "selected");
//}
}
	);
jQuery("div#sidebar ul#info-panel li#help").click(function(){
    $("div#sidebar ul#info-panel li ul").css("display", "none");
    $("div#sidebar ul#info-panel li#help ul").css("display", "block");
    $("div#sidebar ul#info-panel li").removeClass( "selected");
    $("div#sidebar ul#info-panel li#help").addClass( "selected");
}
	);

jQuery("div#sidebar ul#info-panel li#site").click(function(){
    $("div#sidebar ul#info-panel li ul").css("display", "none");
    $("div#sidebar ul#info-panel li#site ul").css("display", "block");
    $("div#sidebar ul#info-panel li").removeClass( "selected");
    $("div#sidebar ul#info-panel li#site").addClass( "selected");
}

	);

jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);

$('#clickme').click(function() {
          $('#sidebar').css("width", '20px');
         // $('#sidebar').css("display", 'none');
         $('#info-area').css("display", 'none');
         $('#social-advanced').css("display", 'none');
         $('#help').css("display", 'none');
          $('#site').css("display", 'none');
          $('#clickme').css("display", 'none');
          $('#showme').css("display", 'inline');
          $('#facebook-advanced').css("display", 'none');
          $('#google-advanced').css("display", 'none');
          $('#twitter-advanced').css("display", 'none');
          $('#small-big').addClass("hidemenu");

});

$('#showme').click(function() {
          $('#sidebar').css("width", '265px');
        //  $('#sidebar').css("display", 'table-cell');
          $('#clickme').css("display", 'block');
          $('#showme').css("display", 'none');
         $('#info-area').css("display", 'block');
         $('#help').css("display", 'block');
         $('#site').css("display", 'block');
         $('#social-advanced').css("display", 'inline');
         $('#facebook-advanced').css("display", 'inline');
         $('#google-advanced').css("display", 'inline');
         $('#twitter-advanced').css("display", 'inline');
         $('#small-big').removeClass("hidemenu");
});


function resizeFrame()
{
    var h = $(window).height();
    var w = $(window).width();
    $("#wall").css('height',(h - 180));
}



});

function popup(url)
{
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';

 newwin=window.open(url,'windowname4', params);
 if (window.focus) {newwin.focus()}
 return false;
}

function make_code_nice(codeReplace){
       var html = codeReplace.replace(/&quot;/g, '"'); // for IE
        html = html.replace(/&#38;/g, '&'); // for firefox
    return html;
}

function start_new_feed(feed,refer){
    cooliris.embed.setFeedURL(feed);
    alter (refer);
}

function start_new_item(item){
    cooliris.embed.selectItemByGUID(item);
    onItemSelected(item);
}

function check_data(dataKey,heading, method){
    switch (method){
        case "titleOfFeed":
             html = "<h1  class=\""+method+"\"><small>"+heading+"</small> "+dataKey+"</h1>";
             return html;
        break;
        case "uk":
        case "uk_download":
        case "uk_boxset":
        case "uk_bluray":
              html = "<div id=\""+method+"\"><h4>"+heading+"</h4><iframe src=\"http://rcm-uk.amazon.co.uk/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=phatreaction-21&o=2&p=8&l=as1&m=amazon&f=ifr&md=0M5A6TN3AXP2JHJBWT02&asins="+dataKey+"\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe></div>";
              return html;
        break;
        case "fr":
        case "fr_download":
        case "fr_boxset":
        case "fr_bluray":
              html = "<div id=\""+method+"\"><h4>"+heading+"</h4><iframe src=\"http://rcm-fr.amazon.fr/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=phatreactionv-21&o=8&p=8&l=as1&m=amazon&f=ifr&md=0V7HTNAW9BB7KPZWWWG2&asins="+dataKey+"\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe></div>";
              return html;
        break;
        case "usa":
        case "usa_download":
        case "usa_boxset":
        case "usa_bluray":
              html = "<div id=\""+method+"\"><h4>"+heading+"</h4><iframe src=\"http://rcm.amazon.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=wwwphatreacti-20&o=1&p=8&l=as1&m=amazon&f=ifr&md=10FE9736YVPPT7A0FBG2&asins="+dataKey+"\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe></div>";
              return html;
        break;
        case "de":
        case "de_download":
        case "de_boxset":
        case "de_bluray":
              html = "<div id=\""+method+"\"><h4>"+heading+"</h4><iframe src=\"http://rcm-de.amazon.de/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=phatreactio0b-21&o=3&p=8&l=as1&m=amazon&f=ifr&md=1M6ABJKN5YT3337HVA02&asins="+dataKey+"\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe></div>";
              return html;
        break;
        case "ca":
        case "ca_download":
        case "ca_boxset":
        case "ca_bluray":
              html = "<div id=\""+method+"\"><h4>"+heading+"</h4><iframe src=\"http://rcm-ca.amazon.ca/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=phatreactio00-20&o=15&p=8&l=as1&m=amazon&f=ifr&md=07AN74PQXHR1PJRCZ582&asins="+dataKey+"\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe></div>";
              return html;
        break;
        default:
         html = "<tr><th class=\""+method+"\">"+heading+"</th>";
         html = html+"<td class=\""+method+"\">"+dataKey+"</td></tr>";
         return html;
       break;
    }
}
var cooliris = {
    onEmbedInitialized : function() {
        cooliris.embed.setCallbacks({
            select: onItemSelected
        });
    }
};

function changeTitle(title) { document.title = title; }

function choose_shop(country){
     switch (country){
        case "netherlands":
             return 'uk';
        break;
        default:
            return 'uk';
        break;
     }
}
function onItemSelected(item) {
    if (item == null) {
        // nothing selected...place your code here
    } else {
        var t = document.getElementById("descriptionField");
        changeTitle(item.title);
        // html = make_code_nice(item.description);
        var html = '<h3>Now Playing</h3><table class=\"details\">';
       if(typeof item.data.titleOfTrack == "string") {html =  html+check_data(item.data.titleOfTrack,"title of track", "titleOfTrack" );}
       if(typeof item.data.titleOfMovie == "string") {html =  html+check_data(item.data.titleOfMovie,"title of movie", "titleOfMovie" );}
       if(typeof item.data.director == "string") {html =  html+check_data(item.data.director,"Director", "director" );}
       if(typeof item.data.artist == "string") {html = html+check_data(item.data.artist,"Artist", "artist" );}
       if(typeof item.data.author == "string") {html = html+check_data(item.data.author,"Author", "author" );}
       if(typeof item.data.writer == "string") {html = html+check_data(item.data.writer,"Writer", "writer" );}
       if(typeof item.data.staring == "string") {html = html+check_data(item.data.staring,"Staring", "staring" );}
       if(typeof item.data.album == "string") {html = html+check_data(item.data.album,"Album", "album" );}
       html=html+'</table>';
       t.innerHTML = html;

       var j = document.getElementById("buying");
       html='';
       if(typeof item.data.uk == "string") {html = html+check_data(item.data.uk," ", "uk" );}
       if(typeof item.data.uk_download == "string") {html = html+check_data(item.data.uk_download," ", "uk_download" );}
       if(typeof item.data.uk_boxset == "string") {html = html+check_data(item.data.uk_boxset," ", "uk_boxset" );}
       if(typeof item.data.uk_bluray == "string") {html = html+check_data(item.data.uk_bluray," ", "uk_bluray" );}
       if(typeof item.data.fr == "string") {html = html+check_data(item.data.fr," ", "fr" );}
       if(typeof item.data.fr_download == "string") {html = html+check_data(item.data.fr_download," ", "fr_download" );}
       if(typeof item.data.fr_boxset == "string") {html = html+check_data(item.data.fr_boxset," ", "fr_boxset" );}
       if(typeof item.data.fr_bluray == "string") {html = html+check_data(item.data.fr_bluray," ", "fr_bluray" );}
       if(typeof item.data.de == "string") {html = html+check_data(item.data.de," ", "de" );}
       if(typeof item.data.de_download == "string") {html = html+check_data(item.data.de_download," ", "de_download" );}
       if(typeof item.data.de_boxset == "string") {html = html+check_data(item.data.de_boxset," ", "de_boxset" );}
       if(typeof item.data.de_bluray == "string") {html = html+check_data(item.data.de_bluray," ", "de_bluray" );}
       if(typeof item.data.usa == "string") {html = html+check_data(item.data.usa," ", "usa" );}
       if(typeof item.data.usa_boxset == "string") {html = html+check_data(item.data.usa_boxset," ", "usa_download" );}
       if(typeof item.data.usa_download == "string") {html = html+check_data(item.data.usa_download," ", "usa_boxset" );}
       if(typeof item.data.usa_bluray == "string") {html = html+check_data(item.data.usa_bluray," ", "usa_bluray" );}
       if(typeof item.data.ca == "string") {html = html+check_data(item.data.ca," ", "ca" );}
       if(typeof item.data.ca_download == "string") {html = html+check_data(item.data.ca_download," ", "ca_download" );}
       if(typeof item.data.ca_boxset == "string") {html = html+check_data(item.data.ca_boxset," ", "ca_boxset" );}
       if(typeof item.data.ca_bluray == "string") {html = html+check_data(item.data.ca_bluray," ", "ca_bluray" );}
       j.innerHTML = html;

    }
    }

