	function itm_pop(iid)
	{
		popWin=window.open( base_url+'index.php?module=catalog&action=itemPopup&itemId='+iid+'&no_buy=1'+'&lid='+base_lid,iid,'width=760,height=450,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
		popWin.window.focus();
		return false;
	}
	
	
	function crt_pop(bid)
	{
		popWin=window.open( base_url+'index.php?module=cart&action=one_cart&cart_id='+bid+'&lid='+base_lid,'cart_detales','width=700,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
		popWin.window.focus();
	}
	
	function invc_pop(vid){
		popWin=window.open( base_url+'index.php?module=cart&action=invoice_cart&cart_id='+vid+'&lid='+base_lid,'invoice_detales','width=700,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
		popWin.window.focus();
	}
	
	function print_cart_doc_pop(bid){
		popWin=window.open( base_url+'index.php?module=cart&action=print_cart_doc&cart_id='+bid,'print_cart_doc','menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=yes');
		popWin.window.focus();
	}
	
	var ua = navigator.userAgent.toLowerCase();
	//if (document.all != null){
	if ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ){
		CRNT_BROWSER = 'ie';		// IE
	}else{
		CRNT_BROWSER = ''; 			// OTHERS
	}
	
	function div_display( div_name ){
	
			div_ = document.getElementById(div_name);
			if ( div_ != null ){
				if ( div_.style.display == 'none'){
					div_.style.display = 'block';
					return true;
				}else{
					div_.style.display = 'none';
				}
			}
			return false;
	}
	
	/**
	*	Converts dec to hex
	*/
	function dechex(d)
	{
		var hD = "0123456789ABCDEF";
		var h  = hD.substr(d&15,1);
		while (d > 15)
		{
			d>>=4;h=hD.substr(d&15,1)+h;
		}
		return h;
	}
	
	/**
	*	Converts hex to dec
	*/
	function hexdec(h)
	{
		return parseInt(h,16);
	}
	
	function viewPreview(url, type)
	{
		var firstArg = "";
		if (type = 'new') 
		{
			form = document.getElementById("albumForm");
			argStr = "";
			var hasFirst = false;
			for (i = 0; i < form.length; i++)
			{
				if (form.elements[i].type == 'checkbox' && form.elements[i].name.indexOf('album[photos][') >= 0 && form.elements[i].checked == true)
				{
					if (hasFirst == false)
					{
						firstArg = form.elements[i].value;
						hasFirst = true;
					}
					argStr += dechex(form.elements[i].value) + ";";
				}
			}
			argStr = (argStr != '') ? "&phids="+argStr : '';
		}
		submitFormEx("albumForm", url + argStr + '&phid=' + firstArg);
		return false;
	}
	
	function showPhotos(url, type)
	{
		
		if (isSelectedPhotos())
		{
			viewPreview(url, type);
			return false;
		}
		else
		{
			switch (base_lid)
			{
			case "2": //EN
				raiseError('There are no photos in active folder or no photos selected. ');
				break;
				
			case "3": //RU
				raiseError('Есть Нет фотографий в активную папку или нет фотографий выбраны.');
				break;
				
			default: //LT & etc.
				raiseError('Šiame kataloge nuotraukų nėra arba jos nepažymėtos.');
				break;
			}
			return false;
		}
	}
	
	/***
	 *	Pakeicia formos locationa ir ja submitina
	 */
	function submitFormEx(id, newLocation) {
		var frm = document.getElementById(id);
	
		if (frm != null) {
			frm.action = newLocation;
			frm.submit();
		}
	}
	
	var check_state = true;
	function checkAllById(prefix, postfix)
	{
		var form = document.getElementById("albumForm");
	
		if (folderContainsPhotos())
		{
			for (i = 0; i < form.length; i++) {
				var item = form.elements[i];
				if (item.type == 'checkbox') {
					if (item.id.substr(0, prefix.length) == prefix && item.id.substr(item.id.length - postfix.length, postfix.length) == postfix)
					{
						item.checked = check_state;
					}
				}
			}
			
			recountCheckedById(prefix, postfix);
			check_state = !check_state;
		}
		else
		{
			switch (base_lid)
			{
			case "2": //EN
				raiseError('There are no photos in active folder.');
				break;
				
			case "3": //RU
				raiseError('Есть Нет фотографий в активную папку.');
				break;
				
			default: //LT & etc.
				raiseError('Šiame kataloge nuotraukų nėra.');
				break;
			}
			return false;
		}
	}
	
	/*checks if there is at least one photo in current folder*/
	
	function folderContainsPhotos(){
		var form = document.getElementById('albumForm');
		for (i = 0; i < form.elements.length; i++)
		{
			if (form.elements[i].name.indexOf('photos') > 0)
			{
					return true;
			}
		}
		return false;
	}
	
	function raiseError(msg, timeout)
	{
		var tm = 10000;
		
		if (timeout != null)
			tm = timeout;
		
		$('js_error_container').style.display = 'none';
		$('js_error_inside_text').innerHTML = msg;
		$('js_error_container').style.display = 'block';
		$('js_error_container').style.opacity = 1;
		var top = $('top');
		if(top == null)
			top = $('centerOnly'); //fpi=1 atveju
			
		top.scrollTo();
		setTimeout("hideContainer()", tm);
		return false;
	}
	
	function recountCheckedById(prefix, postfix)
	{
		checked_count = 0;
		form = document.getElementById("albumForm");
		if (document.getElementById("select_all_photos") != null && document.getElementById("select_all_photos").value == 1)
		{
			checked_count = document.getElementById("albumAllPhotos").value;
		}
		else
		{
			for (i = 0; i < form.length; i++)
			{
				var item = form.elements[i];
				if (item.type == 'checkbox')
				{
					if (item.checked == true && item.id.substr(0, prefix.length) == prefix && item.id.substr(item.id.length - postfix.length, postfix.length) == postfix)
					{
						checked_count++;
					}
				}
			}
			/*
			if (document.getElementById('albumSelectedPhotos') != null)
			{
				var selected = parseInt(document.getElementById('albumSelectedPhotos').value);
				checked_count += selected
			}*/
		}
		if (document.getElementById('div_photos_list_checked_count') != null) {
			document.getElementById('div_photos_list_checked_count').innerHTML = checked_count;
		}
	}
	
	function recount_checked()
	{
		recountCheckedById('', '');
	}
	
	/**
	*	Setting nice errors on fly
	**/
	function hideErrorContainer(obj)
	{
		$('js_error_container').style.display = 'none';
	}
	function raiseError(msg)
	{
		document.getElementById('js_error_container').style.display = 'none';		
		document.getElementById('js_error_inside_text').innerHTML = msg;
		document.getElementById('js_error_container').style.display = 'block';
		return false;
	}
	function hideError()
	{
		document.getElementById('js_error_container').style.display = 'none';
	}
	

function hideContainer()
{
	new Effect.Opacity('js_error_container', {
		duration: 1.0, 
		transition: Effect.Transitions.linear, 
		from: 1.0, to: 0,
		afterFinish: hideErrorContainer });
}

/**
*	leaves two digits after point
*/
function round_money(price){

	price = Math.round(price*100)/100;
	price = price.toString(10);
	taskas = price.lastIndexOf(".");
	if (taskas==-1){
		price+=".00";
	}else{
		poTasko = price.length-taskas-1;
		if (poTasko < 2){
			price+="0";
		}
	}
	return price;
}
	function guide()
	{
		var corner_pic = document.getElementById('gidas_corner');
		var bullet = document.getElementById('gidas_bullet');
		var content = document.getElementById('gidas_content');
		var main_text = document.getElementById('gidas_text');
		
		if (content) { div_display('gidas_content'); }
		
		if (corner_pic)
		{
			corner_src = changeImageSrc(corner_pic.src, 'gidas_corner_open', 'gidas_corner_closed.gif');
			if (corner_src != false)
			{
				corner_pic.src = corner_src;
			}
			else
			{
				corner_src = changeImageSrc(corner_pic.src, 'gidas_corner_closed', 'gidas_corner_open.gif');
				if (corner_src != false)
				{
					corner_pic.src = corner_src;
				}
			}
		}
		
		if (bullet)
		{
			blt_src = changeImageSrc(bullet.src, 'gidas_bullet_1', 'gidas_bullet_2.gif');
			if (blt_src != false)
			{
				bullet.src = blt_src;
			}
			else
			{
				blt_src = changeImageSrc(bullet.src, 'gidas_bullet_2', 'gidas_bullet_1.gif');
				if (blt_src != false)
				{
					bullet.src = blt_src;
				}
			}
		}
		return false;
	}
	function changeImageSrc(img_src, search, replace)
	{
		var mas;
		if (img_src.indexOf(search) != -1)
		{
			mas = img_src.split("/");
			mas[mas.length-1] = replace;
			new_src = mas.join("/");
			return new_src;
		}
		return false;
	}
	function flash_girl(link_, width, height) {
	  document.write('<object type="application/x-shockwave-flash" data="'+link_+'" width="'+width+'" height="'+height+'">\n');
	  document.write('<param name="movie" value="'+link_+'" />');
	  document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	  document.write('<param name="menu" value="false" />\n');
	  document.write('<param name="quality" value="best" />\n');
	  document.write('<param name="wmode" value="transparent" />\n');
	  document.write('<param name="bgcolor" value="#ffffff" />\n');
	  document.write('</object>\n');
	}
	function me_submit() {
		document.votebar.submit();
	}
	function make_album_validate(number)
	{
	  count = 0;
	  ok = 0;
	  form = document.getElementById("albumForm");
	  
	  for (i = 0; i < form.length; i++)
	  {
	    if (form.elements[i].type == 'checkbox')
		{
		  if (form.elements[i].checked == true)
		    count++;
		}
	  }
	  
	  if (number > 1 && count <= number)
        ok = count;
	  
	  return ok;
	}
	function form_album_validate(){
		checked = false;
		form = document.getElementById("albumForm");
		for (i = 0; i < form.length; i++){	
			if (form.elements[i].type == 'checkbox'){
				if (form.elements[i].checked == true){
					checked = true;
				}
			}
		}
		return checked;
	}
	function checkAll(){
		
		form = document.getElementById("albumForm");
		for (i = 0; i < form.length; i++){	
			if (form.elements[i].type == 'checkbox') {
				form.elements[i].checked = check_state;
			}
		}
		check_state = !check_state;
		recount_checked();
	}
	function confirmDelete(text) {
		return confirm(text);
	}
	function submitForm(id) {
		form = document.getElementById(id);
		if (form != null)
			form.submit();
	}
	function submitFormAdvanced(id, input_name) {
		form = document.getElementById(id);
		if (form != null){
			var new_input = document.createElement('input');
			new_input.setAttribute('type','hidden');
			new_input.setAttribute('name',input_name);
			form.appendChild(new_input);
			form.submit();
		}
	}
	function openPreview(url, type) {
		
		if (type = 'new') {
			form = document.getElementById("albumForm");
			argStr = "";
			for (i = 0; i < form.length; i++){	
				if (form.elements[i].type == 'checkbox' && form.elements[i].name == 'album[photos][]' && form.elements[i].checked == true) {
					argStr += form.elements[i].value + ";";
				}
			}
			argStr = (argStr != '') ? "&phids="+argStr : '';
		}
		window.open(url+argStr, 'previewPopup', "scrollbars=yes,toolbar=no,height=675,width=565,resizable=no,z-lock=yes")
		return false;
	}
	function showVal(obj) {
		if (obj != null && obj.value == "") {
			obj.value = obj.id;
		}
	}
	
	function clearVal(obj) {
		if (obj != null && (obj.value == obj.id)) {
			obj.value = "";
		}
	}

function prt_pop(pid){ 
	popWin=window.open( base_url+'index.php?module=partners&action=partnersPopup&partner_id='+pid,'partner_detales','width=554,height=330,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	popWin.window.focus();
}

/*function itm_pop(iid){ 
	popWin=window.open( base_url+'index.php?module=catalog&action=itemPopup&itemId='+iid+'&no_buy=1',iid,'width=600,height=450,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	popWin.window.focus();
	return false;
}

function crt_pop(bid){ 
	popWin=window.open( base_url+'index.php?module=cart&action=one_cart&cart_id='+bid,'cart_detales','width=554,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	popWin.window.focus(); 
}

function invc_pop(vid){ 
	popWin=window.open( base_url+'index.php?module=cart&action=invoice_cart&cart_id='+vid,'invoice_detales','width=700,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	popWin.window.focus(); 
}
*/
function choose_photo_pop(zone){ 
	popWin=window.open(base_url+'index.php?module=make&action=choose_photo&zone_id='+zone,'choose_photo','width=700,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	popWin.window.focus(); 
}

function ftp_upload(){
	popWin=window.open(base_url+'/lib/scripts/img_upload_java_applet/','ftp_upload','width=700,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	popWin.window.focus();
}