/*	
 *	jQuery Object for Script widget
 *  date: Tue Apr 28 14:06:34 IST 2009
 *  author: Patryk Kasperski
*/

var FulltiltForums = {
	init:function() {
		// apply to all png images 
		$('div.footer-cms a.logo').ifixpng();
		$('div.bw09-menu-section').ifixpng();
	}
}
$(function(){ FulltiltForums.init(); });

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

var key_from_url = $.getUrlVar('key');
var key_from_cookie = $.cookie('key');
var default_ftp_cookie = 'MDAwMDAwMDAwMDAwQTlBMTAwMDAwMDAwMDAwMDAwMDA-';
var default_forum_cookie = 'MDAwMDAwMDAwMDAyMjZEQTAwMDAwMDAwMDAwMDAzRTg-';
var cookie_options = { expires:365, path:'/', domain:'.fulltiltpoker.com', secure:false };

if (key_from_url!=undefined) { // if there's key in the url, set it
    $.cookie('key',key_from_url,cookie_options); 
} else {
    if (key_from_cookie!=undefined) { // has the cookie
        if (key_from_cookie==default_ftp_cookie) {
            $.cookie('key',default_forum_cookie,cookie_options);
        }
    } else {
        $.cookie('key',default_forum_cookie,cookie_options);
    }    
} 
