Cufon.replace('h1, h2, #footer p, #home_content',  {hover: 'true'});

$('document').ready(function(){
	
	//show visuals
	$('#home_visuals img, #info-visuals img').show();
	
	//enable fancybox
	$('.media').fancybox({
		'titlePosition' : 'over',
		'padding'		:  5,
		'overlayOpacity'	:  0.6,
		'overlayColor'		: '#1a1005'
	});
	
	//attach newsletter action to form on homepage
	$('#form_newsletter_home').submit(function(){
		//open the newsletter form
		newsletterForm($('#newsletter_email').val());
		
		//don't submit
		return false;
	});
	
	//hints
	$('input, textarea').inputHint();
	
	//open subscription window
	$('.newsletter_subscribe').click(function(){
		//open the newsletter form
		newsletterForm();
		
		//don't submit
		return false;
	});
	
	//open subscription in an iframe, and set the default value for the email
	//field	
	function newsletterForm(_email) {
		var $href = jQueryBaseHref+'/newsletter/subscribe?iframe=true';
		if (typeof(_email) != 'undefined') $href += '&email='+_email;
		$.fancybox(
			{
				'href'				: $href,
	        	'autoDimensions'	: false,
	        	'type'    	     	: 'iframe',
	        	'padding'         	: 5,
				'width'         	: 500,
				'height'        	: 450,
				'transitionIn'		: 'easeInExpo',
				'transitionOut'		: 'easeOutExpo',
				'overlayOpacity'	:  0.6,
				'overlayColor'		: '#1a1005'
			}
		);
	}
	
	/* var $adCookie = $.cookie("open-houses-vagabo");
	if (!$adCookie) {
		$.cookie("open-houses-vagabo", true);
		$("#open-houses").click();
	} */
});

/**
 * Load a javascript or css file
 * @param filename
 * @param filetype
 * @return void
 */
function loadjscssfile(filename, filetype){
	//if filename is a external JavaScript file 
	if (filetype=="js"){ 
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename)
	 }
	 //if filename is an external CSS file
	 else if (filetype=="css"){ 
		 var fileref=document.createElement("link")
		 fileref.setAttribute("rel", "stylesheet")
		 fileref.setAttribute("type", "text/css")
		 fileref.setAttribute("href", filename)
	 }
	 if (typeof fileref!="undefined")
		 document.getElementsByTagName("head")[0].appendChild(fileref)
}
