function runFlvPlayer(movie, target, width, height, preview, autostart) {
	width = width ? width : 350;
	height = height ? height : 300;
	
	var so = new SWFObject('/itvl.pl/media/jwplayer/player.swf','mpl',width,height,'9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','opaque');
	so.addVariable('autostart',autostart);
	so.addVariable('file',movie); // sciezka bezwzględna
	
	if(preview)
		so.addVariable('image', preview);
	
	so.write(target);	// id diva gdzie ma być umieszczony player
}


function setSearchFormBehaviour() {
	var fraz = 'szukaj ...';
	$('#q').focus(function(){
		$(this).val(($(this).val()==fraz)?'':$(this).val());
	}).blur(function(){
		$(this).val(($(this).val()=='')?fraz:$(this).val());
	});
}


function setlikeitBehaviour() {
	

	$('#likeit').mouseover(function() {
			$('#likeit_vote').show();
	}).mouseout(function() {
			$('#likeit_vote').hide();
	}).click(function() {
//		if($('#likeit_logged').val()=='1') {
			$('#likeit_form').submit();
//		}
//		else {
//			$('#likeit_login_register').show();
//		}
	});
	
}


//
//function setMenuBehaviour() {
//	
//	
//	$('.l0').mouseover(function() {
//		
//		console.log($(" > ul", this));
//		
//		$(" > ul", this).show();
//		
//		if($(" > ul", this).length) {
//			$(" > a", this).addClass('selected');
//		}
//	}).mouseout(function() {
//		$(' > ul', this).hide();
//	});
//	
//	$('.l0 > ul').mouseout(function() {
//		$(this).hide();
//		$(".hbm_ul > li > a").removeClass('selected');
//	});
//	
//}



$(document).ready(function(){
	setSearchFormBehaviour();
	setlikeitBehaviour();
//	setMenuBehaviour();
});



var recomendPopUpWindow = '';


function openRecomendPopUpWindow(nid, base) {
	if(!recomendPopUpWindow.closed && recomendPopUpWindow != '') {
		recomendPopUpWindow.focus();
	}
	else {
		recomendPopUpWindow = window.open(base+'/recomend/'+nid,'Poleć Artykuł Znajomemu','scrollbars=yes,menubar=no,status=no, resizable=yes, width=700,height=500');
		recomendPopUpWindow.focus();
	}
}




function checkRegisterForm() {
	var msg ='';
	
	if($.trim($('#username').val())=='')
		msg += "\n Podaj <span style=\"font-weight:bold\">nazwę użytkownika</span>";
			
	if($.trim($('#name').val())=='')
		msg += "\n Podaj <span style=\"font-weight:bold\">imię</span>";
	
	if($.trim($('#surname').val())=='')
		msg += "\n Podaj <span style=\"font-weight:bold\">nazwisko</span>";
	
	if($.trim($('#email').val())=='')
		msg += "\n Podaj adres email";
	
	if($.trim($('#password').val())=='' || $.trim($('#password2').val())=='')
		msg += "\n Podaj <span style=\"font-weight:bold\">hasło</span> dwukrotnie";
	
	if($.trim($('#password').val())!= $.trim($('#password2').val()))
			msg += "\n Podałeś dwa <span style=\"font-weight:bold\">różne hasła</span>";
	
	if(!$('#regulamin').attr('checked'))  
		msg += "\n Aby się zarejestrować musisz zaakceptować <span style=\"font-weight:bold\">regulamin</span>";
	
//	console.log(msg);
//	return false;
	
	if(msg) {
		$('#register_msg').show('slow').html(msg);
		return false;
	}
	else
		return true;
}


function alert_abuse(cid) {
	$('#comment_abuse_id').val(cid);
	$('#comment_abuse_form').submit();
}
