﻿///////////////////GALERIJA////////////////////
var galerija1 = new Array("sk1","sk2","sk3","sk4","sk5","sk6","sk7","sk8","sk9","sk10","sk11","sk12");

var galerija2 = new Array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19",
"20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36");

function getPosition(arrayName,arrayItem)
{
    for(var i=0;i<arrayName.length;i++){ 
       if(arrayName[i]==arrayItem)
            return i;
    }
}
function next(gal,pic){
	var pos = getPosition(gal, pic);
	var next = gal[pos+1];
	
	popup(pic);
	popup(next);
}
function prev(gal,pic){
	var pos = getPosition(gal, pic);
	var next = gal[pos-1];

	popup(pic);
	popup(next);
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}
//////////////////////////////////////////////////////////

//printanje strani
function printpage(){
  window.print();
}

function validate_slo()
{
	if(document.forma.restrict_name.value=='' || document.forma.restrict_text.value=='')
	{
		alert("Prosimo izpolni prazna polja!")
		return false
	}
	
	return true;
}

function validate_eng()
{
	if(document.forma.restrict_name.value=='' || document.forma.restrict_text.value=='')
	{
		alert("Please fill in the missing values!")
		return false
	}
	
	return true;
}


function lengthRestriction_slo(elem, max){
	var uInput = elem.value;
	if(uInput.length <= max){
		return true;
	}
	else
	{
		if(document.getElementById("restrict_name")==elem){
			alert("Dolzina vzdevka ne sme biti daljsa od " +max+ " znakov.");
			elem.focus();
			return false;
		}
		else {			
			alert("Dolzina sporocila ne sme biti daljsa od " +max+ " znakov.");	
			elem.focus();
			return false;
		}
	}
}

function lengthRestriction_eng(elem, max){
	var uInput = elem.value;
	if(uInput.length <= max){
		return true;
	}else{
		if(document.getElementById("restrict_name")==elem){	
		alert("Length of the nickname must be shorter than " +max+ " characters.");
		elem.focus();
		return false;
		}
		else {
		alert("Length of the message must be shorter than " +max+ " characters.");
		elem.focus();
		return false;
		}
	}
}

function zbirka1() {
			if(lengthRestriction_eng(document.getElementById("restrict_text"),100)==true && lengthRestriction_eng(document.getElementById("restrict_name"),20) == true && validate_eng() == true){
				return true;}
			
			else {
				return false;}
}

function zbirka2() {

			if(lengthRestriction_slo(document.getElementById("restrict_text"),100)==true &&lengthRestriction_slo(document.getElementById("restrict_name"),20) == true && validate_slo() == true) {
				return true;}
			else {
			return false;}
}
