function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function visibleoff(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'hidden';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.visibility = 'hidden';
		}
		else { // IE 4
			document.all.id.style.visibility = 'hidden';
		}
	}
}

function visibleon(id) {
	//safe function to show an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'visible';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.visibility = 'visible';
		}
		else { // IE 4
			document.all.id.style.visibility = 'visible';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : '/';
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

function set_cookie(name, value, days) {
	var expireCookieDate = new Date();
	expireCookieDate.setTime(expireCookieDate.getTime() + (days*24*3600*1000));
	SetCookie(name, value, expireCookieDate, '/');
}


function abs_horiz_scroll(element_to_move, offset, element_container, info_id) {
	var el = $$(element_to_move)[0];
	var elc = $$(element_container)[0];
	var el_w = el.getWidth();
	var elc_w = elc.getWidth();
	var oldLeft = parseInt(el.getStyle('left'));
	var newLeft = (oldLeft + offset);
	if (newLeft < elc_w - el_w) newLeft = elc_w - el_w;
	if (newLeft > 0) newLeft = 0;
	if (Math.abs(oldLeft - newLeft) > 5) el.setStyle({left: newLeft + 'px'});
	////
	set_horizscroll_info_text(info_id, element_to_move, element_container, offset);
}

function set_horizscroll_info_text(info_id, scroll_div, container_div, item_width) {
	var elc_w = $$(container_div)[0].getWidth();
	var el = $$(scroll_div)[0];
	if(el) {
		var el_w = el.getWidth();
		var el_l = parseInt(el.getStyle('left'));
		var first_item_no = Math.round(Math.abs(el_l / item_width)) + 1;
		var last_item_no = first_item_no + Math.round(Math.abs(elc_w / item_width)) - 1;
		$(info_id).innerHTML = '' + first_item_no + '-' + last_item_no + ' od ' + Math.round(Math.abs(el_w / item_width));
	}
}

function loadPredlazemoStilImage(element_id, seq, sshow) {
	if (idInterval) clearTimeout(idInterval);
	divID = 'predlazemo-fullsize-image-container';
	new Ajax.Updater(divID, '/ajax/predlazemo_fullsize_image.php', {
		asynchronous:true,
		evalScripts:true,
	    onComplete: function(r) {
	    	$(divID).show();
	    },
		parameters: {id_element: element_id, sequence: seq, slideshow: sshow}
   	});
}

function loadPhotoBlogImage(element_id, seq, sshow) {
	if (idInterval) clearTimeout(idInterval);
	divID = 'photo-blog-fullsize-image-container';
	new Ajax.Updater(divID, '/ajax/photo_blog_popup.php', {
		asynchronous:true,
		evalScripts:true,
	    onComplete: function(r) {
	    	$(divID).show();
	    },
		parameters: {id_element: element_id, sequence: seq, slideshow: sshow}
   	});
}

function loadProductImage(element_id, seq, sshow) {
	if (idInterval) clearTimeout(idInterval);
	divID = 'prod-image';
	new Ajax.Updater(divID, '/ajax/prod-image.php', {
		asynchronous:true,
		evalScripts:true,
	    onComplete: function(r) {
	    	$(divID).show();
	    },
		parameters: {id_element: element_id, sequence: seq, slideshow: sshow}
   	});
}

var idInterval;
function sshow_next_img(element_id, seq) {
	idInterval = setTimeout('loadPredlazemoStilImage(' + element_id + ', ' + seq + ', 1);', 5000);
}
function pb_sshow_next_img(element_id, seq) {
	idInterval = setTimeout('loadPhotoBlogImage(' + element_id + ', ' + seq + ', 1);', 5000);
}