var $Cookie = {
	set: function( name, value, o ) {
		if( typeof o == 'undefined' ) {
			o = {};
		}
		var expires = ( typeof o.expires != "undefined" ) ? o.expires : null;
		var path = ( typeof o.path != "undefined" ) ? o.path : null;
		var domain = ( typeof o.domain != "undefined" ) ? o.domain : null;
		var secure = ( typeof o.secure != "undefined" ) ? o.secure : false;
		document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
	}, 
	get: function (name) {
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen) {
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg) {
				return this._get_val(j);
			}
			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) {
				break;
			}
		}
		return 0;
	}, 
	_get_val: function (offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1)
		endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
	}
};

function under() {
	if( $Cookie.get( "under" ) == 0 ) {
		var url = '/under.php';
		var f = document.createElement( "div" );
		f.id = "exit_pop";
		document.body.insertBefore( f, document.body.firstChild ) ;
		if( navigator.userAgent.indexOf("MSIE") != -1 ) {
			var agent = navigator.userAgent;
			var version = agent.replace( /^.*MSIE ([0-9]{1}).*$/gi, '$1' );
			if( version >= 7 ) {
				var swf = "/js/exit.swf?link="+escape(url);
				$( "#exit_pop" ).html('<embed src="' + swf + '" autostart="true" width="1" height="1"></embed>');
			} else {
				$( "#exit_pop" ).html('<object id="iie" width="1" height="1" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"></object>');
				iie.launchURL( url );
			}
		} else {
			var swf = "/js/exit.swf?link="+escape(url);
			$( "#exit_pop" ).html( '<object width="1" height="1"><param name="movie" value="'+swf+'"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="'+swf+'" width="1" height="1" allowscriptaccess="always"></embed></object>' );
		}
		window.focus();
		$Cookie.set( "under", 1, { path: "/" } );
	}
}

$(document).ready(function() {
	$( "#webmaster" ).overlay({
		target: "#webmaster-form", 
		expose: "#000000", 
		onLoad: function() {
			$("#webmaster-form").html("<iframe src=\"/form.php\" width=\"" + $("#webmaster-form").width() + "\" height=\"" + $("#webmaster-form").height() + "\" frameborder=\"no\" scrolling=\"no\" allowtransparency=\"true\" marginwidth=\"0\" marginheight=\"0\"></iframe>");
		}
    });
	
	$( "#top-tags a" ).each( function() {
		$(this).css( { fontSize: ( Math.round( Math.random() * 10 ) + 10 ) + "px" } );
	} );
	$( "div.videos p b").css( 'color', 'red' );
	$( "div.scrollable").scrollable( {
		size: 1, 
		items: "div.items-scrollable", 
		item: 'div.item-scrollable', 
		clickable: false, 
		vertical: true,
		keyboard: false
	} ).circular().autoscroll({autoplay: true, interval: 5000});
	$("#image-player").css( { opacity: 0.4, visibility: 'visible' } );
	$("img.pgt")
		.css( "cursor", "pointer" )
		.click(function(){
			window.open( "http://tools.gigacu.com/feed.php?n="+$(this).attr("rel")+"&from=mes-pornos.com" );
		});
	$("a.click-player, a.video-out").click( function() {
		window.open( "http://tools.gigacu.com/feed.php?n=1&from=mes-pornos.com" );
		$("a.click-player, a.video-out").unbind( "click" );
		return false;
	} );
	});
