//by go4web.ch | Fabian Lutz

var aktivcolorHEX = "#456386";
var aktivcolorRGB = "rgb(69, 99, 134)"
var hovercolor =  "#63809F";
var inaktivcolor = "#84ADDE";

window.addEvent('domready', function() {
	
	//SUBMENUDIVS SUCHEN
	var alldiv = $('subnavcontainer').getElements('div');
	
	alldiv.each(function(div,item,index) {
		
		if(div.className == "subnav"){
			
			div.addEvent('mouseenter',function(e) {
				showsub(div.id);
			});
			
			div.addEvent('mouseleave',function(e) {
				hidesub(div.id);
			});
		}
		
		
	});
	
	
	//ALLEN MAINNAVS AKTION ZUORDNEN BEI OVER	
	var allmenu = $('mainnav').getElements('li');
	
	allmenu.each(function(li,item,index) {
		
		
		var posi = li.getPosition();

		li.addEvent('mouseenter',function(e) {
			
			//console.log(item);
			
			try{
				if(item == 3){
					$('subnav'+item).setStyle('width','134px');
				}
				$('subnav'+item).setStyle('left',posi["x"]+'px');
				$('subnav'+item).setStyle('height','0px');
				$('subnav'+item).setStyle('opacity',0.9);
				$('subnav'+item).setStyle('display','block');
				
				var blenddown = new Fx.Tween($('subnav'+item), {duration: 400});
				blenddown.start('height',$('subnav'+item).getStyle('height'),'145');
						
				
			}catch(ex){}
			
			if(li.style.backgroundColor!= aktivcolorRGB && li.style.backgroundColor != aktivcolorHEX){
				li.setStyle('backgroundColor', hovercolor);
			}
					  	
 		});

 		
 		//ALLEN MAINNAVS AKTION ZUORDNEN BEI LEAVE
		li.addEvent('mouseleave',function(e) {
			
			
			if(li.style.backgroundColor != aktivcolorRGB && li.style.backgroundColor != aktivcolorHEX){
				
				li.setStyle('backgroundColor', inaktivcolor);	
				
			}
			
			
			try{
				
				$('subnav'+item).setStyle('opacity',0);
				$('subnav'+item).setStyle('display','none');

			}catch(ex){}

			
		});
		
		
	});
	
	
});


function showsub(subelement){	
	
	var no = subelement.substr( subelement.length-1, 1);
	
	$(subelement).setStyle('opacity',0.9);
	$(subelement).setStyle('display','block');
	
	if($('mainnav').getElements('li')[no].getStyle('backgroundColor')!= aktivcolorRGB && $('mainnav').getElements('li')[no].getStyle('backgroundColor') != aktivcolorHEX ){
		$('mainnav').getElements('li')[no].setStyle('backgroundColor', hovercolor);
	}
}

function hidesub(subelement){
	
	var no = subelement.substr( subelement.length-1, 1);
	
	$(subelement).setStyle('opacity',0);
	$(subelement).setStyle('display','none');
	if($('mainnav').getElements('li')[no].getStyle('backgroundColor')!= aktivcolorRGB && $('mainnav').getElements('li')[no].getStyle('backgroundColor') != aktivcolorHEX ){
		$('mainnav').getElements('li')[no].setStyle('backgroundColor', inaktivcolor);
	}
	
}


function intro(){
	$('lilaw').setStyle('opacity','0');
	
	var intro = new Fx.Tween('lilawmain', {duration: 1000,onComplete:function(){$('lilawmain').setStyle('display','none');}}); 
	intro.start('opacity','1','0');
	
	var intro2 = new Fx.Tween('lilaw', {duration: 1000}); 
	intro2.start('opacity','0','1');
}

function googlemap() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallZoomControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(47.171437,8.51658), 16);
		var point = new GLatLng(47.171437,8.51658,15);
		//online -> ABQIAAAAQO7vjAZDK3KEoA9w4ZoZyxSxU_jhJYR74Uo1XR5J3wWlpZfx9RRKSVKFneUpOqb3nM47MIvGQRy0OA
		//local -> ABQIAAAAQO7vjAZDK3KEoA9w4ZoZyxTsR5Iqrv5sl_TP-VtzFEl2TmyEYRQfcSRXZ-GEKmBjeJog6l94As31OA
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		
        	blueIcon.image = "http://www.lilaw.ch/images/gmlogo.gif";
        	blueIcon.iconSize = new GSize(46, 19);
        	markerOptions = { icon:blueIcon };
		
		if(lang == 'de'){
			langlink = "Route berechnen";
		}else{
			langlink = "get directions";
		}
        	
        	
        	marker = new GMarker(point);
		map.addOverlay(marker);
		var html = '<div style="float:left;width:143px;"><b>Lichtsteiner Rechtsanwälte</b><br>Baarerstrasse 10<br>Postfach 4545<br>CH - 6304 Zug<br><br><a href="http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=Baarerstrasse+10,+6300+Zug,+Switzerland+(Lichtsteiner,+Urs)&hl='+lang+'&geocode=%3BFU_HzwIdKPSBACFUB8O_sKt3Og&mra=ls&sll=47.168666,8.515799&sspn=0.009847,0.019312&ie=UTF8&ll=47.171409,8.516657&spn=0.009846,0.019312&z=16" target="_blank">'+langlink+'</a>&nbsp;&nbsp;&nbsp;</div><div style="float:left;padding-left:0px;"><img src="http://www.lilaw.ch/images/gmfassade.jpg"></div>';
	
		marker.openInfoWindowHtml(html);
        	
        	
        	var parkIcon = new GIcon(G_DEFAULT_ICON);
		parkIcon.image = "http://www.lilaw.ch/images/park.png";
        	parkIcon.iconSize = new GSize(18, 30);
        	parkOptions = { icon:parkIcon };
        	
        	var park1 = new GLatLng(47.172237,8.51798,16);
        	p1 = new GMarker(park1,parkOptions);
		map.addOverlay(p1);
		
		
        	var park2 = new GLatLng(47.172297,8.51890,16);
        	p2 = new GMarker(park2,parkOptions);
		map.addOverlay(p2);
        	
		var park3 = new GLatLng(47.170900,8.51658,16);
        	p3 = new GMarker(park3,parkOptions);
		map.addOverlay(p3);
   
        	/*
      		{/literal}
      		{if $aktivlanguage == "de"}
      			lang = "Route berechnen";
      			langlink = "de";
      		{else}
      			lang = "get directions";
      			langlink = "en";
      		{/if}
      		
      		{literal}*/
		
		
	}
}




function zoomSFont(Fsize){
	
	
	
	
	if(Fsize != "reload"){
		var myCookie = Cookie.write('fontSize', Fsize, {duration: 1});
		
		
		if(window.location == "http://www.lilaw.ch/" || window.location == "http://www.lilaw.ch" || window.location == "http://lilaw.ch/" || window.location == "http://.lilaw.ch"){
			window.location.href=window.location+"index.php?first=false";
		}else{
			window.location.reload();	
		}
		
		
	//alert($('copyright').getStyle('position'));
		
		//console.log("WRITE->"+Fsize);
	}else{
		if(Cookie.read("fontSize") != null){
			//console.log("READ ->"+Cookie.read("fontSize"));
			Fsize = Cookie.read("fontSize");
		}else{
			//console.log("SET FIRST")
			Fsize = 11;
			Tsize = 13;
		}
	}
	
	Tsize = parseInt(Fsize)+2;
	
	
	$('content').setStyle('font-size',Fsize+"px");
	
	
	var alldiv = $('content').getElements('div');
	//console.log(alldiv);
	
	alldiv.each(function(div,item,index) {
		
		alldiv.setStyle('font-size',Fsize+"px");
	});
	
	var alltd = $('content').getElements('td');
	
	alltd.each(function(div,item,index) {
		
		alltd.setStyle('font-size',Fsize+"px");
	});
	
	var allA = $('content').getElements('a');
	
	allA.each(function(div,item,index) {
		
		allA.setStyle('font-size',Fsize+"px");
	});
	
	var allH = $('content').getElements('h1');
	
	allH.each(function(div,item,index) {
		
		allH.setStyle('font-size',Tsize+"px");
	});
	
}
	
//var scrollYS = window.getScrollSize();
		
//console.log(scrollYS.y+"----"+ window.innerHeight);

function formwidth(){
	
var allforms = document.forms.length;
for(var i=0;i<=allforms;i++){
	
  try{
  	
    	var formD = eval("document."+document.forms[i].name);    
	var count=formD.length-7;
	for (var x=0; x<count;x++){
		
      		
      		formD.elements[x].style.width ="200px";
        		
      		
	}  
  }catch (ex) {}	
}
}

