

function usr_pop(uid){
	//popWin=window.open( base_url+'?module=&action=&user_id='+uid,'user_detales','width=554,height=350,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no');
	//popWin.window.focus();
}

function prt_pop(pid){ 
	popWin=window.open( base_url+'?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+'?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+'?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+'?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(); 
}


//<block name="pop_up_prinable">,'basket_prinable','width=554,height=400,menubar=yes,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no'); popWin.window.focus(</block name="pop_up_prinable">

	/* Login form */
	function showVal(obj) {
		if (obj != null && obj.value == "") {
			obj.value = obj.id;
		}
	}
	
	function clearVal(obj) {
		if (obj != null && (obj.value == obj.id)) {
			obj.value = "";
		}
	}

	/* / Login form */
	
	
	/**
	*	Function to open preview popup window
	*	@param string url to open
	*	@param string type 'new' or whatever 
	*/
	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;
	}
	
	/**
	*	Submit form by given ID
	*/
	function submitForm(id) {
		form = document.getElementById(id);
		if (form != null)
			form.submit();
	}
	
	
	
	/**
	*	Confirm delete dialog box
	*
	*/
	function confirmDelete(text) {
		
		return confirm(text);
		
	}
	
	var check_state = true;
	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;
		
	}
	
	/* Login form */
	
	
	/**
	*	DIV element display
	*/
	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;
	}

	
	/*
	*	Rounds given float to given decimal places
	*	@param float number
	*	@param int places	 	
	*/
	function round(number, places) {
		
		if (number > 0 && places > 0) {
			inc = Math.pow(10, places);
			number = number * inc;
			number = Math.round(number);
			number = number / inc;
			return number;
		}
		else {
			return '';
		}
		
	}
	
	/**
	*	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 me_submit() {
		document.votebar.submit();
	}
	
	/**
	*	Setting nice errors on fly
	**/
	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;
	}
	/**
	*	Hidding error container
	*/
	
	function hideError()
	{
		document.getElementById('js_error_container').style.display = 'none';
	}
	
	/**
	*	checks are there any photos in current folder
	**/
	function showPhotos(url, type)
	{
		error = true;	
		form = document.getElementById('albumForm');
		for (i=0; i<form.elements.length; i++)
		{
			if (form.elements[i].name.indexOf('photos')>0)
			{
				error = false;
			}
		}
		
		if (!error)
		{
			openPreview(url, type);
			return false;
		}
		else
		{
			raiseError('Šiame kataloge nuotraukų nėra');
			return false;
		}
	}
	
	/**
	*	Default image swaping
	**/
	
	function changeImage(id, url)
	{		
		var image = document.getElementById(id);		
		if (image)
		{
			image.src = url;
		}
	}	
	
	function change_search_type(value)
	{
		var form = document.getElementById('main_search_form');
		if (form_target && form)
		{
			form.setAttribute('action', form_target[value]);
		}
	}
	
	function show_city(id)
	{
		// because flash gives id=1 not 1
		var part_id = id.split('id=');
		id = part_id[1];
		
		var city = document.getElementById('city_'+id);
		var city_list = document.getElementById('city_list');
		if (city_list)
		{
			var tables = city_list.getElementsByTagName('div');		
			var temp_cities = Array();
			var i;
			for (i=0; i<tables.length; i++)
			{
				if (tables[i].id.indexOf('city_')!=-1)
				{
					temp_cities[temp_cities.length] = tables[i];
				}
			}			
			if (temp_cities.length > 0)
			{
				for (i=0; i<temp_cities.length; i++)
				{
					temp_cities[i].style.display = "none";
				}
			}
			if (city)
			{
				city.style.display = "block";
			}
		}
	}
	
	
function flash_map(link_){
	document.write('<object id="map_lang" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="450" width="560" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">\n');
	document.write('<param value="sameDomain" name="allowScriptAccess" />\n');
	document.write('<param value="'+link_+'" name="movie" />\n');
	document.write('<param value="high" name="quality" />\n');
	document.write('<param value="#ffffff" name="bgcolor" />\n');
	document.write('<embed src="'+link_+'"  name="movie" width="560" height="450" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="exactfit"></embed>\n');
	document.write('</object>\n');
}
