
	// spis funkcji
	// - showObject
	var blocked = false;
	var userActive = 0;
	function createCookie(name,value) {
	
		var date = new Date();
		date.setTime(date.getTime()+(9999999*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	
		document.cookie = name+"="+value+expires+"; path=/";
		
	}

	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 eraseCookie(name) {
		createCookie(name,"",-1);
	}
	function checkIfCook(name){
		alert(readCookie(name));
	}
	function showObject(id){		
		
		if(document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = "block";
		}
	}

	function popup(mylink, windowname)
	{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href, windowname, 'width=500,height=300,scrollbars=yes');
	return false;
	}

	
	function changeColourRight(){				
		mint.fx.Color("addpicl", "backgroundColor", null, "f1fbfd", 20, 10);
		mint.fx.Color("addpicr", "backgroundColor", null, "f7f7f7", 20, 10);	
		$("addpicla").style.fontWeight = "normal";
		$("addpicra").style.fontWeight = "bold";
		$("addpicra").style.textDecoration = "none";
		$("addpicra").style.color = "#000000";
		$("addpicla").style.color = "#9a9695";		
		$("addpicla").style.textDecoration = "underline";				
	}
	function changeColourLeft(){				
		mint.fx.Color("addpicl", "backgroundColor", null, "f7f7f7", 20, 10);
		mint.fx.Color("addpicr", "backgroundColor", null, "f1fbfd", 20, 10);
		$("addpicra").style.fontWeight = "normal";
		$("addpicla").style.fontWeight = "bold";
		$("addpicla").style.textDecoration = "none";
		$("addpicra").style.textDecoration = "underline";		
		$("addpicla").style.color = "#000000";		
		$("addpicra").style.color = "#9a9695";				
	}	
	function changeBack(from,by){			
		
		mint.fx.Color(from+"mark", "backgroundColor", null, "f1fbfd", 20, 90);
		mint.fx.Color(from+"mark", "color", null, "9b969c", 20, 90);
		
		mint.fx.Color(from+"comm", "backgroundColor", null, "f1fbfd", 20, 90);
		mint.fx.Color(from+"comm", "color", null, "9b969c", 20, 90);
		
		mint.fx.Color(from+"seen", "backgroundColor", null, "f1fbfd", 20, 90);
		mint.fx.Color(from+"seen", "color", null, "9b969c", 20, 90);
		
		mint.fx.Color(from+"fav", "backgroundColor", null, "f1fbfd", 20, 90);
		mint.fx.Color(from+"fav", "color", null, "9b969c", 20, 90);
		
		mint.fx.Color(from+by, "backgroundColor", null, "f7f7f7", 20, 90);		
		mint.fx.Color(from+by, "color", null, "484848", 20, 90);
		
	}		
	function zliczaj_znaki(id,my_form,maxx){
		if(document.getElementById(id).value.length <= maxx){
			a = document.getElementById(id).value.length;
			b = maxx;
			c = b - a;
			document.getElementById(id+'_ile').innerHTML= '('+c+')';
		}else{
			document.getElementById(id).value = document.getElementById(id).value.substring(0, maxx);
		}
	} 
	
	// fnkcja aktywujaca pola z ocenami jesli 
	// user nie oddal glosu na zdjecie
	function activeMarkBoxes(model)
	{	
		active(model);
		//setTimeout(active(model),100000000);				
	}
	
	function active(model)
	{	
		
		
			var i = 0;	// licznik
			var di, dii, cok;	// tu bedzie wczytany div
			var marks = new Array();
			
			if( di = document.getElementById("markbox_0") ){
				if( dii = document.getElementById("markboxid_0") ){
					
					if( !readCookie("voted_on_"+dii.innerHTML) ){												
						if(model == 'pictures'){
							di.innerHTML="<div>Oddaj głos</div><img src=\"images/ok2.gif\" style=\"margin-top:3px;padding-top:0px;\">";
						}else{
							di.innerHTML="+";
						}
						di.style.cursor="pointer";
					}
					
				}
			}
			
			for (i=0;i<=12;i++){

				
					if( dii = document.getElementById("markboxid_"+i) ){						
						marks.push(dii.innerHTML);
					}
			
				
				if(model == 'index'){
				
						
						if( dii = document.getElementById("markbox2id_"+i) ){						
							marks.push(dii.innerHTML);
						}
				}
				
			}
			
			getPicturesMarks(marks,model);
			
		
		blocked = false;		
	}	
	
	function tryToActiveDiv(what,div){
		var text = document.getElementById(what).value;		
		if(text == ' ' || text == '\n'){
			document.getElementById(what).value = "";
			text = "";
		}
		if(text){
			document.getElementById(div).style.display = "block";
		}else{
			document.getElementById(div).style.display = "none";
		}		
	}
	function hideObject(id){	
		document.getElementById(id).style.display = "none";
	}	
	
	function showObject2(id){
		document.getElementById(id).style.visibility = "visible";
	}
	
	function changeBorders(all_pic,id){
		if(all_pic > 0){			
			for(i=0;i<all_pic;i++){
				document.getElementById('pic_'+i).style.border = '3px solid #e6e6e6';
			}
		}
		document.getElementById(id).style.border = '3px solid #747474';
	}
	
	function hideObjects(obj){
		var broken = obj.split(',');
		for(var i=0;i < broken.length;i++){
			hideObject(broken[i]);
		}
	}		
	
	// zaznaczanie wszystkich obiektow checkboxow na stronie
	 function makeCheck(){ 
		var its = document.getElementsByName('delete[]');
		for( i = 0; i < its.length; i++ ){
			its[i].checked = document.search.ja.checked;
		}
	} 
	
	/*
	 * zaladuj oceny dla tablicy zdjec
	 */
	function loadMarks(){
		
		alert('marks');
	
	}

	
	/*
	 * zamyka okno ze zgloszeniem naruszenia
	 */
	function closeCommentViolation(id){
		
		document.getElementById(id).innerHTML = "";
	
	}	
	
	/*
	 * zamyka okno ze zgloszeniem naruszenia
	 */
	function closeViolation(){
		
		document.getElementById("add_favourite").innerHTML = "";
	
	}	
	
	/*
     * chowa przyciski do dodanai komentarzy i zgloszenia naruszenia
	 * jesli uzytkownik jest zablokowany
	 */
	function checkBlocked(active){
			userActive = active;
		if (active == 1 || active == 0){
		
			showObject("addd_co");
			showObject("show_viol");			
		}
	}	
	
	function unblockVote(id){			
		cok = "voted_on_"+id;		
		if (!readCookie(cok)){	// jesli jeszcze user nei glosowal odblokowujemy mu przycisk ok
			if (box = document.getElementById("vote_"+id)){
				box.innerHTML = '<img src="images/ok2.gif" id="vote_img_'+id+'" style="padding-top:4px;cursor:pointer" onClick="hideObject(\'vote_img_'+id+'\');voteOnPic('+id+')">';
			}
		}
	}
	function unblockVote2(id){		
		cok = "voted_on_"+id;
		if (!readCookie(cok)){	// jesli jeszcze user nei glosowal odblokowujemy mu przycisk ok
			if (box = document.getElementById("vote2_"+id)){
				box.innerHTML = '<img src="images/ok2.gif" id="vote2_img_'+id+'" style="padding-top:4px;cursor:pointer" onClick="hideObject(\'vote2_img_'+id+'\');voteOnPic('+id+')">';
			}
		}
	}	
	function unblockVote3(id){	
		cok = "voted_on_"+id;
		if (!readCookie(cok)){	// jesli jeszcze user nei glosowal odblokowujemy mu przycisk ok
			if (box = document.getElementById("vote_"+id)){
				box.innerHTML = '<div id="vv">Oddaj głos</div><img src="images/ok2.gif" id="vote_img_'+id+'" style="padding-top:4px;cursor:pointer" onClick="hideObject(\'vv\');hideObject(\'vote_img_'+id+'\');voteOnPic('+id+')">';
			}
		}
	}	
	function unblockCommentViolationBoxes(){
		
		if(userActive != 0){
		
			var b = false;
			var i = 1;
			if(document.getElementById("viol_box_0")){
				b = document.getElementById("viol_box_0");			
			}						
			while(b){				
				b.style.display = "block";													
				b = false;				
				if(document.getElementById("viol_box_"+i)){
					b = document.getElementById("viol_box_"+i);				
				}							
				i++;
			}			
		}
		
		b = false;
		i = 1;
		if(document.getElementById("cv_0")){
			b = document.getElementById("cv_0").innerHTML;		
		}		
		while(b){							
			if( !readCookie("voted_onc_"+b) ){			
				document.getElementById("plus2_"+b).style.display = "block";
			}else{				
				document.getElementById("plusc2_"+b).style.display = "block";
			}	
			b = false;
			if(document.getElementById("cv_"+i)){
				b = document.getElementById("cv_"+i).innerHTML;
			}			
			i++;
		}
		
	}
		
		
	function validForm(){
		var http = document.getElementById("ww").style.display;
		if( http == "none" ){
			// jesli jest upload z pliku
			var file = document.getElementById("upfile").value;
			var sp = file.split(".");
			var type = sp[sp.length-1];			
			if(type == 'jpg' || type=='gif' || type=='jpeg' || type=='png' || type == 'JPG' || type=='GIF' || type=='JPEG' || type=='PNG'){
				return true;	
			}else{
				alert('Dodawane zdjęcie musi być formatu jpg,gif lub png.');
				return false;
			}
		}
		
	}	
	
	function validForm2(){
		var http = document.getElementById("fw_1").style.display;

		if( http == "none" ){	
		
			// jesli jest upload z pliku
			var file = document.getElementById("upfile2").value;
//			alert(file);
			var sp = file.split(".");
			
			var type = sp[sp.length-1];			
			
			if(type == 'jpg' || type=='gif' || type=='jpeg' || type=='png' || type == 'JPG' || type=='GIF' || type=='JPEG' || type=='PNG'){
				return true;	
			}else{
				alert('Dodawane zdjęcie musi być formatu jpg,gif lub png.');
				return false;
			}
		}
		
	}		
		