window.addEvent('load', function() { 
	
	(function(){
		document.body.setStyle('margin','7% 0 0 0');//to change back what the fat free cart changes
	}).delay(100);
	
});
window.addEvent('domready', function() { 
	changeBodyBGcolor();
	var h1Links = new MooFont({
		selector:'h1 a', 
		size:16, 
		color:'#5D410F',
		bgColor:'#FEA433',
		color_hover:'#E65088',
		bgColor_hover:'#FEA433',
		font:'soujourn'  
	});
	
	var h1 = new MooFont({
		selector:'#content h1', 
		size:16, 
		color:'#5D410F',
		bgColor:'#F2D5C8',
		color_hover:'#5D410F',
		bgColor_hover:'#F2D5C8',
		font:'soujourn'  
	});
	
	var h2 = new MooFont({
		selector:'h2', 
		size:12, 
		color:'#79402F',
		bgColor:'#F2D5C8',
		color_hover:'#79402F',
		bgColor_hover:'#F2D5C8',
		font:'soujourn'  
	});
	
	var h3 = new MooFont({
		selector:'h3', 
		size:15, 
		color:'#5D410F',
		bgColor:'#F2D5C8',
		color_hover:'#5D410F',
		bgColor_hover:'#F2D5C8',
		font:'soujourn'  
	});
	//var abadiFont = new MooFont({selector:'h1,h2', color:'#253F39', color_hover:'#253F39', bgColor:'#DFF6F9', bgColor_hover:'#DFF6F9' });
	//var links = new MooFont({selector:'a', color_hover:'#FF0000' });
	
	//linkImages();
	
	
	
});

function linkImages(){
	var passedVars = getUrlVars();
	if(passedVars.id == 2){
		var $imgs = $('content').getElements('img');
		//var evenOdd = 1;
		
	    $imgs.each(function(item, index){
	        if(item.getParent() && item.getParent().get('tag') === 'h1'){
				return;
			}
			
			if(item.getParent() && item.getParent().get('tag') === 'h2'){
				return;
			}
			
			if(item.getParent() && item.getParent().get('tag') === 'h3'){
				return;
			}
			if(item.getParent() && item.getParent().get('tag') === 'h4'){
				return;
			}
			
			var imgNameArr = item.src.split('/');
			var imgName = imgNameArr[(imgNameArr.length-1)];
			
			
			var link = new Element('a', {
			    'title': item.alt,
			    'href': "App_Images/Image/"+imgName,
				'rel': 'lightbox[gallery]',
				'target':'_blank'
			});
			
			item.set('src',"App_Images/Image/medium/"+imgName);
			item.set('rel',"[gallery]");
			
			link.inject(item,'before');
			item.inject(link,'inside');

		   //evenOdd++;
		   //if evenOdd is even
		   //item.style.float = "right";
		   
		   $(item).addClass('galleryImg');
		   $(link).addClass('galleryLink');
		   
		   
	    }); 
	
	}
		
		//Lightbox.init.bind(Lightbox);
}

function getUrlVars()
{
    // Read a page's GET URL variables and return them as an associative array.
    //this function is from http://snipplr.com/view/799/get-url-variables/
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}


function changeBodyBGcolor(){
	//if browser is Safari
	if(Browser.Engine.webkit || Browser.Engine.webkit419 || Browser.Engine.webkit420){
		document.body.style.backgroundColor = "#F9E4C2";
	}
}

