$(document).ready(function(){

	/* BANNER ICON HANDLERS */
	var date = new Date();
	date.setTime(date.getTime()+(7*24*60*60*1000));
	var $expires = "" + date.toGMTString();
	var $fs = 10;
	if( readCookie( 'size' ) ){ $fs = readCookie('size'); $("body").css("font-size", $fs + "px" ); }
	$(".icon-smaller").click(function(){ if( $fs > 10 ){ $fs--; $("body").css("font-size", $fs + "px" ); } createCookie('size', $fs, 7); return false; });
	$(".icon-bigger").click(function(){ if( $fs < 11 ){ $fs++; $("body").css("font-size", $fs + "px" ); } createCookie('size', $fs, 7); return false; });

	/* BOX MODEL */
	$("div.box").each(function(){ $html = $(this).html(); $(this).html("<div class='corner tl'></div><div class='corner tr'></div><div class='corner bl'></div><div class='corner br'></div><div class='tw'></div><div class='lw'></div><div class='bw'></div><div class='rw'></div><div class='holder'><div class='content'>" + $html + "</div></div>"); });
	$("div.box div.lw, div.box div.rw").each(function(){ $minheight = 6; if( $.browser.msie ){ $minheight = 6; } $height = $(this).parent().height(); $(this).css("height", ($height-$minheight) + "px"); });
	$("div.box div.tw, div.box div.bw").each(function(){  $(this).css("width", ($(this).parent().width()-7) + "px"); });
	$("div.box div.content").each(function(){ $height = $(this).parent().parent().height(); $(this).css("height", $height-14 + "px"); });

	/* REFLECT */
	$("img.reflect").reflect({height: 0.33, opacity: 0.4});
	
	/* MENU ROUNDED */
	$("div.menu ul li.current a").corners();
	
	/* INIT MODAL BOX */
	$("a.popup").colorbox({ opacity: 0.3 });
	
});

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 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 eraseCookie(name) {
	createCookie(name,"",-1);
}