function addOption(value, text, id)
{
	var thisValue = value;
	var thisText  = text;
	var thisOpt   = document.createElement('option');
	thisOpt.value = thisValue;
	thisOpt.appendChild(document.createTextNode(thisText));
	$("#" + id).append(thisOpt);
}

function showAddress(map,geocoder,address,html, postalcode, i) {
	geocoder.getLatLng(
	address,
	function(point) {
		if (!point && i < 1) {
			showAddress(map, geocoder, postalcode, html, postalcode, 1);
		} else {
			map.setCenter(point, 15);
			var marker = new GMarker(point);
		
			map.addOverlay(marker);
			map.addControl(new GMapTypeControl());
			map.addControl(new GLargeMapControl());
		}
	});
}

function switchStylestyle(styleName)
{
  jQuery('link[@rel*=style][title]').each(function(i)
  {
     this.disabled = true;
     if (this.getAttribute('title') == styleName) this.disabled = false;
  });
  createCookie('style', styleName, 365);
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}

$(document).ready(function()
{
 	$('#pictureHomeContainer ul').innerfade({ 
		animationtype: 'fade',
		speed: 1000,
		timeout: 5000,
		type: 'sequence'
	});	
    
    
    $('ul#fadetext').innerfade({ 
		animationtype: 'fade',
		speed: 1000,
		timeout: 10000,
		type: 'sequence'
	});	
    
	$('ul#fadetext').innerfade({ 
		animationtype: 'fade',
		speed: 1000,
		timeout: 10000,
		type: 'sequence'
	});	
	
	$('ul#headerimg').innerfade({ 
		speed: 1000,
		timeout: 10000,
		type: 'sequence',
		containerheight: '158px'
	}); 

	$('.styleswitch').click(function()
	{
		switchStylestyle(this.getAttribute("rel"));
		$(".styleswitch").css({"color" : "#000"});
		$(this).css({"color" : "#ec6f0e"});
		
		return false;
	});
	var c = readCookie('style');
	
	if (c) 
	{
		$(".styleswitch").css({"color" : "#000"});
		$('#stylesBox > ul > li > a#' + c + 'Letters').css({"color" : "#ec6f0e"});
		switchStylestyle(c);
	}
	
	$(".tooltip").tooltip({ 
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    opacity: 1, 
	    fixPNG: true, 
	    showBody: " - ", 
	    extraClass: "pretty", 
	    top: -15, 
	    left: 5 
	});  
	
});
