
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="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/birzuduona/";
var address = "http://www.fibiura.lt";


function echeck() {
	
	var neisvesti_duomenys = document.getElementById('no_data').value;
	var blogas_el_pastas = document.getElementById('no_email').value;

		if (document.getElementById('name').value.length == 0  || document.getElementById('email').value.length == 0 || document.getElementById('text').value.length == 0){
			alert(neisvesti_duomenys);
			return false;
		}
		
		
		if ( check_mail('email', blogas_el_pastas) )
			var form = document.getElementById('send_query');		
			form.submit();		
	
}
	
function checkkarjera(){
	
	var neisvesti_duomenys = document.getElementById('no_data').value;
	var blogas_el_pastas = document.getElementById('no_email').value;
	var blogas_adresas = document.getElementById('no_address').value;
	var blogas_failas = document.getElementById('no_file').value;

	if (document.getElementById('name').value.length == 0  || document.getElementById('email').value.length == 0  || document.getElementById('adress').value.length == 0){
		alert(neisvesti_duomenys);
		return false;
	}
		
	
	
	if ( !check_mail('email', blogas_el_pastas) ){
		return false;
	}
	
	//tikrini ar nurodyti tikrai failai
	if ( !LimitAttach(document.getElementById('cv').value) || !LimitAttach(document.getElementById('motivation_letter').value) ){
		alert(blogas_failas);
		return false;
	}
	
	var form = document.getElementById('send_query');		
	form.submit();
		
}

//galimi failu pletiniai
//ir is open offico

extArray = new Array(".doc", ".txt", ".rtf", ".pdf", ".html", ".htm", ".xls", ".ppt", ".odt", ".odp", ".ods");

function LimitAttach(file) {
	allowSubmit = false;
	if (!file) 
		return;
	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		
	ext = file.slice(file.indexOf(".")).toLowerCase();

	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { 
			allowSubmit = true; break; 
		}
	}
	
	return allowSubmit;
}




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.gif";
}

function not_active_m(el){
		document.getElementById(el).src=address+"img/"+el+"_not_active.gif";
}

function clearFields(){
		document.getElementById('name').value="";
		document.getElementById('email').value="";
		document.getElementById('text').value="";
}


function clearFieldsKarjera(){
		document.getElementById('name').value="";
		document.getElementById('email').value="";
		document.getElementById('adress').value="";
		document.getElementById('cv').value="";
		document.getElementById('motivation_letter').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')";
}


function checkkarjera(){
	
	var neisvesti_duomenys = document.getElementById('no_data').value;
	var blogas_el_pastas = document.getElementById('no_email').value;
	var blogas_adresas = document.getElementById('no_address').value;
	var blogas_failas = document.getElementById('no_file').value;

	if (document.getElementById('name').value.length == 0  || document.getElementById('email').value.length == 0  || document.getElementById('adress').value.length == 0){
		alert(neisvesti_duomenys);
		return false;
	}
		
	
	
	if ( !check_mail('email', blogas_el_pastas) ){
		return false;
	}
	
	//tikrini ar nurodyti tikrai failai
	if ( !LimitAttach(document.getElementById('cv').value) || !LimitAttach(document.getElementById('motivation_letter').value) ){
		alert(blogas_failas);
		return false;
	}
	
	var form = document.getElementById('send_query');		
	form.submit();
		
}

//galimi failu pletiniai
//ir is open offico

extArray = new Array(".doc", ".txt", ".rtf", ".pdf", ".html", ".htm", ".xls", ".ppt", ".odt", ".odp", ".ods");

function LimitAttach(file) {
	allowSubmit = false;
	if (!file) 
		return;
	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		
	ext = file.slice(file.indexOf(".")).toLowerCase();

	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { 
			allowSubmit = true; break; 
		}
	}
	
	return allowSubmit;
}

function clearFieldsKarjera(){
		document.getElementById('name').value="";
		document.getElementById('email').value="";
		document.getElementById('adress').value="";
		document.getElementById('cv').value="";
		document.getElementById('motivation_letter').value="";
}


function check_poll_formA(id){
	var form = document.getElementById('poll_'+id+'_A');
	for (var i=0; i<form.length; i++){
		if (form[i].checked){
			return form[i].value;
		}
	}
	return 0;
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}


