DMW = {
	$: function(x){return document.getElementById(x);},
	$S: function(x) {return this.$(x).style},
	isInt: function(f){return (/^\d+$/.test(f)) ? true : false},
	isEmail: function(x){return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(x))? true : false;},
	h_e : function(ex,dom,nam) 
	{
		var max_length = 23;
		var email = nam + '@' + dom + '.' + ex;
		var target = email;
		if (email.length>max_length) {email = email.substr(0,max_length) + '..'}
		document.write('<a href="mailto:' + target + '" class="email">' + email + '</a>');
	},	
	isPhone: function(x){var strValidChars="0123456789+- )(";var strChar;var blnResult=true;if(x.length==0)return false;for(i=0;i<x.length&&blnResult==true;i++){strChar=x.charAt(i);if(strValidChars.indexOf(strChar)==-1){blnResult=false;}}return blnResult;},
	isMoney: function(x){var strValidChars="0123456789.,";var strChar;var blnResult=true;if (x.length==0)return false;for(i=0;i<x.length&&blnResult==true;i++){strChar=x.charAt(i);if (strValidChars.indexOf(strChar)==-1){blnResult=false;}}return blnResult;},
	isIntOP: function(e){var isNS4=(navigator.appName=="Netscape")?1:0;if(!isNS4){if((e.keyCode>7&&e.keyCode<10)||(e.keyCode>27&&e.keyCode<30)||(e.keyCode==46)||e.keyCode>47&&e.keyCode<58){e.returnValue=e.keyCode;}else{e.cancelBubble=true;e.returnValue=false;}}else{if((e.which>7&&e.which<10)||(e.which>27&&e.which<30)||(e.which==46)||e.which>47&&e.which<58){return true;}return false;}}, //check integer on press (event)
	getVal: function(x){if(this.$(x)){if(this.$(x).value){return this.$(x).value;}if(this.$(x).innerHTML){return this.$(x).innerHTML;}}	return '';},
	go2: function(x){location.href=x;},
	switchPic: function(picid, newpic) {if (this.$(picid) && newpic){this.$(picid).src=newpic.src;}},// for picture gallery
	loadCSS: function(url) {var f=document.createElement("link");f.setAttribute("rel", "stylesheet");f.setAttribute("type", "text/css");	f.setAttribute("href", url); document.getElementsByTagName("head").item(0).appendChild(f);}, //dynamic CSS load
	loadJS: function(url) {var j=document.createElement("script");j.setAttribute("type", "text/javascript");j.setAttribute("src", url);document.getElementsByTagName("head").item(0).appendChild(j);}, // dynamic JS load
	sub: function(form_id){this.$(form_id).submit();}, // submiting forms
	debug: function (o) {var s = '';for ( p in o ){s += p + ' - ' + o[p] + '\r\n'} return s;}, // debug objects 
	array2json: function (d) { var json = ""; for (var ind in d) {json += '"'+ind.replace('"','\"')+'":"'+d[ind].toString().replace('"','\\"')+'",';	} json = json.substr(0,json.length-1);	return "{"+json+"}";}, // convert object or array to json
	clone: function (obj){if(obj == null || typeof(obj) != 'object') return obj; var temp = new obj.constructor(); for(var k in obj) {temp[k] = this.clone(obj[k]);}    return temp;},
	getUserVar: function(pname) {if (UDATA.data[pname]) { return this.clone(UDATA.data[pname])} else  {return "";}}, // get user session variable
	isLoggedIn: function() {if (UDATA.user['logged']) {return UDATA.user['logged'];} else  {return 0;}}, // get user session variable
	timeKeeper: [],	userVar: [], userVarNew : [],
	setUserVarProxy: function(key) 
	{
		if ((UDATA.data[key] && UDATA.data[key] == this.userVarNew[key]) || (!UDATA.data[key] && !this.userVarNew[key])) 
		{
			return;
		}  
		UDATA.data[key] = this.clone(this.userVarNew[key]);
		jQuery.post("/lt/vartotojo-profilis/js", {n:key,v:this.userVar[key]});
	},
	
	setUserVar : function(pname, pvalue, delay)	
	{
		delay = (!delay) ? 0 : delay; 
		if (!this.timeKeeper) {this.timeKeeper = [];} 				
		this.userVarNew[pname] = this.clone(pvalue);
		if (typeof(pvalue) == 'array' || typeof(pvalue)=='object')	
		{
			pvalue = this.array2json(pvalue);
		}	
		if (this.timeKeeper[pname])	{window.clearTimeout(this.timeKeeper[pname]);} 
		this.userVar[pname] = pvalue; 
		this.timeKeeper[pname] = window.setTimeout('DMW.setUserVarProxy("' + pname + '");', delay * 1000); 
		},
	chksrch: function(f){if(f&&f.value.length>0&&f.value!='Įveskite paieškos žodį'){return true;}else{if(f){f.focus();}return false;}},
	dosearch: function(f){if(f.search&&f.search.value.length>0&&f.search.value!='Įveskite paieškos žodį'){location.href=f.search_type.options[f.search_type.selectedIndex].value+f.search.value;return false;}else{if(f.search){f.search.focus();}return false;}},
	shI: function(){if(this.$('info')){$('div#info').css('display','block');}},	 // display #info
	ili: function(){if(this.isLoggedIn()==0){this.shI();}},	 // all the actions if user is not logged in
	sortable: function(selector, sess_id) {
		// blocks order
		var newsorder = DMW.getUserVar(sess_id);
		if (typeof(newsorder) == 'object')
		{
		    var $children = jQuery(selector).children();
			$children.remove();
			jQuery.each(newsorder, function(j,k)
			{
				$block = $children.filter('#'+j);
				if ($block.length > 0)
				{
					if (k == 0)
					{
						$block.find('h3 span').attr('class', 'plus');
						$block.find('div.tabcontent').css('display', 'none');
					}
					jQuery(selector).append($block);
				}
			});
			$children.each(function(){if (!newsorder[this.id]){jQuery(selector).prepend(this);}});
		}
		// make blocks sortable
		jQuery(selector).sortable(
		{
			placeholder: (jQuery.browser.msie)? '' : "blockhover", 
			helper: function (e, ui) {return jQuery("<li/>").addClass("blockhelper").append(ui.contents().clone()); },
			update: function(){DMW.sortableSave(sess_id, jQuery(this));},
			cursor: 'move',	scroll: true, opacity: 0.7,	handle: 'h3'
		});
		// add move css
		jQuery(selector + " li h3").css('cursor', 'move');
		// minimize/maximize blocks
		jQuery(selector + " li h3 span").click(function()
		{
			var oc = jQuery(this).attr("class");
			var c = (oc == 'minus') ? 'plus' : 'minus';
			jQuery(this).attr('class',c).parent().parent().children('div.tabcontent').toggle();
			DMW.sortableSave(sess_id, jQuery(selector));
		});
	}, 
	sortableSave : function(sess_id, $obj) { var st = {}; $obj.children().not('.ui-sortable-helper').each(function() { st[this.id] = (jQuery(this).find('h3 span').attr('class') == 'minus')? 1 : 0;	});	DMW.setUserVar(sess_id, st, 4);	}
}

// jq tabs plugin
jQuery.fn.dmwtabs = function() 
{
	var self = this;
	this.$lis = jQuery('li:has(a[href])', self);
	this.$tabs = this.$lis.map(function() { return jQuery('a', this)[0]; });
	this.$tabs.each(function(i, a) 
	{
		jQuery(a).click(function() 
		{
			self.$lis.removeClass('active');
			jQuery(this).parent().addClass('active');
			var myhref = this.href;
			var pos = myhref.indexOf('#');
			if (pos < 0 ) return true;
			var mytab = myhref.substring(pos, myhref.length);
			var cpos;
			self.$tabs.each(function(j, ah) 
			{
				currhref = this.href;
				if (myhref != currhref)
				{
					cpos = currhref.indexOf('#');
					if (cpos >= 0 )
					{
						currtab = currhref.substring(cpos, currhref.length);
						jQuery(currtab).hide();
					}
				}
			});
			jQuery(mytab).show();
			return false;
		});
	});
}

CMNT = 
{
	nm: '',
	inform_confirm: 'Ar tikrai manote, kad šis komentaras netinkamas?',
	inform_thankyou: 'Ačiū, komentaras netrukus bus patikrintas',
	inform_url: '/naujienos/comment_blame',
	gN: function()
	{
		if(typeof UDATA == 'object')
		{
			if(UDATA.user)
			{
				if(UDATA.user.name && UDATA.user.name.length>0)
				{
					this.nm = UDATA.user.name;
					jQuery('input#cmnt_name').val(this.nm);
					jQuery('input#cmnt_name').attr('readonly','readonly');
					jQuery('input#cmnt_name').attr('class','trns');					
				}
			}
		}
	},
	shAn: function()
	{
		this.gN();
		jQuery('#comm_post_id').val(Math.ceil(Math.random() * 89999) + 10000);
		if (this.nm.length>0)
		{
			jQuery('tr#anon_tr').show();
			jQuery('input#anon_check').removeAttr('checked');
		}
	},
	n2a: function(x)
	{
		if (this.nm.length>0)
		{
			if (x.checked==true)
			{
				jQuery('input#cmnt_name').removeAttr('class');
				jQuery('input#cmnt_name').removeAttr('readonly');
				jQuery('input#cmnt_name').val('');
				jQuery('input#cmnt_name').focus();
			}
			else
			{
				jQuery('input#cmnt_name').attr('class','trns');
				jQuery('input#cmnt_name').attr('readonly','readonly');
				jQuery('input#cmnt_name').val(this.nm);
				jQuery('textarea#cmnt_text').focus();
			}
		}
	},
	ft: function()
	{
		if (jQuery('input#cmnt_name').val().length>0)
		{
			setTimeout("jQuery('textarea#cmnt_text').focus()",100);
		}
		else
		{
			setTimeout("jQuery('input#cmnt_name').focus()",100);
		}
	},
	ift: function()
	{
		jQuery('#komentarai ul.tabline li a[href=#fragment-1]').bind('click', function() 
		{
			CMNT.ft();
		});
	},
	blm: function(ob,n,url)
	{
		if (confirm(this.inform_confirm))
		{
			jQuery(ob).load(this.inform_url,{n:n,u:url},function(){alert(CMNT.inform_thankyou);});
			jQuery(ob).attr('onclick','');
			jQuery(ob).unbind('click');
			jQuery(ob).css('cursor','auto');
		}
	}
} // CMNT

CMP = // campaigns
{
	record2cookie: function(pid)
	{
		coo = '';
		if (jQuery.cookie('c155v84')!=null)
		{
			coo = jQuery.cookie('c155v84');
		}
		if (coo=='')
		{
			coo = pid		
		}
		else
		{
			arr = coo.split("-");
			arrl = arr.length;
			for(i=0;i<arrl;i++)
			{
				if (arr[i]==pid)
				{
					return true;
				} // if
			}
			coo += "-" + pid;			
		} // if
		jQuery.cookie('c155v84', coo, { expires: 3 , domain: 'diena.lt', path: '/'});
		return true;
	},
	exists_in_cookie: function(pid)
	{
		if (jQuery.cookie('c155v84')==null)
		{
			return false;
		} // if
		coo = jQuery.cookie('c155v84');
		if (coo=='')
		{
			return false;
		} // if
		arr = coo.split("-");
		arrl = arr.length;
		for(i=0;i<arrl;i++)
		{
			if (arr[i]==pid)
			{
				return true;
			} // if
		} // for
		return false;
	},
	bind_votings: function(url)
	{
		img_active = new Image(); img_active.src = 'http://r.diena.lt/i/heart_it_active.gif';
		img_inactive = new Image(); img_inactive.src = 'http://r.diena.lt/i/heart_it_inactive.gif';
		img_mouseover = new Image(); img_mouseover.src = 'http://r.diena.lt/i/heart_it_mouseover.gif';
		img_vote_loader = new Image(); img_vote_loader.src = 'http://r.diena.lt/i/vote-loader.gif';
		
		user_id = 0;
		if (typeof UDATA == 'object' && UDATA.user.uid && UDATA.user.uid!=undefined)
		{
			user_id = UDATA.user.uid
		} // if
		
		jQuery('div.komentaras a.vote').each(function() 
		{
			post_no = parseInt(jQuery(this).attr('href').replace(/#vote-/, ''));
			if (CMP.exists_in_cookie(post_no))
			{
				jQuery(this).removeAttr('href');
				jQuery(this).attr('title', 'Jums patinkantis įrašas');
				this.className = 'voted';
			}
			else			
			{
				jQuery(this).bind('click', function() 
				{
					post_no = parseInt(jQuery(this).attr('href').replace(/#vote-/, ''));			
					CMP.vote(this, url, post_no, 1, user_id);
					return false;
				});
			}
		});
	},
	vote: function(ob, url, post_no, score, user_id)
	{
		votes_no = parseInt(jQuery('#votesno-'+post_no+' strong').text());
		jQuery(ob).css('display','none');
		jQuery('#vote-loader-'+post_no).css('display','block');		
		jQuery.post(url, {vt:post_no, sc:score, ui:user_id}, function(data){if(data=='1'){CMP.record2cookie(post_no);jQuery(ob).unbind('click');ob.className='voted';jQuery(ob).removeAttr('href');jQuery(ob).attr('title', 'Jums patinkantis įrašas');jQuery('#vote-loader-'+post_no).css('display','none');jQuery(ob).css('display','block');jQuery('#votesno-'+post_no+' strong').text(votes_no+1);jQuery('#votesno-'+post_no).css('display','block');}else{jQuery('#vote-loader-'+post_no).css('display','none');jQuery(ob).css('display','block');alert("Klaida! Atsiprašome, bandykite vėliau.");}});
	}
} // CMP

PIC = 
{
	post_vote: '/vaizdai/vote',
	post_cmnt: '/lt/cmnt',
	post_visits: '/vaizdai/visit',
	rate:null,
	active_photo:'0',
	comments_ajax_reload:1,
	rateover: function()
	{
		
		jQuery('div.tabcontent div.two div.stars0 div.stars').mousemove
		(		
			function(e)
			{
				r = 0;
				if(PIC.rate==null)
				{
					PIC.rate=jQuery('div.tabcontent div.two div.stars0 div.stars div.ratingStars').css('width');
				}				
				r = PIC.rate;
				r = (r.substring(0,r.length-1));
				if(r==''){r=0;}
				r = r/10;				
				var ilgis = jQuery('div.tabcontent div.two div.stars0 div.stars').width();
				var offset32 = jQuery(this).offset();
				var x = e.pageX - offset32.left;
				x = Math.round(x*100/ilgis);
				if (x<0){x=0;}
				if (x>100){x=100;}
				m = x%10;
				x = (x-m)/10;
				if (m>0){x++;}
				x10 = x*10;
			    jQuery('div.tabcontent div.two div.stars0 div.stars div.ratingStars').css('width',x10+'%');
			    if(PIC.active_photo=='0')
			    {
			    	alt = jQuery('#gallery .gallist ul li a[href='+jQuery('#bigpic').attr('src')+'] img').attr('alt');
			    	arr = alt.split('||$||');
			    	PIC.active_photo=arr[5];			    	
			    }
		   }
	   );
	},


	rateclick: function()
	{
		jQuery('div.tabcontent div.two div.stars0 div.stars').click
		(
			function(e)
			{	
				PIC.rate = jQuery('div.tabcontent div.two div.stars0 div.stars div.ratingStars').css('width');
				r = PIC.rate;
				r = (r.substring(0,r.length-1))/10;
				jQuery('div.tabcontent div.two div.stars0 div.starsCount').text(r);
				jQuery('div.tabcontent div.two div.stars0 div.stars').unbind('click');
				jQuery('div.tabcontent div.two div.stars0 div.stars').unbind('mousemove');
				jQuery('div.tabcontent div.two div.stars0 div.stars').css('cursor','auto');
				jQuery('#gallery .gallist ul li a[href='+jQuery('#bigpic').attr('src')+'] img').attr('voted','1');
				jQuery('#gallery .gallist ul li a[href='+jQuery('#bigpic').attr('src')+'] img').attr('rate',PIC.rate);
				uid = 0;
				if(typeof UDATA == 'object' && UDATA.user)
				{
						if(UDATA.user.uid && UDATA.user.uid>0)
						{
							uid = UDATA.user.uid;
						}
					}
				jQuery.post
				(
					PIC.post_vote,
				  	{
				  		vote: r,
						id: PIC.active_photo,
						user_id: uid
					},
				  	function(data)
				  	{
				    	//alert('Ačiū, kad balsavote!');
				  	}
				);
			}
	   );	
	},


	rateout: function()
	{
		jQuery('div.tabcontent div.two div.stars0 div.stars').mouseout
		(
			function(e)
			{	
				jQuery('div.tabcontent div.two div.stars0 div.stars div.ratingStars').css('width',PIC.rate);
			}
	   );	
	},
	
	img2big: function(ob)
	{
		jQuery('#bigpic').attr('src',ob.parentNode.href);
		jQuery('#bigpic').attr('title',ob.title);
		arr = ob.alt.split('||$||');
		jQuery('div#gallery div.autorius').html('&copy; '+arr[0]);
		if (jQuery(ob).attr('rate'))
		{
			PIC.rate = jQuery(ob).attr('rate');
		}
		else
		{
			PIC.rate = Math.round(arr[1]*10)+'%';
		}		
		jQuery('div.tabcontent div.two div.stars0 div.stars div.ratingStars').css('width',PIC.rate);
		r = PIC.rate;
		r = (r.substring(0,r.length-1))/10;
		jQuery('div.tabcontent div.two div.stars0 div.starsCount').text(r);
		jQuery('div.tabcontent div.two div.inf span').text('Vertinimų: '+arr[2]);		
		jQuery('div.tabcontent div.one h2 span.h2').text(ob.title);
		jQuery('span.commentscount span a').text('['+arr[6]+']');
		if (DMW.isInt(arr[6]) && arr[6]>0)
		{
			jQuery('span.commentscount').css("display","inline");
		}
		else
		{
			jQuery('span.commentscount').css("display","none");			
		} // if
		text = arr[3];
		if (text==''){text='&nbsp;';}
		jQuery('div.tabcontent div.one span.date').text(arr[4]);
		PIC.active_photo=arr[5];		
		if (PIC.comments_ajax_reload==1 && document.getElementById('komentarai') && document.getElementById('komentarai')!=undefined)
		{
			c = 'l';
			m = 1;
			md = 0;
			if (document.getElementById('comment_frm') && document.getElementById('comment_frm')!=undefined && document.getElementById('comment_frm')['__action'] && document.getElementById('comment_frm')['__action']!=undefined && document.getElementById('comment_frm')['__action'].value && document.getElementById('comment_frm')['__action'].value!=undefined)
			{
				act_arr = document.getElementById('comment_frm')['__action'].value.split('.');
				c = act_arr[0];
				m = act_arr[1];
			} // if			
			if (PIC.mod_id && PIC.mod_id!=undefined)
			{
				md = PIC.mod_id;
			} // if
			jQuery.post(this.post_cmnt, {ps_id: arr[5], ps_cnt: arr[6], ps_c: c, ps_m: m, ps_md: md}, function(data){DMW.$('komentarai').innerHTML = data; jQuery('#komentarai ul.tabline').dmwtabs(); if(DMW.$('fragment-1') && DMW.$('fragment-1')!=undefined){jQuery('#fragment-2').hide();}CMNT.shAn();});
		} // if
		jQuery('div#gallery span').html(text);
		if (jQuery(ob).attr('voted')=='1')
		{
			jQuery('div.tabcontent div.two div.stars0 div.stars').unbind('click');
			jQuery('div.tabcontent div.two div.stars0 div.stars').unbind('mousemove');
			jQuery('div.tabcontent div.two div.stars0 div.stars').css('cursor','auto');
			//PIC.rate=undefined
		}
		else
		{
			this.rateover();
			this.rateout();
			this.rateclick();
			jQuery('div.tabcontent div.two div.stars0 div.stars').css('cursor','pointer');					
		} // if
	},
	
	vph: function($phid) {},
	vg: function($gid) {},
	
	subfltr: function(form_id, action)
	{
		if (form_id!=undefined&&form_id)
		{
			if (action!=undefined&&action)
			{
				l = action.length;
				if (l>0)
				{
					if (action.substring(l-1,l)!='/')
					{
						action = action+'/';
					}
				}
				DMW.$(form_id).action=action;
			}
			DMW.$(form_id).submit();
		}
	}
} // PIC

SOC =
{
	share : function(url, title)
	{
		hrf_facebook = "http://www.facebook.com/sharer.php?u="+url+"&t="+title;
		hrf_twitter = "http://twitter.com/home?status="+title+"%20-%20"+url;
		var title_prefix = url.replace('http://', '');
		title_prefix = url.replace('http%3A%2F%2F', '');
		title_prefix = title_prefix.replace('www.', '');
		title_prefix = title_prefix.split('/');
		title_prefix = title_prefix[0].split('%2F');
		hrf_frype = 'http://www.frype.lt/say/ext/add.php?title=' + title + '&link=' + url + '&titlePrefix=' + title_prefix[0];
		jQuery('#left span.share a.facebook').attr('href', hrf_facebook);
		jQuery('#left span.share a.twitter').attr('href', hrf_twitter);
		jQuery('#left span.share a.frype').attr('href', hrf_frype);
	}
} // SOC

dmwScroll = 
{
	scrW : 0,
	scrThumbW : 111,
	scrDragW : 5,
	scrDragTime : 400,
	scrCnt : 5,
	scrStep : 0,
	scrFocus : 0,
	scrLast : null, // last active clicked
	scrFirstVisible : 0,
	scrCurrent : 0,
	scrGallery : null,
	ie6 : false,
	init : function (scrCurrent)
	{
		var kairen_png = new Image(); kairen_png.src = 'http://r.diena.lt/i/kairen.png';
		var desinen_png = new Image(); desinen_png.src = 'http://r.diena.lt/i/desinen.png';
		this.scrCurrent = parseInt(scrCurrent);
		$.scrollTo.defaults.axis = 'x';
		this.scrW = $('#gallery div.paging').width();
		this.scrStep = Math.floor(this.scrCnt / 2);
		this.scrFocus = Math.round(this.scrCnt / 2);
		this.scrLast = $('#gallery div.gallist ul li img.current')[0];
		this.scrGallery = $('#gallery div.gallist ul li');
		$('#gallery div.gallist ul').width(this.scrGallery.length * this.scrThumbW);
		if ($.browser.opera)
		{
			this.scrDragTime = 0;
		}
		if (this.scrGallery.length > this.scrCnt)
		{
			$('#gallery div.r a.kitas').bind('click', function(){ return dmwScroll.go2('f');})
			$('#gallery div.l a.ankstesnis').bind('click', function(){return dmwScroll.go2('b');});
			if (this.scrCurrent > (this.scrFocus - 1) && this.scrCurrent < (this.scrGallery.length - this.scrFocus))
			{
				this.scrFirstVisible = this.scrCurrent - (this.scrFocus - 1);
			}
			else if (this.scrCurrent > (this.scrGallery.length - this.scrFocus))
			{
				this.scrFirstVisible = this.scrGallery.length - this.scrCnt;
			}
			this.go2();
		}
		else
		{
			$('#gallery div.r a.kitas').hide();
			$('#gallery div.l a.ankstesnis').hide();
		}
		$('div.gallist ul li a').bind('click', function()
		{
			var imgobj = this.firstChild
			PIC.img2big(imgobj);
			if (dmwScroll.scrLast)
			{
				$(dmwScroll.scrLast).removeClass('current');
			}
			dmwScroll.scrLast = imgobj;
			$(dmwScroll.scrLast).addClass('current');
			if (dmwScroll.scrGallery.length > dmwScroll.scrCnt)
			{
				dmwScroll.scrCurrent = $('#gallery div.gallist ul li').index(this.parentNode);
				dmwScroll.go2();
			}
			return false;
		});
		if (jQuery.browser.msie) {
		if(6 >= parseInt(jQuery.browser.version))
			{
				this.ie6 = true;
			} // if
		} // if
//		$('#bigpic').bind('onload', function() { dmwScroll.lra(); });
		DMW.$('bigpic').onload = function() {  dmwScroll.lra(); };

	},
	getFirst : function(idx)
	{
		var go_to = this.scrFirstVisible;
		var step = this.scrStep;
		if (idx)
		{
			// by forward back
			go_to = this.scrFirstVisible + this.scrStep * ((idx == 'b') ? -1 : 1) ; 
		}
		else
		{
			// by clicks
			var diff = this.scrCurrent - this.scrFirstVisible;
			if (diff == 0)
			{
				step *= -1;
			}
			else if (diff == (this.scrFocus - 1))
			{
				step = 0
			}
			else if (diff > 0 && diff < (this.scrFocus - 1))
			{
				step = -1;
			}
			else if (diff > (this.scrFocus - 1) && diff < (this.scrCnt - 1))
			{
				step = 1;
			}
			go_to = this.scrFirstVisible + step;
		}
		if (go_to < 0)
		{
			go_to = 0;
		}
		else if (go_to >= (this.scrGallery.length - this.scrCnt))
		{
			go_to = this.scrGallery.length - this.scrCnt;
		}
		if (go_to != this.scrFirstVisible)
		{
			var ret = (go_to > this.scrFirstVisible) ? -1 : 1;
			this.scrFirstVisible = go_to;
			return ret;
		}
		return false;
	},
	go2 : function (idx)
	{
		var move = this.getFirst(idx);
		$('div.gallist').scrollTo(this.scrGallery[this.scrFirstVisible], this.scrDragTime);
		if (move && !$.browser.opera)
		{
			// drag
			$('div.gallist').scrollTo( ((move > 0) ? '+' : '-') + '=' + this.scrDragW + 'px', 50 );
			$('div.gallist').scrollTo( ((move > 0) ? '-' : '+') + '=' + this.scrDragW + 'px', 50 );
		}
		return false;
	},
	arrow_zone_width : function ()
	{
		//w = $('#bigpic').width();
		//w = Math.floor(w/4);
		//return w;
		return 150;
	},
	arrow_zone_height : function ()
	{
		h = $('#bigpic').height();		
		return h;
		return 399;
	},
	arrow_position_left : function ()
	{
		//arrow_width = 45;
		//w = $('#bigpic').width();
		//w = Math.floor(w/4);	
		//l = Math.floor((w/2)-(arrow_width/2));
		//if (l<0){l = 0;}		
		//return l;
		return 52;
	},
	arrow_position_top : function ()
	{
		//arrow_height = 42;
		//h = $('#bigpic').height();	
		//r = Math.floor((h/2)-(arrow_height/2));
		//if (r<0){r = 0;}
		//return r;
		return 178;
	},
	arrow_zones : function ()
	{
		$('div.l_arr').remove();
		$('div.r_arr').remove();
		$('#bigpic').after('<div class="r_arr" style="position:absolute;display:block;background:url(http://r.diena.lt/i/trans-big.gif);z-index:2;top:18px;right:35px;height:'+this.arrow_zone_height()+'px;width:'+this.arrow_zone_width()+'px;"></div>');
		$('#bigpic').after('<div class="l_arr" style="position:absolute;display:block;background:url(http://r.diena.lt/i/trans-big.gif);z-index:2;top:18px;left:35px;height:'+this.arrow_zone_height()+'px;width:'+this.arrow_zone_width()+'px;"></div>');
	},
	bind_arrow_events : function ()
	{
		$('#gallery div.l_arr').bind('mouseenter', 
			function(e)
			{
				if ($('img.current').parent().parent().prev().children().attr('href')!=undefined)
				{
					//$('#gallery div.l_arr').attr('title', 'Žiūrėti ankstesnę nuotrauką');
					if (dmwScroll.ie6)
					{
						$('#gallery div.l_arr').css('cursor', 'pointer, hand');
						$('#gallery div.l_arr').css('background', 'url(http://r.diena.lt/i/trans-big.gif) repeat');
						$('#gallery div.l_arr').append('<div class="l_arr_ie6" style="z-index:-1;position:absolute;top:'+dmwScroll.arrow_position_top()+'px;left:'+dmwScroll.arrow_position_left()+'px;width:45px;height:42px;"></div>');
						$('#gallery div.l_arr_ie6').css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src=\'http://r.diena.lt/i/kairen.png\')');
					}
					else
					{						
						$('#gallery div.l_arr').css('cursor', 'pointer');
						$('#gallery div.l_arr').css('background', 'url(http://r.diena.lt/i/kairen.png) no-repeat center');
					} // if
				} // if
			}
		);
		$('#gallery div.l_arr').bind('mouseleave', 
			function(e)
			{
				if (dmwScroll.ie6)
				{
					$('#gallery div.l_arr_ie6').remove();
				} // if
				$('#gallery div.l_arr').css('background', 'url(http://r.diena.lt/i/trans-big.gif) repeat');
				$('#gallery div.l_arr').css('cursor', '');
				$('#gallery div.l_arr').attr('title', '');
			}
		);
		$('#gallery div.l_arr').bind('click', 
			function(e)
			{
				cur_li = $('img.current').parent().parent();
				cur_li = cur_li.prev();
				cur_li.children().trigger('click');
				//dmwScroll.arrow_zones();
				//dmwScroll.bind_arrow_events();
				if ($('img.current').parent().parent().prev().children().attr('href')==undefined)
				{
					$('#gallery div.l_arr').trigger('mouseleave');
				}
			}
		);
		
		$('#gallery div.r_arr').bind('mouseenter', 
			function(e)
			{
				if ($('img.current').parent().parent().next().children().attr('href')!=undefined)
				{
					//$('#gallery div.r_arr').attr('title', 'Žiūrėti kitą nuotrauką');
					if (dmwScroll.ie6)
					{
						$('#gallery div.r_arr').css('cursor', 'pointer, hand');
						$('#gallery div.r_arr').css('background', 'url(http://r.diena.lt/i/trans-big.gif) repeat');
						$('#gallery div.r_arr').append('<div class="r_arr_ie6" style="z-index:-1;position:absolute;top:'+dmwScroll.arrow_position_top()+'px;right:'+dmwScroll.arrow_position_left()+'px;width:45px;height:42px;"></div>');
						$('#gallery div.r_arr_ie6').css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src=\'http://r.diena.lt/i/desinen.png\')');
					}
					else
					{
						$('#gallery div.r_arr').css('cursor', 'pointer');
						$('#gallery div.r_arr').css('background', 'url(http://r.diena.lt/i/desinen.png) no-repeat center');
					} // if
				} // if
			}
		);
		$('#gallery div.r_arr').bind('mouseleave', 
			function(e)
			{
				if (dmwScroll.ie6)
				{
					$('#gallery div.r_arr_ie6').remove();
				} // if
				$('#gallery div.r_arr').css('background', 'url(http://r.diena.lt/i/trans-big.gif) repeat');
				$('#gallery div.r_arr').css('cursor', '');
				$('#gallery div.r_arr').attr('title', '');
			}
		);
		$('#gallery div.r_arr').bind('click', 
			function(e)
			{
				cur_li = $('img.current').parent().parent();
				cur_li = cur_li.next();
				cur_li.children().trigger('click');
				//dmwScroll.arrow_zones();
				//dmwScroll.bind_arrow_events();
				if ($('img.current').parent().parent().next().children().attr('href')==undefined)
				{
					$('#gallery div.r_arr').trigger('mouseleave');
				}
			}
		);
	},
	lra : function () // left and right arrows
	{
		if (!DMW.$('bigpic')||DMW.$('bigpic')==undefined)
		{
			return false;
		} // if
			
		$('#gallery').css('position','relative');
		this.arrow_zones();	
		this.bind_arrow_events();
	} // function 
} // dmwScroll
