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','/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;};
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,'+');};
validateContactForm=function(){
	var f1=document.getElementById('ff1');
	var f2=document.getElementById('ff2');
	var f4=document.getElementById('ff4');
	if(trim(f1.value)==''){alert('Nav norādīts vārds');$(f1).focus(); return false;}
	apos=f2.value.indexOf("@");
	dotpos=f2.value.lastIndexOf(".");
	if((apos<1||dotpos-apos<2)){alert('Nav norādīts e-pasts');$(f2).focus(); return false;}
	if(f4.value==''){alert('Nav norādīts teksts');$(f4).focus(); return false;}
	return true;
};
validateOrderForm=function(){
	var f1=document.getElementById('ff1');
	var f2=document.getElementById('ff2');
	var f4=document.getElementById('ff4');
	if(trim(f1.value)==''){alert('Nav norādīts vārds');$(f1).focus(); return false;}
	if(trim(f4.value)==''){alert('Nav norādīts uzvārds');$(f4).focus(); return false;}
	apos=f2.value.indexOf("@");
	dotpos=f2.value.lastIndexOf(".");
	if((apos<1||dotpos-apos<2)){alert('Nav norādīts e-pasts');$(f2).focus(); return false;}
	return true;
};
initMenu=function(){
	$('.submenu').each(function(){var w=$(this.parentNode).width();$(this).css({'width':w});});
	$('.smbm').each(function(){var w=$(this.parentNode).width()-36;$(this).css({'width':w});});
	$('.mmi').hover(function(){var id=$(this).attr('id').replace('mi','');$('#sm'+id).show();},function(){var id=$(this).attr('id').replace('mi','');$('#sm'+id).hide();});
	$('.submenu').css({'visibility':'visible','display':'none'});
	$('.submenu').each(function(){var o=$(this.parentNode).offset();$(this).css({'left':o.left});});
};
subscribeNews=function(){
	var v=trim($('#mail').val());
	apos=v.indexOf("@");
	dotpos=v.lastIndexOf(".");
	if((apos<1||dotpos-apos<2)){
		alert('Lūdzu norādiet pareizu e-pasta adresi');
		$('#mail').focus();
		return false;
	}else{
		var r=a('act=isEmailFree&mail='+urlencode(v));
		if(r=='0'){
			alert('Šī e-pasta adrese jau ir sarakstā!');
			$('#mail').focus();
			return false;
		}else{
			$('#mail').val($('#mail').attr('rel')).blur();
			alert(r);
			return false;
		}
	}
	return false;
}
$(document).ready(function(){
	$('.target').attr({'target':'_blank'});
	$('.border:first').height($('#catalog').height()+18);
	
	$('#mail').focus(function(){if($(this).val()==$(this).attr('rel')){$(this).val('');}});
	$('#mail').blur(function(){if($(this).val()==''){$(this).val($(this).attr('rel'));}});
	if($('.body>.left:first').height()>$('.center:first').height()){
		$('.center:first').height($('.body>.left:first').height());
	}
	$('#print').click(function(){
		var bolWebPartFound = false;
		if(document.getElementById != null){
			var PrintingHTML = '<HTML>\n<HEAD>\n';
			if (document.getElementsByTagName != null){var HeadData= document.getElementsByTagName("HEAD");if (HeadData.length>0){PrintingHTML += HeadData[0].innerHTML;}}
			PrintingHTML += '\n</HEAD>\n<BODY style="background: #FFFFFF; text-align: left;" onload="print()">\n';
			var WebPartData = document.getElementById('printableContent');
			if (WebPartData != null){PrintingHTML += WebPartData.innerHTML;bolWebPartFound = true;}else{bolWebPartFound = false;alert ('Cannot Find Web Part');}
		}
		PrintingHTML += '\n</BODY>\n</HTML>';
		if(bolWebPartFound){
			var size_x = 800;
			var size_y = 600;
			LeftPosition = (screen.width) ? (screen.width-size_x)/2 : 0;
			TopPosition = (screen.height) ? (screen.height-size_y)/2 : 0;
			var msgWindow = window.open("about:blank", "PrintWebPart", "width=800,height=600, top="+TopPosition+", left="+LeftPosition+", resizable=no, status=no, toolbar=no, menubar=no, scrollbars=yes ");
			if(msgWindow != null){var doc = msgWindow.document.open('text/html', 'replace' );doc.write(PrintingHTML);doc.close();}
		}
	});
	$('.subm>a').click(function(){
		if(/opened/.test($(this.parentNode).attr('className'))){$(this.parentNode).removeClass('opened');} else {$(this.parentNode).addClass('opened');}
		$('.border:first').height($('#catalog').height()+18);
		return false;});
	if(/Opera/.test(navigator.userAgent)){
		$('#mail').css({'padding-left':'4px'});
	}
	$('.go-back').click(function(){if($(this).attr('href')=='#'){history.go(-1)}});
	setTimeout('initMenu()', 700);
});





