DEBUG = false;
//function debug(msg)
//{
//	if ($('#debug').length == 0) $('body').prepend('<div id="debug"></div>');
//	$('#debug').append("<br />" + msg);
//}
// Framebreaker
if(parent.location != self.location) { 
    parent.location=self.location; 
} 
if(self!=top) { 
    url=self.location.href; 
    if(document.images) { 
        top.location.replace(url); 
    } else { 
        top.location.href=url; 
    } 
} else { self.focus(); }


// Some nice short cookie functions
// http://www.quirksmode.org/js/cookies.html
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);
}


// POP Function
function NewWindow(mypage,myname,w,h,pos,infocus)
{
	var newwindow = null;
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
newwindow=window.open(mypage,myname,settings);
newwindow.blur();
self.focus();
return newwindow;
}

function pop(purl,pw,ph)
{
    if (purl == null || purl == '') purl = 'http://7wins.eu/';
    if (pw == null) pw = 468;
    if (ph == null) ph = 80;
        
	if (readCookie('popexecuted') != '-') {
		pwin = NewWindow(purl, pw, ph, 'center', 'back');
        window.focus();
		if (pwin != null) {
			createCookie('popexecuted','y',1);			
			$(document).each(function(){$(this).unbind("click", pop);})
			return true;
		}
	}
}

function preparePopClicks()
{
	if(readCookie('popexecuted')!='-')
		$(document).each(function(){$(this).bind("click", pop);});
}

$(document).ready(function(){   
        //$(preparePopClicks());
        $("#categorydir").accordion({animated:false, header:"h3"});
        $("#categorydir").accordion("activate", "#currentcat");
        $("#trendgraph > ul").tabs();
        $('a[rel*="external"]').click( function() {
            window.open( $(this).attr('href') );
            return false;
            });
})
