
function writeFlash(movieLocation,width,height){
  document.write('<object id="flashmast" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+movieLocation+'" /><param NAME="wmode" VALUE="transparent"><param name="quality" value="high" /><embed id="flashembed" src="'+movieLocation+'" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="'+width+'" height="'+height+'"></embed></object>');
}

//var address = "http://localhost/daigera/";
var address = "http://www.daigera.lt/";


function echeck() {
	
	var neisvesti_duomenys = document.getElementById('no_data').value;
	var blogas_el_pastas = document.getElementById('no_email').value;
	
	if (document.getElementById('title'))
		var bloga_tema = document.getElementById('no_title').value;

		if (document.getElementById('name').value.length == 0  || document.getElementById('email').value.length == 0 || document.getElementById('text').value.length == 0 || ( document.getElementById('title') && document.getElementById('title').value.length == 0) ){
			alert(neisvesti_duomenys);
			return false;
		}
		
		
		if ( check_mail('email', blogas_el_pastas) )
			var form = document.getElementById('send_query');		
			form.submit();		
	
	}
	
function check_mail(email, blogas_el_pastas){
	
		str = document.getElementById(email).value;
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert(blogas_el_pastas)
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(blogas_el_pastas)
		   return false
		}
		
		
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(blogas_el_pastas)
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(blogas_el_pastas)
		    return false
		 }
		 
		

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(blogas_el_pastas)
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(blogas_el_pastas)
		    return false
		 }
		 
		
		 if (str.indexOf(" ")!=-1){
		    alert(blogas_el_pastas)
		    return false
		 }
		 
		 mas = str.split('.')		 
		 galune = mas[mas.length-1];
		 if (galune==""){
		 	 alert(blogas_el_pastas)
			 return false;
		 }
		 
		 return true;
	
}

/*function active_top_items(name){
	document.getElementById(name).style.backgroundImage="url('"+address+"img/"+name+"_active.gif')";
}
function not_active_top_items(name){
	document.getElementById(name).style.backgroundImage="url('"+address+"img/"+name+"_not_active.gif')";
}

function active_top_items_mail(name){
	document.getElementById(name).src=address+"img/"+name+"_active.gif";
}

function not_active_top_items_mail(name){
	document.getElementById(name).src=address+"img/"+name+"_not_active.gif";
}
*/


function print_active(){
	document.getElementById('printas').src=address+'img/print_active.gif';
	document.getElementById('printas_a').style.color="#F47D1F";
	document.getElementById('printas_a').style.textDecoration="underline";
}

function print_not_active(){
	document.getElementById('printas').src=address+'img/print_not_active.gif';
	document.getElementById('printas_a').style.color="#718A8F";
	document.getElementById('printas_a').style.textDecoration="none";
}


function active_meniu(id){
	
	document.getElementById('td_'+id).style.backgroundImage="url('"+address+"img/arrow_active.gif')";
	
}
function not_active_meniu(id, i){
	
	if (!i)
		document.getElementById('td_'+id).style.backgroundImage="url('"+address+"img/arrow_not_active.gif')";

}

function active_m(el){
		document.getElementById(el).src=address+"img/"+el+"_active.jpg";
}

function not_active_m(el){
		document.getElementById(el).src=address+"img/"+el+"_not_active.jpg";
}

function clearFields(){
		document.getElementById('name').value="";
		document.getElementById('email').value="";
		document.getElementById('text').value="";
		
		if (document.getElementById('title'))
			document.getElementById('title').value="";
}

function active_button(id){
	if (id==1){
		document.getElementById('sbm').style.backgroundImage="url('"+address+"img/button-active.gif')";
	}
	else
		document.getElementById('res').style.backgroundImage="url('"+address+"img/button-active.gif')";

}
function not_active_button(id){
	if (id==1){
		document.getElementById('sbm').style.backgroundImage="url('"+address+"img/button-not-active.gif')";
	}
	else
		document.getElementById('res').style.backgroundImage="url('"+address+"img/button-not-active.gif')";

}

function go_banner (id, unique_id, url, clicked){
	
	//tipo paspaude
	var imgas = new Image();
	imgas.src = address+'banner.php?id='+id+'&unique_id='+unique_id+'&clicked='+clicked;
	
	window.open(url,'_blank');
}

function active_lang(lng){
		document.getElementById('lang_'+lng).style.backgroundImage="url('"+address+"img/lang_rodykle.gif')";
}

function deactive_lang(lng){
		document.getElementById('lang_'+lng).style.backgroundImage="url('"+address+"img/lang_rodykle_hide.jpg')";
}


// JavaScript Document

var SiteUrl = "http://www.daigera.lt/home.php?lng=LT&id=283&seo=0";

function OnMenuOver (obj)
{
    var ObjectSrc, HoverExpression, DotExpression, SearchCheck;
    ObjectSrc = obj.src;
    HoverExpression = /Hover\.jpg/i;
    DotExpression = /\.jpg/;
    SearchCheck = ObjectSrc.search(HoverExpression);
    if (SearchCheck != -1)
    {
        obj.src = ObjectSrc.replace(HoverExpression, '.jpg');
        
    }
    else
    {
        obj.src = ObjectSrc.replace(DotExpression, 'Hover.jpg');
    }
}


function reload_filter(obj)
{
    var filter_block = document.getElementById('filter_block');
    var filter_loader = document.getElementById('filter_loader');
    filter_block.style.display = "none";
    filter_loader.style.display = "";
    var values = xajax.getFormValues('filter');
    var name = '';
    if (obj) name = obj.name;
    reload_filter_all(values, name, tarp_vars);
}
    function win(page,wid,hit)
        {
        var  windo=eval('window.open("'+page+'","","status=no,toolbar=no,resizable=yes,scrollbars=yes,menubar=no,width='+wid+',height='+hit+',top=100,left=100")');
        }
        
        
function ShowPrintVersion(state) {

    if (state == true) {
    
        $('#cart_printer').css('display', ''); 
        $('#main-wrap').css('display', 'none');
        $('#bodyTag').removeClass('bodybg');
        $('#bodyTag').addClass('printBodyBg');
        
    } else {
        
        $('#cart_printer').css('display', 'none'); 
        $('#main-wrap').css('display', '');
        $('#bodyTag').removeClass('printBodyBg');
        $('#bodyTag').addClass('bodybg');
    
    }

}



function olodas(){
				
			var apvalus=document.getElementsByTagName("td");
			
			
			for( var i=0; i<apvalus.length; i++){
				
				if (apvalus[i].id.substr(0,7) == 'apvalus'){
				
					//jeigu yra aktyvus, nurodom kita backgruonda
					id  = apvalus[i].id.length;
					active = apvalus[i].id.substr(id-6,id);
					
				
					if (browser == 'IE'){
					
						if (active == 'active'){
							apvalus[i].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/apvalus_active.png' + suffix + '', sizingMethod='crop'), ;";
						}
						else{
							apvalus[i].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/apvalus.png' + suffix + '', sizingMethod='crop'), ;";
						}
						
					}
					
					
					else{
						if (active == 'active'){
							apvalus[i].style.backgroundImage = 'url({$real_adress}img/apvalus_active.png)';	
						}
						else{
							apvalus[i].style.backgroundImage = 'url({$real_adress}img/apvalus.png)';
						}
					}
					
				}
			}
			
			//up, down, spausdinti
			if (browser == 'IE'){
				document.getElementById('back_button').style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/back.png' + suffix + '', sizingMethod='crop'), ;";
				document.getElementById('up_page').style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/up_page.png' + suffix + '', sizingMethod='crop'), ;";
				document.getElementById('printas').style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/print.png' + suffix + '', sizingMethod='crop'), ;";
		
			}
			else{
				document.getElementById('back_button').style.backgroundImage = 'url({$real_adress}img/back.png)';
				
				document.getElementById('up_page').style.backgroundImage = 'url({$real_adress}img/up_page.png)';
				
				document.getElementById('printas').style.backgroundImage = 'url({$real_adress}img/print.png)';
				
			}
			
			//cia bendrai
			document.getElementById('back_button').style.backgroundRepeat = 'no-repeat';
			document.getElementById('up_page').style.backgroundRepeat = 'no-repeat';
			document.getElementById('printas').style.backgroundRepeat = 'no-repeat';
			
			
			/*document.getElementById('back_button').style.backgroundPosition = '0px 3px';
			
			document.getElementById('up_page').style.backgroundRepeat = 'no-repeat';
			document.getElementById('up_page').style.backgroundPosition = '0px 3px';
			
			document.getElementById('up_page').style.backgroundRepeat = 'no-repeat';*/
			
			
		}
		
		function active_apvalus(td_image){
			var td = document.getElementById("apvalus_"+td_image);
			
			if (td){
				if (browser == 'IE'){
					td.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/apvalus_active_not_selected.png' + suffix + '', sizingMethod='crop'), ;";
				}
				else{
					td.style.backgroundImage = 'url({$real_adress}img/apvalus_active_not_selected.png)';
				}
			}
		}
		
		function not_active_apvalus(td_image){
			var td = document.getElementById("apvalus_"+td_image);
			
			if (browser == 'IE'){
				td.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$real_adress}img/apvalus.png' + suffix + '', sizingMethod='crop'), ;";
			}
			else{
				td.style.backgroundImage = 'url({$real_adress}img/apvalus.png)';
			}
		}
		
		function win(page,wid,hit)
			{
			var  windo=eval('window.open("'+page+'","","status=no,toolbar=no,resizable=yes,scrollbars=yes,menubar=no,width='+wid+',height='+hit+',top=100,left=100")');
			}
			
		function reload_filter(obj)
			{
			var filter_block = document.getElementById('filter_block');
			var filter_loader = document.getElementById('filter_loader');
			filter_block.style.display = "none";
			filter_loader.style.display = "";
			var values = xajax.getFormValues('filter');
			var name = '';
			if (obj) name = obj.name;
			xajax_reload_filter_all(values, name, tarp_vars);
			}