overrides={
	ready:function(){

		//home page image
		$('.col1 img[src=/EE/image/amandaShot.jpg]').css({margin:'0px'});

		//fix content page layout
		/*
		if($('.PsubMenu').length){
			$('.content').wrapInner('<div id="contentbody" />');
			$('#contentbody').before($('.PsubMenu'));
			$('#contentbody table').attr('width','100%');
			$('#contentbody textarea').css('width','300px');
		}
		*/

		//add in news box
		/*
		var htm = '<div id="newsletter"><!-- <h4>Ask Amanda E-News<brand E-Book</h4> --><p>'
			+'Sign up for Ask Amanda News, Updates & Special offers and receive a free eBook:'
			+'</p><p class="book">'
			+'<strong>Style Confidence</strong> Simple steps to dressing confidently every day!'
			+'</p><a href="#">Join E-News</a></div>';
		$('.section-home .col3').html(htm);
		
		*/
		//home page - add icons
		/*var htm = '<div id="home-hooks">'
			+'<a href="/index.php/site/personal/" class="hl">For people wanting to look their best & feel more confident in any situation</a>'
			+'<a href="/index.php/site/corporate/" class="hr">For businesses wanting to get that edge, confidence and credibility</a>'
			+'</div>';
		$('.section-home .col2').append(htm);
		*/
		//home - news box actions
		$('#newsletter a').click(function(){
			$(this).dialog({content:
				'<form id="news-signup">'
				+'<div><label>Name</label><input type="text" name="name" /></div>'
				+'<div><label>Email</label><input type="text" name="email" /></div>'
				+'<div><a href="#">Join E-News Now</a></div>'
				+'<p>Your privacy is our priority and your<br />details will never be sold, given, traded'
				+'<br />or rented to anyone else</p>'
				+'</form>'
			});
			return false;
		});

		//home page - 
/*
		var addthis = '<div class="addthis_toolbox addthis_default_style" style="margin-top:10px;">'
+'<div><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a></div><div><a class="addthis_button_tweet"></a></div>'
+'<div><a class="addthis_button_google_plusone" g:plusone:size="medium"></a></div>'
+'<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4ec0785431402162"></script>';

		var htm = '<div id="social">'
			+'<div><a class="fb" target="_blank" href="http://www.facebook.com/pages/Ask-Amanda-Image-Style-Consultants/196784747042342">Facebook</a></div>'
			+'<div><a class="li" target="_blank" href="http://au.linkedin.com/pub/amanda-curren/4/865/139">LinkedIn</a></div>'
			+'<div><a class="gp" target="_blank" href="https://plus.google.com/117013722984453173276">Google+</a></div></div>'
			+addthis;
*/
		/*var htm = '<a target="_blank" style="margin-top:20px;display:block;" href="http://www.facebook.com/pages/Ask-Amanda-Image-Style-Consultants/196784747042342"><img alt="View Facebook" src="/override_assets/facebook_button.jpg"></a>';
		$('.section-home .col3').append(htm);
		*/
		//newsletter
		$('#news-signup a').live('click',function(){
			//$('#news-signup').css('opacity',0.5);
			$('#news-signup a').html('Adding&hellip;');
			
			$.post('/override_assets/newsletter.php',{
				email:$('#news-signup input:eq(1)').val(),name:$('#news-signup input:eq(0)').val()}
			,function(r){
				if(r=='1'){
				
					$('#news-signup').html('<p>Thank you for joining Ask Amanda e-News, you will find your copy of our free eBook, Style Confidence - Simple steps to dressing confidently every day in you mailbox shortly.</p><p>Enjoy!</p>');
				}else{
					alert('Sorry invalid email. Please try again');
					$('#news-signup a').html('Join E-News Now');
					//$('#news-signup').css('opacity',1);
				}
					
			});
		
			return false;
		});


		
	}
}


$(document).ready(overrides.ready);






/*
	Custom Dialog/Lightbox box
*/
$.fn.dialog = function(options){
	var options   = options || {};

	//Add box to DOM Once
	if($('#dialogbox').length<1){ $('<div id="dialogbox"><div id="dialogbox-content"></div></div><div id="dialogbox-overlay"></div><div id="dialogbox-close"><a href="">Close</a></div>').appendTo('body');$(window).resize(onresize);$(window).scroll(onresize);}


	var dialogbox = $('#dialogbox');
	var content = $('#dialogbox-content');
	var overlay = $('#dialogbox-overlay');
	var close_button = $('#dialogbox-close');
	options.hide_close = options.hide_close ? true : false;

	//Element to load from - handle one element
	var element = $(this).eq(0);

	//load dialog box
	load();

	function onresize(){
		if(!$('#dialogbox:visible').length) return;
		var size = _getPageSize();
		var scroll = _getPageScroll();
		overlay.css({width:size.windowWidth,height:size.windowHeight});
		var position = size.windowHeight<dialogbox.height()?'absolute':'fixed';
		var dialogbox_top = size.windowHeight<dialogbox.height()?(position=='absolute'?dialogbox.offset().top:scroll.y+15):(size.windowHeight/2)-(dialogbox.height()/2);
		dialogbox.css({top:dialogbox_top,position:position,left:size.windowWidth/2-(dialogbox.width()/2)});
		var closeX = dialogbox.offset().left+dialogbox.width()-close_button.width();
		close_button.css({top:dialogbox_top-close_button.height()+5,left:closeX,position:position});
	};
	
	function load(){
		overlay.css('opacity',0.2).show();
		overlay.unbind('click');//.click(function(){	if(!options.hide_close){ $.dialog_close();}	});
		close_button.unbind('click').click(function(){	$.dialog_close();return false;	}).hide();
		content.hide();
		
		//size to element position (for zoom effect)
		if(dialogbox.filter(':hidden').length){
			var scroll = _getPageScroll();
			dialogbox.css({width:element.width(),height:element.height(),top:element.offset().top-scroll.y,left:element.offset().left-scroll.x});
		}

		//hide flash (cannot be overlayed)
		$('embed').css('visibility','hidden');
		
		//if is image is supplied & set max width/height
		if(options.image){
			
			//Show Loading Icon
			options.hide_close = 1;
			loaded('<div class="loading">loading...</div>');
			options.hide_close = 0;
			html = '<img class="box-img" src="'+options.image+'" />';
			$(html).load(function(){
				close_button.hide();
				//set max width / height - return new values
				var newsize = _newsize($(this).attr('width'),$(this).attr('height'),800,1000);
				
				html = $(html).attr({width:newsize.width,height:newsize.height}).click(function(){close();});
				loaded(html);
			});
		//if html content is supplied
		}else if(options.content){
			loaded();
		}
	};
	function loaded(html){
		var html = html || options.content;
		dialogbox.show();

		//get content width/height & limit to max width
		//var height = $(html).attr('height') || parseInt($(html).css('height')) || options.width || 100;
		//var width = $(html).attr('width') || parseInt($(html).css('width')) || options.height || 100;
		
		//change width to actual content if we can
		content.hide().html(html);
		
		var width = options.width || content.width() || 300;
		var height = options.height || content.height() || 300;
		
		//Animate to new position
		var size = _getPageSize();
		var scroll = _getPageScroll();
		var dialogbox_top = size.windowHeight<height?scroll.y+15:(size.windowHeight/2)-(height/2);
		var position = size.windowHeight<height?'absolute':'fixed';
		dialogbox.css({position:position});
		close_button.hide();
		dialogbox.stop().animate({width:width,height:height,top:dialogbox_top,left:size.windowWidth/2-(width/2)},250,function(){
			content.fadeIn();
			
			//position and show close button
			var closeX = dialogbox.offset().left+dialogbox.width()-close_button.width();
			var closeY = dialogbox.offset().top-close_button.height()+5;
			var closePosition = dialogbox.css('position');
			if(!options.hide_close){
				close_button.css({left:closeX,top:closeY,position:closePosition}).fadeIn();
			}
			
			//trigger callback function
			if(options.callback) options.callback(this);
			onresize();
		});

	};
	
	$.dialog_close = function(){
		overlay.hide();
		dialogbox.stop().hide();
		close_button.hide();
		$('embed').css('visibility','visible');
	};
	$.dialog_update_size = function(){
    if(!$('#dialogbox:visible').length) return false;
		var width = $('#dialogbox-content').width();
		var height = $('#dialogbox-content').height();
		//Animate to new position
		var size = _getPageSize();
		var scroll = _getPageScroll();
		var dialogbox_top = size.windowHeight<height?scroll.y+15:(size.windowHeight/2)-(height/2);
		var position = size.windowHeight<height?'absolute':'fixed';
		dialogbox.css({position:position});
		dialogbox.animate({width:width,height:height,top:dialogbox_top,left:600-(width/2)},function(){
			onresize();
		});
	};
	
	/**
	 * getPageSize() by quirksmode.com
	 */
	function _getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		return {
			width:pageWidth,
			height:pageHeight,
			windowWidth:windowWidth,
			windowHeight:windowHeight
		};
	};

	/*
	getPageScroll() by quirksmode.com
	 */
	function _getPageScroll() {
		var xScroll, yScroll;
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;	
		}
		return {
			x:xScroll,
			y:yScroll
		};
	};
	/*
	resize values by paul collett
	 */
	function _newsize(currentWidth,currentHeight,maxWidth,maxHeight){
		var ratioWidth = maxWidth/currentWidth;
		var ratioHeight = maxHeight/currentHeight;
		
		if(currentWidth>currentHeight){//landscape
		    var newWidth = maxWidth;
		    var newHeight = Math.ceil(currentHeight*ratioWidth);
		}else{//portarait or correct ratio
		    var newHeight = maxHeight;
		    var newWidth = Math.ceil(currentWidth*ratioHeight);
		}	
		return {width:newWidth,height:newHeight};	
	}

}

