//*****************************************************************
// PNG Fixes
//*****************************************************************
$( document ).ready ( function() {
    $("#movie_skin").pngfix();
    $("#content_container").pngfix({sizingMethod: "scale"});
    $("#content").pngfix({sizingMethod: "scale"});
} );

//*****************************************************************
// Bookmark
//*****************************************************************
$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){
			$("a.jqbookmark").attr("rel","sidebar");
		} 
	}

	$("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});
});

//*****************************************************************
// Don't show bookmark link of IE 6
//*****************************************************************
$( document ).ready ( function() {
    jQuery.each(jQuery.browser, function(i, val) {
        if($.browser.msie && $.browser.version == "6.0"){
            $(".jqbookmark").remove();
        }
    });
});

//*****************************************************************
// URL encode
//*****************************************************************
function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
                                     
    var ret = str;
    
    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');
 
    return ret;
}

//*****************************************************************
// Show Chatwise chat box
//*****************************************************************
$( document ).ready ( function() {
    $("#chatlink").click(function () {
        $("#chatbox_container").toggle(300);
        return false;
    });
} );

//*****************************************************************
// Swap out the background image if less than 1024px wide
//*****************************************************************
$( document ).ready ( function() {
    if (GetWidth() <= 1024) {
        $("body").css('background-image','url(../images/layout/body_bg_sm.jpg)');
        $("#tabs ul").css('padding-top', '10px');
    }
} );


//*****************************************************************
// Get browser width
//*****************************************************************
function GetWidth()
  {
          var x = 0;
          if (self.innerHeight)
          {
                  x = self.innerWidth;
          }
          else if (document.documentElement && document.documentElement.clientHeight)
          {
                  x = document.documentElement.clientWidth;
          }
          else if (document.body)
          {
                  x = document.body.clientWidth;
          }
          return x;
  }

