a=function(data,mode){var ajax_data=null;if(mode==null||mode!=true)var mode=false;if(window.XMLHttpRequest)xmlhttp=new XMLHttpRequest;else if(window.ActiveXObject)xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");xmlhttp.open('POST','/'+sys_lang+'/ajax/',mode);xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){ajax_data=xmlhttp.responseText;}}};xmlhttp.send(data);return xmlhttp.responseText;};
loadXML=function(txt){try{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(txt);return(xmlDoc);}catch(e){try{parser=new DOMParser();xmlDoc=parser.parseFromString(txt,"text/xml");return(xmlDoc);}catch(e){}}return(null)};
trim=function(str, chars) {return ltrim(rtrim(str, chars), chars);};
ltrim=function(str, chars) {chars = chars || "\\s";return str.replace(new RegExp("^[" + chars + "]+", "g"), "");};
rtrim=function(str, chars) {chars = chars || "\\s";return str.replace(new RegExp("[" + chars + "]+$", "g"), "");};
urldecode=function(str){var histogram={},histogram_r={},code=0,str_tmp=[];var ret=str.toString();var replacer=function(search,replace,str){var tmp_arr=[];tmp_arr=str.split(search);return tmp_arr.join(replace);};histogram['!']='%21';histogram['%20']='+';for(replace in histogram){search=histogram[replace];ret=replacer(search,replace,ret);}ret=decodeURIComponent(ret);return ret;};
urlencode=function(str){string=encodeURIComponent(str).replace(/~/g,'%7E');return string.replace(/%20/g,'+');};
isMail=function(str){var filter=/^.+@.+\..{2,3}$/; return filter.test(str)};
opener=function(url,w,h){var l=(screen.width-w)/2;var t=(screen.height-h)/2;window.open(url,'','height='+h+',width='+w+',top='+t+',left='+l+',scrollbars=no,resizable=no,location=no,directories=no,status=no,menubar=no,toolbar=no')};
ga=function(obj,attr){return urldecode(obj.getAttribute(attr))};
array_search=function(needle,haystack,argStrict){var strict=!!argStrict;var key='';for(key in haystack){if((strict&&haystack[key]===needle)||(!strict&&haystack[key]==needle)){return key;}}return false};
/*
$(document).ready(function(){

	

	$('.main-menu').css({'padding-right':($(document).width()-970)/2});
	$('.submenu>a').each(function(){
		$(this).click(function(e){
			e.preventDefault();
			var ul=$('.submenu>ul[rel='+$(this).parent().attr('rel')+']');
			if($(ul).css('display')=='none'){
				$(ul).slideDown();
				$('.submenu>ul').not(ul).not($(ul).parent().parent()).slideUp();
				
			}else{
				$(ul).slideUp();
			}
		});
	});
	
	//$('.target').attr({'target':'_blank'});
	if(/Mozilla/.test(navigator.userAgent)){$('.footer').css({'margin-top':'-40px'});}
	$('.lang').hover(
		function(){if(!/act/.test($(this).attr('className'))){$(this).addClass('act').animate({'height':'43px'},200)}},
		function(){if(/act/.test($(this).attr('className'))){$(this).animate({'height':'14px'},200,function(){$(this).removeClass('act')})}});
	$('.email').each(function(){
		var t=$(this).text().replace('(abols)','@');
		$(this).text(t).attr('href','mailto:'+t)});
	
	switch(page){
	case 'gallery':
		$(".product").fancybox();
	break;
	case 'home':
		$(".product").fancybox();
	break;
	case 'contacts':
		$('input[type=text], textarea')
			.focus(function(){if($(this).val()==$(this).attr('rel')){$(this).val('')}$(this).addClass('focused')})
			.blur(function(){
				if($(this).val()==''){$(this).val($(this).attr('rel'))}
				if($(this).val()==$(this).attr('rel')){$(this).removeClass('focused')}
			});
		$('#contacts').submit(function(e){
			$('.message, .success').hide();
			if($('#ff1').val()==$('#ff1').attr('rel')||$('#ff1').val()==''){$('#contacts>.foot>.message').show();e.preventDefault();$('#ff1').focus();return false}
			if($('#ff2').val()==$('#ff2').attr('rel')||$('#ff2').val()==''){$('#contacts>.foot>.message').show();e.preventDefault();$('#ff2').focus();return false}
			if(!isMail($('#ff3').val())){$('#contacts>.foot>.message').show();e.preventDefault();$('#ff3').focus();return false}
			if($('#ff4').val()==$('#ff4').attr('rel')||$('#ff4').val()==''){$('#contacts>.foot>.message').show();e.preventDefault();$('#ff4').focus();return false}
		});
		$("#ff4").autogrow();
	break;
	}
	
});

$(document).ready(function(){
	$('.pogas').bind('mouseover',function(){
		var o=$(this).offset();
		$('.ieksa').css({'left':o.left-23});
		$('.goo').css({});
	});								
});

var smallPost=0;
var loadXML=function(txt){
	try{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");    
		xmlDoc.async="false";
		xmlDoc.loadXML(txt);
		return(xmlDoc);
	}catch(e){
		try{
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(txt,"text/xml");
			return(xmlDoc);
		}catch(e){}
	}
	return(null);
};

var getTabName=function(){return String(location.hash.replace('#','')).replace(new RegExp('/',"gi"),'-')};
var tab=function(rel){

	if(!$('.panel[rel='+rel+']').size()){
	
	$('.panel').css({"visibility":"visible"});
		$('<div class="panel" rel="'+rel+'"></div>').appendTo('.paneltop');
		$('.panel').css({"visibility":"visible"});
		$('.panel').not('.panel[rel='+rel+']').css({'visibility':'hidden'}).slideUp(function(){
			$('.goo').slideUp('fast');
			$('#bgimg,.exit,.exit2,#popupContactClose,popupContactClose').click(function(){
			$('.panel').css({"visibility":"hidden"});
			});
		});
		return [0,'.panel[rel='+rel+']'];
	}else{
		$('.panel').not('.panel[rel='+rel+']').css({'visibility':'hidden'}).slideUp(function(){
			$('.panel[rel='+rel+']').css({'visibility':'visible','display':''}).slideDown('fast');
		});
		return [1,'.panel[rel='+rel+']'];
	}
};

var loadContent=function(){
	var h=location.hash.replace('#',''); 
	if(!h.length) return false;
	if(h==55) return false;
	if(h=='undefined') return false;
	var t=tab(getTabName());
	if(!t[0]){
		
		$.post(
			h,
			{act:'loadContent',small:smallPost},
			function(r){
				smallPost=0;
				var r=loadXML(r);
				var text=$(r).find('text').text();
				var title=$(r).find('title').text();
				try{$('title').text(title);}catch(e){}
				$(t[1]).html(text);
				
				$(t[1]).find('a').not('.no-rewrite').click(function(e){
					if($(this).attr('href')!='#' && String($(this).attr('href')).substr(0,7)!='http://'){
						e.preventDefault();
						smallPost=/post-small/.test($(this).attr('className'))?1:0;
						location.hash=$(this).attr('href');          
					}
					if(String($(this).attr('href')).substr(0,7)=='http://'){
						$(this).attr('target','black');
					}
				});
			},
			'html'
		)
	}else{
		$(t[1]).css({'display':''});                                                           
		$(t[1]).find('.panel').css({'display':''});	
	}	
};

$(document).ready(function(){
	$('a').not('.no-rewrite').click(function(e){
		location.hash=$(this).attr('href');
		e.preventDefault();
	});
	$(function(){
		$(window).hashchange(function(){loadContent()});
		$(window).hashchange();
	});
	$('#bgimg,.exit,.visi').click(function(){
		$('.panel').slideUp('fast').css({'visibility':'hidden','display':'none'});
	});

});
		$(document).ready(function(){					
			var browserName=navigator.appName; 
			if (browserName=="Microsoft Internet Explorer") {
				$('.btn-slides').css({'padding':'21px 1px 0px 0px'});				
			} else if (browserName=="Opera") {
				$('.btn-slides').css({'padding':'21px 1px 0px 0px'});
			}
		});	

		
		function loadContent(id){
			$('.panel').not('#panel'+id).slideUp('slow', function(){
			$('#panel'+id).slideDown();
			});				
		}
		$(document).ready(function(){var id=location.hash.replace('#',''); 
		if(id!=null&&id==parseFloat(id)){
		loadContent(id);}})
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-galerija.swf", "noFlash2", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-izstade.swf", "noFlash1", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-mani-draugi.swf", "noFlash4", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/kontakti.jpg", "noFlash8", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);

		
		var flashvars3 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-sakumlapa.swf", "noFlash3", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars3, params, attributes,resize);
	
	
		var flashvars5 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-mes-piedavajam.swf", "noFlash5", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars5, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-vesture.swf", "noFlash6", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);

		
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-default.swf", "noFlash7", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);

		
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-mes-piedavajam.swf", "noFlash10", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/seminari.jpg", "noFlash11", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-mes-piedavajam.swf", "noFlash12", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-mes-piedavajam.swf", "noFlash13", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
	
		var flashvars6 = {};
		var params = {};
		params.play = "true";
		params.loop = "true";
		params.menu = "false";
		params.quality = "high";
		params.scale = "noborder";
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "flashContent";
		attributes.name = "flash";
		attributes.salign = "top";
		swfobject.embedSWF("/img/rm-mes-piedavajam.swf", "noFlash14", "100%", "100%", "8.0.24", "/img/expressInstall.swf", flashvars6, params, attributes,resize);
	
		test=function(){
			$('.panel').slideUp();
		};
		reloadContain = function(){
			var id=0; //String(location.hash).replace('#',''); 
			$('.panel').not('#panel'+id).slideUp('slow', function(){
				$('#panel'+id).slideDown();
			});
		};
	
		$(document).ready(function(){
			$(".poga").click(function(){
				var id=$(this).attr('rel');
				$('.panel').not('#panel'+id).slideUp('slow', function(){
					$('#panel'+id).slideDown('slow');
				});
			});
			$('#bgimg,.exit,.exit2,#popupContactClose').click(function(){
				$('#'+$(this).attr('id')).slideUp();
				$('.panel').css({'visibility':'hidden'});
			});
			$('#panel').css({'visibility':'visible'});
			reloadContain();
		});
	
		// copyright poga un panelis 
		$(document).ready(function(){
			$(".ccc").click(function(){
				var id=55;
						
				$('.panel').not('#panel'+id).slideUp('fast', function(){
					$('#panel'+id).css({'visibility':'visible'}).slideDown('fast');
					$('.graftik').css({'visibility':'visible'});
				});
			});
			$('#bgimg, .exit, #flashContent,.visi').click(function(){
					$('.graftik').css({'visibility':'hidden'});
				$('.panel').slideUp('fast');
			
			})
			$('#panel').css({'visibility':'hidden'});
			reloadContain();
		});
				
		tes=function(){
		$('.go').slideUp();
		};					
		reloadContains = function(){
			var id=0; 
			$('.goo').not('#go'+id).hide('slow', function(){
				$('#go'+id).slideDown().css({"display":"table","visibility":"visible"});
				$('.goo').css({"visibility":"visible"});
					$('.saraksts').show();
			});
		};

		$(document).ready(function(){
			$(".pogas").mouseover(function(){
			$('.goo').css({"display":""});
				var id=$(this).attr('rel');
				$('.goo').not('#go'+id).hide(function(){
				$('.goo').css({"visibility":"visible"});
					$('#go'+id).show();
					
				});
			});
			$("#bgimg,.panel,#panel,.poga,.afterpanel2,.lielais,.body,.visi").mouseover(function(){
				$('.goo').css({"visibility":"hidden"});
			});
			
			reloadContains();
		});

	
		function loadPopup(){
			$("#backgroundPopup").css({"opacity": "0"});
			$("#popupContact").show();
		}

		function disablePopup(){
			$("#backgroundPopup").fadeOut("slow");
			$("#popupContact").fadeOut("medium");
		}
		function centerPopup(){
			var windowWidth = document.documentElement.clientWidth;
			var windowHeight = document.documentElement.clientHeight;
			var popupHeight = $("#popupContact").height();
			var popupWidth = $("#popupContact").width();
			$("#popupContact").css({"position": "absolute","top": windowHeight/1.3-popupHeight/1.3,"left": windowWidth/7.5-popupWidth/3});
			$("#backgroundPopup").css({"height": windowHeight});
		}
			
		$(document).ready(function(){
			$("#btn").click(function(){
				littlePopup();
				centerPopup();
				loadPopup();
			});
			
			
			$("#popupContactClose, .panel, .paneltop, #bgimg,.poga").click(function(){
				disablePopup();                            
			});
			centerPopup();                               
			loadPopup();
			$(document).keypress(function(e){
				if(e.keyCode==27){
					disablePopup();
				}
			});
		});
	

	

		var FullscreenrOptions = {  width: 1280, height: 1300, bgID: '#bgimg' };
		// This will activate the full screen background!
		jQuery.fn.fullscreenr(FullscreenrOptions);

		
		$(document).ready(function() {
			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
		});
*/


//$('#content').html('<h1>Title</h1><p>lorem</p>');

function rebindClose() {
	$('.close').unbind('click');
	$('.close').click(function(e){
		$('#content').fadeOut('slow');
		e.preventDefault();
	});
}


var smallPost=0;
var loadContent=function(){
	var h=location.hash.replace('#',''); 
	if(!h.length) return false;
	if(h==55) return false;
	if(h=='undefined') return false;
	$.post(
		h,
		{act:'loadContent',small:smallPost},
		function(r){
			smallPost=0;
			var r=loadXML(r);
			var text=$(r).find('text').text();
			var title = decodeURIComponent(($(r).find('title').text() + '').replace(/\+/g, '%20')).replace('&Uuml;','Ü');
			
			try{$('title').text(title);}catch(e){				
				document.title = title;
			}
			text = '<a href="#" class="close"></a>'+text;
			$('#content').html(text);
			
			/*
			$('#content').find('.thumbs').click(function(e){
				location.hash=$(this).attr('href');
				e.preventDefault();
			});
			*/
	
			$('#content').fadeIn();
			rebindClose();
			// ---<--- change background image
			var background = $(r).find('background').text();
			var bg1IsVisible = $('#bgimg1').css('display');
			if(bg1IsVisible == 'block') {
				$('#bgimg2').attr('src','/img/backgrounds/'+background);
				var bg1Img = $('#bgimg1').attr('src');
				var bg2Img = $('#bgimg2').attr('src');
				if(bg1Img != bg2Img) {
					$('#bgimg1').fadeOut('slow');
					$('#bgimg2').fadeIn('slow');
				}
			} else {
				$('#bgimg1').attr('src','/img/backgrounds/'+background);
				var bg1Img = $('#bgimg1').attr('src');
				var bg2Img = $('#bgimg2').attr('src');
				if(bg1Img != bg2Img) {
					$('#bgimg2').fadeOut('slow');
					$('#bgimg1').fadeIn('slow');
				}
			}
				
			// --->--- change background image
			$('#content').find('a').not('.no-rewrite').click(function(e){
				if($(this).attr('href')!='#' && String($(this).attr('href')).substr(0,7)!='http://'){
					e.preventDefault();
					smallPost=/post-small/.test($(this).attr('className'))?1:0;
					location.hash=$(this).attr('href');          
				}
				if(String($(this).attr('href')).substr(0,7)=='http://'){
					$(this).attr('target','black');
				}
			});
			
			$("a[rel=gallery]").fancybox();
		},
		'html'
	)
	
};

$(document).ready(function() {
	// ---<--- fancybox
	$("a[rel=gallery]").fancybox();
	// --->--- fancybox
	// ---<--- hashchange
	$('a').not('.no-rewrite').click(function(e){
		location.hash=$(this).attr('href');
		e.preventDefault();
	});
	$(function(){
		$(window).hashchange(function(){loadContent()});
		$(window).hashchange();
	});
	var id=location.hash.replace('#',''); 
	if(id!=null&&id==parseFloat(id)){
		loadContent(id);
	}
	/*
	*/
	// --->--- hashchange
	// ---<--- fullscreener
	var FullscreenrOptions = {width: 1920, height: 1200, bgID:'#bgimg1'};
	jQuery.fn.fullscreenr(FullscreenrOptions);
	var FullscreenrOptions = {width: 1920, height: 1200, bgID:'#bgimg2'};
	jQuery.fn.fullscreenr(FullscreenrOptions);
	// --->--- fullscreener
	// ---<--- sub menu
	$('.main-menu a').click(function(e){
		$('#welcome').fadeOut();
		$('.sub-menu').hide();
		var link = $(this).attr('href');
		if(link == '#') {
			$('#welcome').fadeOut();
			$('#content').fadeOut();
			var submenu = $(this).parent().find('.sub-menu');
			$(submenu).fadeIn('fast');
			e.preventDefault();
		} 
	});
	// --->--- sub menu
	rebindClose();
	$('.hide').click(function(e){
		$('#welcome').fadeOut();
		e.preventDefault();
	});
	
	$('bgimg').click(function(e){
		$('#welcome').fadeOut();
		$('#content').fadeOut();
		e.preventDefault();
	});
	
	// ---<--- copyright
		$('.copyright').click(function(e){
			$('#content').fadeOut();
			$('#content').html('<a href="#" class="close"></a><p>© 2012 Visas tiesības paturētas. Mājas lapas izstrāde: <a href="http://www.graftik.lv">Graftik</a></p>');
			$('#content').fadeIn();
			rebindClose();
			e.preventDefault();
		});
	// ---<--- copyright
	// ---<--- image preloading
	jQuery.preLoadImages(
		"/img/backgrounds/atslega.jpg",
		"/img/backgrounds/meitene-ar-laci.jpg",
		"/img/backgrounds/meitene-pie-klavierem.jpg",
		"/img/backgrounds/meitene-pie-loga.jpg",
		"/img/backgrounds/mura-varti.jpg",
		"/img/backgrounds/sieviete-pie-durvim.jpg",
		"/img/backgrounds/vinila-plate.jpg",
		"/img/backgrounds/zalie-kebli.jpg"
	);
	// --->--- image preloading
	
});


// ---<--- img preload function
(function($) {
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {	  
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
	  document.getElementById('preloader').appendChild(cacheImage);
    }
  }
})(jQuery)
// --->--- img preload function

