
var spinner;
var bigspin;
var globalOrder;
var ShowViaPreview;

var ViaPreview = Class.create({
	initialize: function(container) {
		this.previewBox = new Element('div', {'class':'viapreview'}).hide();
		
		container.insert({'bottom':this.previewBox});
	},
	show: function(container, image){
		this.previewBox.setStyle({
			'left': $(container).cumulativeOffset()[0] + 70 + 'px',
			'top': $(container).cumulativeOffset()[1] - 70 + 'px'
			});
		this.previewBox.update('<img src="' + image + '" />');
		this.previewBox.show();
	},
	hide: function(){
		this.previewBox.hide();
	}
});

var ViaVideoController = new Class.create({
	initialize: function(content, options){
		this.content = $(content);
	},
	show: function(){
	
		if(!this.videoResult)
			this._createVideoResultAreaIfNeeded();
			
		this.showVideoArea();
	},
	initVideoPlayer: function(){
	
		if(this._movieController)
			return;
			
			
			this._movieControls = new Core.VideoPanelWidget(this.controllerPanel);
					
			
			
			var movieOptions = {
				width:749,
				height:421,
				controller:false,
				posterFrame:null,
				showlogo:false,
				autostart:true,
				cache:true,
				bgcolor:"black",
				aggressiveCleanup:false
			};
			
		this._movieController = new Core.VideoPlayer(this.moviePanel, "/global/video/viamovie2_high.mov", movieOptions).getController();
		this._movieController.setControlPanel(this._movieControls);
		this._movieController.setDelegate(this);
			
	},
	_createVideoResultAreaIfNeeded: function(){
		this.videoResult = new Element("div", {id: "video-area"}).update(
			this.videoResultFrame = new Element("div", {id: "video-area-frame"}).hide()
			);
			
			var closebutton = new Element("a",{href:'#', 'class':'close'}).update("StŠng SškfŠltet");
			
			
			
			closebutton.observe('click', function(evt){
				Event.stop(evt);
				this.hideVideoArea();
			}.bindAsEventListener(this));
			
			
			this.moviePanel = new Element("div").addClassName("moviePanel");
			this.controllerPanel = new Element("div").addClassName("controllerPanel");
			this.moviePanel.insert({'bottom':this.controllerPanel});
			this.videoResultFrame.insert({'bottom':this.moviePanel});
			
			$('main').insert({'before':this.videoResult});
			
			

			this.videoResultFrame.insert({'bottom':closebutton});
			
			
		
	},
	showVideoArea: function(){
	
		this.videoResult.morph("height:500px;", {
			duration:0.45,
			afterFinish:function(){
			
				this.initVideoPlayer();
			
				document.fire("VideoArea:didExpand");
				
				this.isAnimating = false;
				
				this.videoResultFrame.appear({duration:0.45});
			}.bind(this)
		});
		
	},
	hideVideoArea: function(){
		
		this.videoResultFrame.fade({
			duration:0.45,
			afterFinish:function(){
				this.videoResult.morph("height:0px;", {
					duration:0.45,
					afterFinish:function(){
						this.isAnimating = false;
						
						document.fire("VideoArea:didColapse");
				
					}.bind(this)
				});
				
			}.bind(this)
		
		});		
	}
});

var ViaVideoPromo = Class.create({
	classwrapper: "moviewrapper",
	classframes: "movieframes",
	fps:2,
	position: 0,
	pos: [0,142,285,284+142],
	initialize: function(container) {
	
		 this.wrapper = new Element("a", {'href':'#','class': this.classwrapper}).update(
	  		this.movieframes = new Element("div", {'class': this.classframes})
	  	);
	  
	  container.insert({'top':this.wrapper});
	  
	  this.wrapper.scrollTop = this.pos[this.position];
	  this.timeoutId = setInterval(this.render.bind(this),parseInt(1000/this.fps));
	  
	  
	  this.video = new ViaVideoController("main");
	  
	  this.wrapper.observe("click", function(evt){
	  	Event.stop(evt);
	  	
	  	this.video.show();
	  	
	  }.bind(this));
	},
	render: function(){
		this.position++;
		
		if(this.position>3)
			this.position = 0;
			
		this.wrapper.scrollTop = this.pos[this.position];
		
	}
});

               
document.observe('dom:loaded', function() { 

	ShowViaPreview = new ViaPreview($(document.body));

	$("distrilogin").hide();
	
	new Autocompleter.SelectBox('options');
	new protostyle('psuser');
	new protostyle('pspass', {isPassword: true});
	
	if($('psepost'))
	{
		new protostyle('psepost');
	}
	new modules('contentmodules');
	
	//new infofield('contentmodules');
	
	//$('menulanguage').setStyle({top: '-30px'});
	
	if($("moviecontainer"))
		new ViaVideoPromo($("moviecontainer"));
	
	if($('spinnercontainer'))
	{
		spinner = new viacounter('spinnercontainer', false);
	}
	
	if($('bigspinnercontainer'))
	{
		bigspin = new viacounter('bigspinnercontainer', true);
	}
	
	
	
	$$(".bigtarget a").each(
		function(elm) {
		$(elm).bigtarget();
	});
	
	
  		
	FLIR.init();
	$$("h1").each( 
		function(el) { 
			FLIR.replace(el, new FLIRStyle({ cFont:'interlightholviks', mode:'wrap' }) ); 
	});
	
	$$("h2").each( function(el) { FLIR.replace(el, new FLIRStyle({ cFont:'interlightholviks' }) ) } );
	
	$$("a.graybutton").each( function(el) { FLIR.replace(el, new FLIRStyle({ cFont:'interboldholviks' }) ) } );
	
	
	if($("movietext"))
	FLIR.replace($("movietext"), new FLIRStyle({ cFont:'interboldholviks' }) );
	
	
	FLIR.replace($("spinnernumber"), new FLIRStyle({ cFont:'interboldholviks' }) );
	FLIR.replace($("viametricswebtextnew"), new FLIRStyle({ cFont:'interboldholviks' }) );
	FLIR.replace($("logintextnew"), new FLIRStyle({ cFont:'interboldholviks' }) );
	
	Event.observe(window, 'resize', resizeFrame);
	Event.observe($('viametricslogo'), 'click', function() {window.location = "/";});
	
	Event.observe(window, 'scroll', resizeFrame);
	

	
	
});


function recup_lg() 
{ 
var lgr; 
if (verif_lg(navigator.userLanguage)) { lgr = verif_lg(navigator.userLanguage); } 
else if (verif_lg(navigator.systemLanguage)) { lgr = verif_lg(navigator.systemLanguage); } 
else if (verif_lg(navigator.browserLanguage)) { lgr = verif_lg(navigator.browserLanguage); } 
else if (verif_lg(navigator.language)) { lgr = verif_lg(navigator.language); } 
else { lgr = 'us'; }

return lgr; 
}


function verif_lg(lg_tmp) 
{ 
if(lg_tmp) 
{ 
if(lg_tmp.indexOf('fi')!= -1) { return 'fi'; } 
else if (lg_tmp.indexOf('en')!= -1) { return 'us'; } 
else if (lg_tmp.indexOf('es')!= -1) { return 'es'; } 
else if (lg_tmp.indexOf('da')!= -1) { return 'da'; } 
else if (lg_tmp.indexOf('sv')!= -1) { return 'sv'; } 
else if (lg_tmp.indexOf('de')!= -1) { return 'de'; } 
else if (lg_tmp.indexOf('it')!= -1) { return 'it'; } 
else { return ''; } 
} 
}

function doCheckLang(){
	var viabro = "sv_SE";
	
	var lg_nav = recup_lg();
	
	if(lg_nav == 'us'){viabro="en_US"}
	else if(lg_nav == 'se'){viabro="sv_SE"}
	else if(lg_nav == 'fi'){viabro="fi_FI"}
	else if(lg_nav == 'de'){viabro="de_DE"}
	else if(lg_nav == 'no'){viabro="no_NO"}
	else if(lg_nav == 'it'){viabro="it_IT"}
	else if(lg_nav == 'dk'){viabro="da_DK"}
	
	
	if(viabro!=viabrowlang)
	{
			if(!checkPrefLang())
			{
				doLangSel();
			}
			
	}
	

}

function checkPrefLang() {
	var x = false;
	
	
	if (document.cookie.length>0)
	{
		var cstart = document.cookie.indexOf("preflang");
		
		if(cstart!=-1)
		{
			x = true;
		}
		
	
	}
	
	return x;
}

function doSetLang(setlang){
	var c = new Date();
	c.setDate(c.getDate()+365);
	document.cookie = "preflang=" + setlang +"; expires="+c.toGMTString()+"; path=/;";
	
	var viagoref = "nuller";
	switch(setlang){
	case "sv_SE":
		viagoref = "/";
	break;
	case "no_NO":
		viagoref = "/no/";
	break;
	case "fi_FI":
		viagoref = "/fi/";
	break;
	case "it_IT":
		viagoref = "/it/";
	break;
	case "da_DK":
		viagoref = "/dk/";
	break;
	case "de_DE":
		viagoref = "/de/";
	break;
	case "en_US":
		viagoref = "/en/";
	break;
	case "lv_LV":
		viagoref = "/lv/";
	break;
	case "ee_EE":
		viagoref = "/ee/";
	break;
	case "lt_LT":
		viagoref = "/lt/";
	break;
	case "pl_PL":
		viagoref = "/pl/";
	break;
	default:
	break;
	}
	
	
	Modalbox.hide({afterHide: function(){
		if(viagoref != "nuller")
		{
			window.location.href = "http://www.viametrics.com" + viagoref;
		}
	
	
	}});
	
	
	
	
	
	return false;

}

function doLangSel(){
	
	Modalbox.show('/global/specialpages/langsel.html', {title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});

}


function showDistriLogin(){
	
	Modalbox.show('/distrilogin/', {title: 'VIAMETRICS DISTRIBUTOR', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('thediformin'), new FLIRStyle({ cFont:'interstatebold' }) );
		
		if($('thecancel'))
		{
			FLIR.replace($('thecancel'), new FLIRStyle({ cFont:'interstatebold' }) );
		}
		
		
		//FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});

}

function leveransShow(){

	if(!$('webshopleverans').visible())
	{
		Modalbox.resizeToInclude('webshopleverans', {afterResize: function(){
			
			new Effect.Appear('webshopleverans');
		}});
	};
	
	
	return false;
}

function doViaMail(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/via.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}


function doViaMailDK(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viadk.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}

function doViaMailFI(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viafi.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}

function doViaMailDE(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viade.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}


function doViaMailIT(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viait.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}

function doViaMailNO(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viano.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}

function doViaMailEN(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viaen.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}


function doViaMailEE(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viaee.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interlightholviks' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interboldholviks' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interboldholviks' }) );	
		}});
}

function doViaMailLT(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/vialt.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interlightholviks' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interboldholviks' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interboldholviks' }) );	
		}});
}

function doViaMailLE(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viale.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interlightholviks' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interboldholviks' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interboldholviks' }) );	
		}});
}

function doViaMailPL(meter){
var metto = "met=" + meter;

Modalbox.show('/global/specialpages/viapl.php', {params: metto, title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interlightholviks' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interboldholviks' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interboldholviks' }) );	
		}});
}


function doDistMail(lang){

		if (lang == "")
		{
			lang = "se";
		}
		
var langurl = "/cms/" + lang + "/distform/";


Modalbox.show(langurl, {title: 'VIAMETRICS', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
		}});
}


function doMessageUser(lang, pagealias){
	allowLogin = true;
	
	if(lang == "")
		lang = "se";
	
	
	if(lang != "se")
		lang = "en";
		
	var langurl = "/cms/" + lang + "/" + pagealias + "/";


	Modalbox.show(langurl, {title: 'VIAMETRICS', afterLoad: function(){
		Custom.init();
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
		FLIR.replace($('update2'), new FLIRStyle({ cFont:'interstatebold' }) );	
	}});
}




function thetextupdate(){
		
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );

}
function resizeFrame() {

	var viewportHeight = document.viewport.getHeight();
	var newFrameDivHeight = viewportHeight - 518;
	
	
	newFrameDivHeight = newFrameDivHeight + document.viewport.getScrollOffsets().top;
	
	if(newFrameDivHeight<150)
	{
		newFrameDivHeight = 150;
	}
	$('infoboxh').setStyle({ height: (newFrameDivHeight) + 'px'});
	
}

function setCookie(id) {
	var c = new Date();
	c.setDate(c.getDate()+7);

	document.cookie = id + "=yes; expires="+c.toGMTString()+";";

}
function checkCookie(id) {
	var x = false;
	var myReg = RegExp(id+"=yes");
	var c = document.cookie.split(";");
	for(var t=0;t<c.length;t++)
	{
		
		if(c[t].match(myReg))
		{
			x = true;
			
		}
	}
	
	return x;
}

function loginnow(id) {

	
	
	if($("showthis").checked)
	{
		setCookie(id);
	}
	
	
	
	document.loginform.submit();
	
	return false;
}

function doResearchSend(){
var sendthis = "skicka=research&" + Form.serialize('viaresearch');



new Ajax.Request('/global/cosmosmail/outserver.php', {
	parameters: sendthis,
  onSuccess: function(transport) {
    document.loginform.submit();
    }
    });

}

function doDistriForm() {
	
	var noError = true;
	
	var thestuff = $("distriforms").select(".viawebinput");
	
	thestuff.each( 
		function(el) { 
			if(el.value.length < 1)
			{
				if(el.name != "faktco2")
				{
					el.morph('background:#990000;color:#ffffff');
				
					noError = false;
				}
				
			}
			else
			{
				el.morph('background:#FFFFFF;color:#000000');
				
			}
	});
	
	
	if(noError)
	{
		var viaorderstuff = "skicka=distri&" + Form.serialize('distriform');
	
	Modalbox.show('/global/cosmosmail/outserver.php', {title: 'VIAMETRICS', params: viaorderstuff, afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			
		}});
	}
	
}

function doOrderStepTwo() {

globalOrder = "";
var noError = true;
	
	var thecomptype = Form.getInputs('compactform_stepone','radio','reflex').find(function(radio){ return radio.checked; });
	
	if(thecomptype)
	{
		
		$("selecttypearea").morph('background:#FFFFFF;color:#000000');
	}
	else
	{
		$("selecttypearea").morph('background:#990000;color:#ffffff');
		noError = false;
	}
	
	var theamount = $("webshopantal").select(".viawebinput");
	
	
	theamount.each( 
		function(el) { 
			if(el.value.length < 1)
			{
				el.morph('background:#990000;color:#ffffff');
				
				noError = false;
			}
			else
			{
				el.morph('background:#FFFFFF;color:#000000');
				
			}
	});
	
	
	if(noError)
	{
		globalOrder = "skicka=order&" + Form.serialize('compactform_stepone');
		
		
	Modalbox.show('/global/specialpages/shop2.html', {title: 'VIAMETRICS WEBSHOP', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			
		}});
	}
	
	return false;

}

function doDistriOrder() {
	var noError = true;
	
	if($("vdiddata").value.length < 1)
	{
				
		$("vdiddata").morph('background:#990000;color:#ffffff');
				
		noError = false;
				
				
	}
	else
	{
		$("vdiddata").morph('background:#FFFFFF;color:#000000');
				
	}
	
	

	if(noError)
	{
		var viaorderstuffdistri = "skicka=distriorder&" + Form.serialize('compactform_distri');
		Modalbox.show('/global/cosmosmail/outserver.php', {title: 'VIAMETRICS', params: viaorderstuffdistri, afterLoad: function(){
			FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
			FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			
		}});
	}
	
	return false;

}

function doOrder() {
	
	var noError = true;
	
	
	
	
	
	var thestuff = $("webshopfaktura").select(".viawebinput");
	
	
	thestuff.each( 
		function(el) { 
			if(el.value.length < 1)
			{
				if(el.name != "faktco2")
				{
					el.morph('background:#990000;color:#ffffff');
				
					noError = false;
				}
				
			}
			else
			{
				el.morph('background:#FFFFFF;color:#000000');
				
			}
	});
	
	if($('webshopleverans').visible()){
	
	var themorestuff = $("webshopleverans").select(".viawebinput");
	
	
	themorestuff.each( 
		function(el) { 
			if(el.value.length < 1)
			{
				if(el.name != "levco")
				{
				el.morph('background:#990000;color:#ffffff');
				
				noError = false;
				}
			}
			else
			{
				el.morph('background:#FFFFFF;color:#000000');
				
			}
	});
	
	}
	
	if(noError)
	{
		var viaorderstuff = globalOrder + "&" + Form.serialize('compactform_steptwo');
	
	Modalbox.show('/global/cosmosmail/outserver.php', {title: 'VIAMETRICS', params: viaorderstuff, afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			
		}});
	}
	
	return false;
	
	
}
function webshop() {
	
		
		Modalbox.show('/global/specialpages/shop1.html', {title: 'VIAMETRICS WEBSHOP', afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			
		}});		
}






function webshopdistrimonitor() {
	$('compactform_distri').select('.dviawebinput').each(function(el){
		el.observe('keyup',function(ee){
			var tosendthis = Form.serialize('compactform_distri');
			new Ajax.Request( '/global/cosmosmail/realtimeshop.php', { parameters: tosendthis, 
						onSuccess: function(transport) {
								var index = transport.responseText.indexOf("+");
								var length = transport.responseText.length;
								$("distritotalsum").update(transport.responseText.substring(0, index));
								$("distrinettosum").update(transport.responseText.substring(index+1, length));
							
						}.bind(this),
						onException: function(instance, exception){
							
						}
					});

		});
	
	});
}
function webshopdistri() {
	
		
		Modalbox.show('/global/specialpages/distrishop1.html', {title: 'VIAMETRICS DISTRIBUTOR ORDER SYSTEM', width:470, afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			webshopdistrimonitor();
		}});		
}
function doThanks() {
	if($('psepost').value.match(/@/))
	{
		
		var viawebm = "skicka=newsletter&" + "youremail=" + $('psepost').value;
		Modalbox.show('/global/cosmosmail/outserver.php', {title: 'VIAMETRICS', params: viawebm, afterLoad: function(){
		FLIR.replace($('popinforub'), new FLIRStyle({ cFont:'interstate' }) );
		FLIR.replace($('update'), new FLIRStyle({ cFont:'interstatebold' }) );
			
		}});
	}
	
		
		
}


function doLogin(lang) {

	/*if(!checkCookie('viasommar'))
		doMessageUser(lang,'gladsommar');
	else*/
		document.loginform.submit();


	return false;		
}


function InitBaseLoad() {

	//Resize the Frame
	resizeFrame();
	
	//Observe form login 
	/*Event.observe('loginform','submit',function(e) {
		Event.stop(e);
		doLogin(currentlang)	
	});*/
	
	Event.observe('distriloginbutton','click',function(e) {
		Event.stop(e);
		showDistriLogin();	
	});
	
		
	$("distrilogin").hide().setStyle('right:130px;');
	
	new Effect.Morph('menulanguage',{
	style:'top:0px;',
	transition: Effect.Transitions.EaseFromTo,
	duration:2.0,
	afterFinish: function() {
				
				//$('languagecontainer').setStyle({overflow: 'visible'});
				
				$('languagecontainer').setStyle({overflow: 'visible'});
				$("distrilogin").show();
				
				new Effect.Morph('distrilogin',{
					style:'right:330px;',
					duration:0.75,
					transition: Effect.Transitions.EaseFromTo
					
											
				});
			
				
			}.bind(this)
	});
	
	
	doCheckLang();
}

Event.observe(window, 'load', InitBaseLoad, false);
