function zaznacz()
{
    document.getElementById("linkText").focus();
    document.getElementById("linkText").select();
}

function openWindow( address )
{
    window.open(address, "wykres", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=480,height=640");
}

function viewWyniki( address )
{
    window.open( address, "wyniki", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=640,height=480");
}

function zoom(adress) {
	noweOkno = window.open(adress,"club_photo", "menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no, width=820, height=640");
}

function skasuj(obj) {
    if(obj.value == "Szukaj")
    obj.value = "";
}
function wstaw(obj) {
    if(obj.value == "")
    obj.value = "Szukaj";
}

var compareCount = 0;
function addCompare( obj )
{
	if( obj.checked==true )
	{
		if( compareCount<2)
		{
			compareCount++;
		}
		else
		{
			obj.checked=false;
			alert("Mozesz wybrac tylko 2 modele!");
		}
	}
	else
	{
		compareCount=compareCount-1;
	}
}
function resetCompare()
{
	//wywal wszystkie
	compareCount = 0;
	return true;
}

function sendComment(url_adress)
{
	var nick = $("#nick").val();
	var token = $("#token").val();
	var text = $("#text").val();
	var mail = $("#mail").val();
	var ret = true;
	if( nick=="")
	{
		$("#commentInfo").empty().append("Wypełnij nick!");
		ret = false;
	}
	else if(token=="")
	{
		$("#commentInfo").empty().append("Wypełnij kod!");
		ret = false;
	}
	else if(text=="")
	{
		$("#commentInfo").empty().append("Wypełnij text!");
		ret = false;
	}
	if( ret==true )
	{
		$.ajax({
		type: "POST",
		url: url_adress,
		data: {
		nick : $("#nick").val(),
		token : $("#token").val(),
		text : $("#text").val(),
		mail : $("#mail").val(),
		uniqueParameter : Math.random( 1000000 )
		},
		success: function(msg){
			$("div#comments_form").html(msg);
		}
		});
		return false;
	}
	return ret;
}

function getComment( link )
{
 $.ajax({
	type: "GET",
	url: link,
	data: {
	uniqueParameter : Math.random( 1000000 )
	},
	success: function(msg){
		$("div#comments").html(msg);
	}
 });
 return false;
}

function showFull(id, host)
{
	window.open(host+'galeria/foto/pelny/'+id+'.html', 'Galeria', 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=800,height=600');
}
function showFull2(id, host)
{
	window.open(host+'club/full/'+id+'.html', 'Galeria', 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=640,height=480');
}

function highlight( nr )
{
	var ile = nr;
	var current = nr;
	var objId = 0;
	var disableHighligh = false;
	var path = 'images/rings/';
	var moduleName = 'galeria';

	this.podswietl = function(obj, nr, id, module)
	{
		if(disableHighligh==true)
			return true;
		for(var i=1; i<=nr; i++)
			document.getElementById("img"+i).src = path+i+"_a.png";
		for(var i=nr+1; i<=4; i++)
			document.getElementById("img"+i).src = path+i+"_n.png";
			
		
		current = nr;
		objId = id;
    	moduleName = module;
		obj.onclick = this.saveState;
    	obj.onmouseout = this.Hide;
	}
	
    this.Hide = function()
	{
		for(var i=1; i<=4; i++)
			document.getElementById("img"+i).src = path+i+"_n.png";
		for(var i=1; i<=ile; i++)
			document.getElementById("img"+i).src = path+i+"_a.png";
    }
    this.saveState = function()
	{
		ile = current;
		disableHighligh = true;
		galleryVote( ile, objId, moduleName );
    }
}

function galleryVote(vote, objId, module)
{ 
 $.ajax({
	type: "GET",
	url: "/"+module+"/vote/"+objId+"/"+vote+".html",
	data: {
	uniqueParameter : Math.random( 1000000 )
	},
	success: function(msg){
		$("#VoteInfo").html(msg);
	}
 });
 return false;
}

function addToFav(movieid)
{ 
 $.ajax({
	type: "GET",
	url: "/filmy/addfav/"+movieid+".html",
	data: {
	uniqueParameter : Math.random( 1000000 )
	},
	success: function(msg){
		$("#VoteInfo").html(msg);
	}
 });
 return false;
}

function delFromFav(movieid)
{ 
 $.ajax({
	type: "GET",
	url: "/filmy/delfav/"+movieid+".html",
	data: {
	uniqueParameter : Math.random( 1000000 )
	},
	success: function(msg){
		alert(msg);
	}
 });
 return false;
}

function potwierdz( text , link )
{
	if( confirm( text ) )
	{
		document.location = link;
	}
	else
	{
		return false;
	}
}

function sendMovie()
{
	var title = $("#film_title").val();
	var text = $("#film_description").val();
	var code = $("#film_code").val();
	if(title=='')
	{
		alert('Musisz wypelnic tytul filmu');
		return false;
	}
	if(text=='')
	{
		alert('Musisz wypelnic opis filmu');
		return false;
	}
	if(code=='')
	{
		alert('Musisz wstawic kod lub link do filmu');
		return false;
	}
	return true;
}