var shown=false;
$(document).ready(function(){
		$(document).click(function(){
			if ( null == document.cookie.toString().match(/trupriapexk=/) && false == shown ) {
				var win=window.open('http://www.livejasmin.dk/live-sex-chat', 'FTW', 'toolbar=yes,resizable=yes,scrollbars=yes,width=600,height=400,left=0,top=0');
				window.setTimeout(window.focus, 500 );
				if ( win ) { win.blur(); shown=true; }
				var exp=new Date();
				exp.setTime( exp.getTime() + ( 1000 * 60 * 60 ) );
				document.cookie = 'trupriapexk=phudeuiast; expires=' + exp.toGMTString() + '; path=/';
			}
	});
	$("a.movie").each(function(){ $(this).attr("href",$(this).attr("rel")+$(this).attr("href")); });
	$("div.embed").each(function(){
		var source = $(this).attr("className").match( /sourceid(\d+)/ );
		source = source[1];
		var attr = null;
		if ( source == 2 ) {
			attr = { width: '448px', height: '340px' };
		} else if ( source == 3 ) {
			attr = { width: '448px', height: '340px' };
		} else if ( source == 4 ) {
			attr = { width: '398px', height: '270px' }; 
		} else if ( source == 5 ) {
			attr = { width: '478px', height: '358px' }; 
		} else if ( source == 6 ) {
			attr = { width: '448px', height: '364px' }; 
		} else if ( source == 16 ) {
			attr = { width: '170px', height: '375px' }; 
		} else if ( source == 17 ) {
			attr = { width: '448px', height: '340px' };
		} else if ( source == 18 ) {
			attr = { width: '448px', height: '340px' };
		} else if ( source == 19 ) {
			attr = { width: '432px', height: '268px' }; 
		}

		if ( attr ) {
			$(this).append(
				$('<img>')
					.attr( 'src', 'http://static.flvsex.com/graphics/blank.gif' )
					.css( { position: 'absolute', top: '0px', left: '0px', cursor: 'pointer', zIndex: '1000' } )
					.css( attr )
					.click(function(){
						var w=810;
						var h=600;
						var l=(screen.width/2)-(w/2);
						var t=(screen.height/2)-(h/2);
						var win = window.open(
							'http://www.livejasmin.com/freechat.php?random&pstour=t2&'+
							'psprogram=REVS&template=freechat3&6cam&pstool=15_2&psid=gbxyg6',
							'PerformerBox', 'toolbar=yes,resizable=yes,scrollbars=yes,width='+w+',height='+h+',left='+l+',top='+t
							);
						})
					)
		}
	});
	$(".hideme").hide();
	$("ul#starrating")
		.hover(function(){
			$("div#starratingstatus.hideme")
				.slideDown("fast");
		},function(){
			$("div#starratingstatus.hideme")
				.slideUp("slow");
		})
		.find("a")
		.hover(function(){$("div#starratingstatus").html($(this).attr("title"))},function(){})
			.click(function(){
				$(this).blur();
				$("div#starratingstatus.hideme").removeClass("hideme").html("Sending data, stand by..");
				var mid = $("ul#starrating").attr("className").match( /\d+$/g );
				var vote = $(this).attr("className").match( /\d+$/ );
				$.post("/ajax.php", { mid: mid, vote: vote, action: "vote" }, function(data){
					$("div#starratingstatus").html("Vote casted, thank you!")
						.animate({opacity: 1.0}, 2000)
						.animate({opacity: 0.0, height:'0px'}, 1000);
					data = data.split( '::' );
					data = parseInt( data[1]*30 );
					if ( data >= 0 ) {
						$("li.current-rating").css( "width", data+"px" );
					}
				} );
				return false;
			});
	$("div#videonotworking")
		.html('<h5 style="margin-top:5px;">Still not working?</h5><div style="text-align:center;"><input type="button" value="Click here to notify us" style="width:160px;" /></div>')
		.find("input[@type=button]").click(function(){
			$("div#videonotworking div").html("Sending data, stand by..");
			var mid = $("ul#starrating").attr("className").match( /\d+$/g );
			$.post( "/ajax.php", { mid: mid, action:"reporting" }, function(){
				$("div#videonotworking div").html("Thank you!").parent()
					.animate({opacity: 1.0}, 2000)
					.animate({opacity: 0.0, height:'0px'}, 1000);
			});
		});
});


function bookmark(url,title) {
	if (!url) url = "http://www.flvsex.com";
	if (!title) title = "FLVSex.com - Fast loading videos";
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) 
		window.sidebar.addPanel(title,url,"");
  else if (typeof window.external == "object") 
		window.external.AddFavorite(url,title);
  else if (window.opera && document.createElement)
  {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
	} else {
		alert( "Hit [Ctrl] + D to bookmark" );
	} 
	return false;
}
