/* Hoverboxes on homepage */
var myEffects = new Array();
var mouseOverNavBoxItem = null;
function mouseOverNavBox(el){
	if(mouseOverNavBoxItem != el){
		mouseOverNavBoxItem = el;
		while(myEffects.length != 0){
			myEffects.pop().cancel();
		}
		$(el).up('li').siblings().each(function(e){
			myEffects.push(new Effect.Parallel([
				new Effect.Fade($(e).down('span.img'), { sync:true }),
				new Effect.Morph($(e),{ style: 'height:124px',sync:true}),
				new Effect.Fade($(e).down('a').down('strong'), { sync:true })
			],{duration:0.3}));
		});
		
		myEffects.push(new Effect.Parallel([
				new Effect.Appear($(el).previous('span.img'), { sync:true }),
				new Effect.Morph($(el).up('li'),{ style: 'height:134px',sync:true}),
				new Effect.Appear($(el).down('strong'), { sync:true })
			],{duration:0.3}));
	}
}
function showTab(el,id){
	$(el).addClassName('selected');
	$(el).up('li').siblings().each(function(e){e.down('a').removeClassName('selected');});
	
	$(id).show();
	$(id).siblings().each(function(e){e.hide();});
}
var googleMapsPopup;
var googleMapsMap;
function popupGoogleMaps(lat,lng,title){
	var title = title || ""; //4.98961,9.876709
	var lat = lat || 50.823919;
	var lng = lng || 4.314757;
	var latlng = new google.maps.LatLng(lat,lng);
   
    if(googleMapsPopup && googleMapsMap){
    	// load correct item
    	googleMapsPopup.show();
    	googleMapsPopup.center();
    	googleMapsMap.setCenter(latlng);
    }else {
    	// create map
	   var myOptions = {
	      zoom: 16,
	      center: latlng,
	      mapTypeId: google.maps.MapTypeId.ROADMAP,
	      mapTypeControl: false
	    };
    	googleMapsPopup = new LightWindow({width: '474px',height:'400px', content: "<div id=\"googleMaps\" style=\"width:400px;height:400px;position:relative;zoom:1;\"></div>", draggable: false});
    	
    	googleMapsMap = new google.maps.Map(document.getElementById("googleMaps"), myOptions);
    }
    
    // create marker
    var marker = new google.maps.Marker({
        position: latlng, 
        map: googleMapsMap,
        title:title
    });
}
function homepagePopup(content){
	new LightWindow({width: '474px', content: content+"<a href=\"solutions.html\" class=\"readMore\">Our Solutions</a>", draggable: true,remove:true});
}

/*
 * Functions to create auto focus/blur on inputs
*/
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}

function setInputs() {
   var s = document.getElementsByTagName('input');
   for (var i=0; i<s.length; i++) {
		if(s[i].type.toLowerCase() == 'text' && s[i].title != undefined && s[i].title != ""){
			s[i].value = s[i].title;
			s[i].onfocus = function(){
				if(this.value == this.title){
					this.value = "";
				}
				this.className += ' focused';
			}
			s[i].onblur = function(){
				if(this.value == ""){
					this.value = this.title;
				}
				this.className = this.className.replace(new RegExp(" focused\\b"), '');
			}
		}
   }
 }
 addEvent(window,'load',function() {
   setInputs();
 });



