/* Copyright (c) 2009 Alvaro A. Lima Jr http://alvarojunior.com/jquery/joverlay.html
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * Version: 0.8 (OUT 19, 2009)
 * Requires: jQuery 1.3+
 * Packer from http://dean.edwards.name/packer/
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(7($){3 h=$.W.1p&&$.W.1q==6.0;3 i=E;$.A.j=7(b){1($(\'#j\').1r){$.t()}1(i!==E){1s(i)}3 b=$.I({},$.A.j.u,b||{});3 c=b.X||b.J;3 d=k.Y(\'*\')?k:\'#4\';3 e=h?\'1t\':\'1u\';3 f=/([^\\/\\\\]+)\\.(1v|1w|1x|1y|1z)$/i.1A(b.n);3 g=b.K?"<Z L=\'B\' 10=\'"+b.K+"\' 11=\'M:"+e+"; z-12:"+(b.D+9)+";\'/>":\'\';7 8(a){1(b.8){$.8(a)}N 1(h){$.8(\'#4\',{\'O\':$(o).13()+\'p\',\'14\':\'\',\'15\':\'\',\'P\':\'\'})}}$(\'1B\').1C(g+"<16 L=\'j\' />"+"<16 L=\'4\' 11=\'M:"+e+"; z-12:"+(b.D+5)+"; C:17;\'/>");$(\'#4\').q(\'u\',b);$(\'#B\').18(7(){8(k)});1(h){$(\'Q\').1D();$(\'#4 Q\').v()}$(\'#j\').r({\'1E\':b.19,\'M\':e,\'O\':\'1a\',\'P\':\'1a\',\'1F\':\'1G(s=\'+(b.s*R)+\')\',\'s\':b.s,\'-1H-s\':b.s,\'-1I-s\':b.s,\'D\':b.D,\'m\':!h?\'R%\':$(o).m()+\'p\',\'l\':!h?\'R%\':$(F).l()+\'p\'}).v();1($.1J(b.w)){$(d).w(b.w)}1(k.Y(\'*\')){$(\'#4\').q(\'S\',k.1K());$(\'#4\').w(k.v().q(\'C\',b.1b?\'17\':k.r(\'C\')));1(!f){8(\'#4\');$(\'#4\').v();1(!b.n&&$.T(c)){c(k)}}}1(f){$(\'<Z/>\').18(7(){3 a=$.U(k.m,k.l);$(k).r({m:a.m,l:a.l});$(d).w(k);8(\'#4\');8(\'#B\');$(\'#B\').1c(1d);$(\'#4\').v();1($.T(c)){c($(d))}}).1e(7(){1f(\'1L (\'+b.n+\') 1g 1h.\');$.t()}).1M({\'10\':b.n,\'1N\':b.n})}1(b.n&&!f){$.1O({1P:b.1i,q:b.q,n:b.n,J:7(a){$(\'#B\').1c(1d);$(d).w(a).v();8(\'#4\');1($.T(c)){c(a)}},1e:7(){1f(\'1Q (\'+b.n+\') 1g 1h.\');$.t()}})}1(h){$(o).1R(7(){8(\'#4\')});$(o).U(7(){$(\'#j\').r({\'m\':$(o).m()+\'p\',\'l\':$(F).l()+\'p\'});8(\'#4\')})}1(b.1j){$(F).1k(7(a){1(a.1S==1T){$.t()}})}N{$(F).1U(\'1k\')}1(b.1l){$(\'#j\').1V($.t)}1(b.G&&1m(b.G)>0){i=o.1W($.t,1m(b.G))}$(\'#4\').r(b.r||{})};$.U=7(a,b){3 x=$(o).m()-1n;3 y=$(o).l()-1n;1(a>x){b=b*(x/a);a=x;1(b>y){a=a*(y/b);b=y}}N 1(b>y){a=a*(y/b);b=y;1(a>x){b=b*(x/a);a=x}}1X{\'m\':a,\'l\':b}};$.8=7(a,b){3 a=$(a);3 c=a.m();a.r($.I({},{\'m\':c+\'p\',\'14\':\'-\'+(c/2)+\'p\',\'15\':\'-\'+a.l()/2+\'p\',\'l\':\'1Y\',\'O\':!h?\'1o%\':$(o).13()+($(o).l()/2)+\'p\',\'P\':\'1o%\'},b||{}))};$.A.j.u={\'1i\':\'1Z\',\'q\':\'\',\'n\':\'\',\'19\':\'#20\',\'s\':\'0.6\',\'D\':21,\'8\':H,\'K\':\'\',\'1l\':H,\'J\':E,\'X\':E,\'G\':0,\'1b\':H,\'r\':{},\'w\':\'\',\'1j\':H};$.A.j.22=7(a){$.A.j.u=$.I({},$.A.j.u,a||{})};$.t=7(){3 a=$(\'#4\');3 b=a.q(\'u\');3 c=a.q(\'S\');1(h){$("Q").v()}1(c){3 d=a.23();c.24(d.r(\'C\',d.q(\'C\')));d.V(\'C\');a.V(\'S\')}a.V(\'u\');$(\'#B, #4, #j\').25()}})(26);',62,131,'|if||var|jOverlayContent|||function|center|||||||||||jOverlay|this|height|width|url|window|px|data|css|opacity|closeOverlay|options|show|html||||fn|jOverlayLoading|display|zIndex|null|document|timeout|true|extend|success|imgLoading|id|position|else|top|left|select|100|jOverlayElementPrev|isFunction|resize|removeData|browser|onSuccess|is|img|src|style|index|scrollTop|marginLeft|marginTop|div|none|load|color|0px|autoHide|fadeOut|500|error|alert|not|found|method|closeOnEsc|keydown|bgClickToClose|Number|150|50|msie|version|length|clearTimeout|absolute|fixed|png|gif|jpeg|jpg|bmp|test|body|prepend|hide|backgroundColor|filter|alpha|khtml|moz|trim|prev|Image|attr|alt|ajax|type|URL|scroll|keyCode|27|unbind|click|setTimeout|return|auto|GET|000|9999|setDefaults|children|after|remove|jQuery'.split('|'),0,{}))
$(document).ready(function(){	

	if($("div#navholder").length > 0){
		$('#navigationMenu li .normalMenu').each(function(){
			$(this).before($(this).clone().removeClass().addClass('hoverMenu'));
		});

		$('#navigationMenu li').hover(function(){
			$(this).find('.hoverMenu').stop().animate({marginTop:'0px'},200);
		},
		function(){
			$(this).find('.hoverMenu').stop().animate({marginTop:'-25px'},200);
		});
	}

	if($("div#scnm-navholder").length > 0){
		$('ul#navigationMenu li .normalMenu').each(function(){
			$(this).before($(this).clone().removeClass().addClass('hoverMenu'));
		});

		$('ul#navigationMenu li').hover(function(){
			$(this).find('.hoverMenu').stop().animate({marginTop:'0px'},200);
		},
		function(){
			$(this).find('.hoverMenu').stop().animate({marginTop:'-25px'},200);
		});
	}
	
	if($("div#websites-options").length > 0){

		$("div.website-content").hide();
		$('a.website-list-item2').click(function (e) {
		$("div#website-content-intro").hide();
			$("div.website-content").hide().filter(this.hash).fadeIn("slow");
			e.preventDefault();											   			
		});	
	}
	$('#webmot').click(function(e) {
		$("#webmot-text").jOverlay();
		e.preventDefault();											   			
	});	
	$('input#webmotsub').click(function(e){
	
		var webmotval = $('input#webmotyes').val();
		$('input#webmotsub').attr('disabled','disabled').attr('value','Submitting...');
		
		$.post("/inc/process_website_mot.php", { webmot: webmotval },
		   function(result){
			 if(result == '0'){
				$('#motstatus').html('<p style="color:red;">Submission failure; try again!');
				$('input#webmotsub').attr('disabled','').attr('value','Submit');					
			 } else {
				$('#motstatus').html('<p style="color:green;">Thanks!  We\'ll be in touch with further details.');
				$('input#webmotyes').hide();					
				$('input#webmotsub').hide();
				$("#webmot-text, div.lb_overlay").delay(4000).fadeOut('slow');					
			 }				 
		   });
		e.preventDefault();											   			
	
	});
	if($('div#budget-form-container').length > 0){
		$('div#budget-form-container').hide();		
		$('img#show-budget-form').click(function (e) {
			$('div#budget-form-container').slideToggle('slow');			
			e.preventDefault();											   			
		});	
	}
	if($('div#basic-form-container').length > 0){
		$('div#basic-form-container').hide();		
		$('img#show-basic-form').click(function (e) {
			$('div#basic-form-container').slideToggle('slow');			
			e.preventDefault();											   			
		});	
	}
	if($('div#premium-form-container').length > 0){
		$('div#premium-form-container').hide();		
		$('img#show-premium-form').click(function (e) {
			$('div#premium-form-container').slideToggle('slow');			
			e.preventDefault();											   			
		});	
	}
	$('input.webenq').click(function(e){
		var type = $(this).attr('id');
		var type2 = type.substr(0, 1).toUpperCase() + type.substr(1);
		$("input#" + type).attr("disabled","disabled").attr("value","Submitting...");
		var name = $("input#" + type + "-name").val();
		var email = $("input#" + type + "-email").val();
		var phone = $("input#" + type + "-phone").val();
		var notes = $("textarea#" + type + "-notes").val();
		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&notes=' + notes + '&type=' + type;
		$.ajax({
		  cache:false,
		  type: "POST",
		  url: "/inc/process_website_enquiry.php",
		  data: dataString,
		  success: function(data) {
				if (data == 'err'){
					$('#' + type + '-status').html("<p style='color:#FF0000;'>Form Failure!  Check for a valid email address, empty fields and try again.</p>")
					.fadeIn('fast', function() {
						$('#' + type + '-status');
					}).delay(5000).fadeOut('fast', function(){
						$('#' + type + '-status');					
					});		
					$("input#" + type).attr("disabled","").attr("value","Submit " + type2 + " Website Enquiry");
				} else {
					$('#' + type + '-status').html("<p style='color:#005830;'><img src='/img/tick-small.jpg' align='absmiddle' /> Thanks! Your enquiry has been emailed to Sunshine Coast New Media.</p><p style='color:#005830;'>We look forward to discussing your website!</p>")
					.fadeIn(1500, function() {
						$('#' + type + '-status');
					}).delay(5000).fadeOut('fast', function(){
						$('#' + type + '-status');					
					});		
					$("input#" + type).attr("disabled","").attr("value","Submit " + type2 + " Website Enquiry");	
					$(':input','#' +  type + '-form').not(':button, :submit, :reset, :hidden').val('');
				}  
			}	
		});
		e.preventDefault();											   			
	});
	// clear form buttons
	$(':input','#budget-form').not(':button, :submit, :reset, :hidden').val('');
	$(':input','#basic-form').not(':button, :submit, :reset, :hidden').val('');
	$(':input','#premium-form').not(':button, :submit, :reset, :hidden').val('');
	
	if($("div#home-content-box").length > 0){
		$.getScript("/_jscripts/jquery.corner.js", function(){
			$('div.dogear').corner();
		});
	}
	$('a.wedlink').live('click', function(e){
		range = $(this).attr('r');
		e.preventDefault();											   
		$('div#weddings-content').html('<p><img src="/img/loader.gif" align="absmiddle" /> Please wait; images loading...</p>').load('/weddings/range.inc.php?range=' + range);
	});
	$('a#showprices').live('click',function(e){
		e.preventDefault();
		$(this).text($(this).text() == 'Hide Wedding Stationery Price List' ? 'View Wedding Stationery Price List' : 'Hide Wedding Stationery Price List');
		$('div#price-list').slideToggle().html('<p><img src="/img/loader.gif" align="absmiddle" /> Please wait; Price List loading...</p>').load('/weddings/prices.inc.php');
	});
	$('a#showsizes').live('click',function(e){
		e.preventDefault();
		$(this).text($(this).text() == 'Hide Wedding Stationery Size Information' ? 'View Wedding Stationery Size Information' : 'Hide Wedding Stationery Size Information');
		$('div#sizes').slideToggle('slow').html('<p><img src="/img/loader.gif" align="absmiddle" /> Please wait; Sizes loading...</p>').load('/weddings/sizes.inc.php');
	});
	$("#submit_btn").click(function() {

		$("#submit_btn").attr("disabled","disabled").attr("value","Submitting...");
		var text = $("textarea#text").val();
		var email = $("input#email").val();
		var name = $("input#name").val();

		var dataString = 'name='+ name + '&email=' + email + '&text=' + text;
		
		$.ajax({
		  cache:false,
		  type: "POST",
		  url: "/inc/process_contact_form.php",
		  data: dataString,
		  success: function(data) {
			if (data == 'invalid'){
				$('#page-blurb').html("<h2>Form Failure!</h2><p>Click \"Contact Us\" to reload the page and try again</p><p>Please check for invalid data (eg. email address typo)").fadeIn(1500, function() {
				  $('#page-blurb');
				});		
			} else {
				$('#page-blurb').html("<h2>Contact Form Submitted!</h2>")
				.append("<img src='img/tick.jpg' style='float:left;'><p style='float:left;'>Thanks!  Your enquiry has been emailed to Sunshine Coast New Media.</p>").fadeIn(1500, function() {
				 $('#page-blurb');
				});
				return false;
			}  
		}
		});
		return false;

	});	
	$('input#get-promo').click(function(e){
				
			var pc = $('input#promo').val();
		
			$('input#get-promo').attr('value','Applying...');
		
			$.ajax({
			  cache:false,
			  type: "GET",
			  url: "/inc/process_website_promocode.php?pc=" + pc,
			  success: function(data) {
					if (data == 'err'){
						alert('Not a valid Promotion!')
						$('input#get-promo').attr('value','Apply Discount');
					} else if(data == 'exp'){
						alert('Sorry, this promotion has expired! You can still contact us for great website packages though...')
						$('input#get-promo').attr('value','Apply Discount');						
					} else {
						location.reload();
					}  
				}	
			});		
			e.preventDefault();
	});
	$('div.tile').mouseover(function(e){
		$('span#' + $(this).attr('id') + '-text').show();
	}).mouseout(function(e){
		$('span#' + $(this).attr('id') + '-text').hide();
	});	
	if($("div.website-portfolio-container").length > 0){
		$('a.web-preview').click(function(e){
			$('div#portfolio-preview').jOverlay({url: '/img/web/' + $(this).attr('id') + '_large.jpg', imgLoading : '/img/loader.gif'});
			e.preventDefault();
		});
	}
	if($("div#gd-thumb-strip").length > 0){
		$('img.gd').click(function(e){
			$('div#gd-preview').hide().html('<img src="/img/gd/graphics_' + $(this).attr('id') +'.jpg" />').fadeIn('slow');
		});
	}
	if($("div#inv-thumb-strip").length > 0){
		$('img.inv').click(function(e){
			$('div#inv-preview').hide().html('<img src="/img/inv/invites_' + $(this).attr('id') +'.jpg" />').fadeIn('slow');
		});
	}		
});
