// JavaScript Document
$(document).ready(function() {
	$('#search label').click(function() {
		$('#searchform').submit();
	});

	// H1s ==================================================================
	$("#postpage h1.ask-a-question").css({
		'padding':	'0px',
		'width':	'600px',
		'height':	'80px'}).html('<img src="/wp-content/themes/myhomelife/images/h1-ask-a-question.png" width="600" height="80" alt="Ask a Question" />');
	$("#postpage h1.join-mhl").css({
		'padding':	'0px',
		'width':	'600px',
		'height':	'80px'}).html('<img src="/wp-content/themes/myhomelife/images/h1-join-mhl.png" width="600" height="80" alt="Join My Home Life Magazine" />');
	$("#postpage h1.diy-household-tips").css({
		'padding':	'0px',
		'width':	'600px',
		'height':	'80px'}).html('<img src="/wp-content/themes/myhomelife/images/h1-diy-household-tips.png" width="600" height="80" alt="Do It Yourself &amp; Household Tips" />');
	$("#postpage h1.mhl-magazine").css({
		'padding':	'0px',
		'width':	'600px',
		'height':	'80px'}).html('<img src="/wp-content/themes/myhomelife/images/h1-mhl-magazine.png" width="600" height="80" alt="My Home Life Magazine" />');

	// INTRO ================================================================
//	$("#footer").hide();
	for(r = 1; r <= 6; r++){
		for(c = 1; c <= 8; c++){
			$("#intro").html($("#intro").html()+'<div id="intro-'+ r +'-'+ c +'" class="r'+ r +' c'+ c +'"></div>');
		}
	}
	$("#intro").css('background', 'none');
	$("#intro img").delay(1500).fadeOut(5000);
	for(r = 6; r > 0; r--){
		for(c = 8; c > 0; c--){
			myDelay = ((r/0.20-c)*100)+1500;
		//	$("#intro-"+ r +"-"+ c).html(myDelay);
			$("#intro-"+ r +"-"+ c).delay(myDelay).fadeOut(1000);
		}
	}
	$("#intro").delay(myDelay+3000).fadeOut();
	$("#footer").delay(myDelay+3000).fadeIn();
//	$("#intro").hide();

	// MHL ==================================================================
	$('#home-block-mhl').mouseover(function() {
	/*	$('#home-block-mhl').animate({
				'width': '500px',
				'height': '200px'
		}, 1000);	*/
		$('#home-block-mhl').css({
				'width': '500px',
				'height': '200px'
		});
	});
	$('#home-block-mhl').mouseout(function() {
	/*	$('#home-block-mhl').animate({
				'width': '200px',
				'height': '100px'
		}, 1000);	*/
		$('#home-block-mhl').css({
				'width': '200px',
				'height': '100px'
		});
	});

	// SPONSORS =============================================================
	$('#home-block-sponsors').mouseover(function() {
		$("#home-block-sponsors-image").hide();
		$("#home-block-sponsors-text").show();
		$('#home-block-sponsors').css({
				'width': '300px',
				'height': '279px',
				'margin-top': '-179px',
				'margin-left': '-200px'
		});
	});
	$('#home-block-sponsors').mouseout(function() {
		$("#home-block-sponsors-text").hide();
		$("#home-block-sponsors-image").show();
		$('#home-block-sponsors').css({
				'width': '100px',
				'height': '100px',
				'margin-top': '0px',
				'margin-left': '0px'
		});
	});

	// JOIN MHL =============================================================
	$('#home-block-join').mouseover(function() {
		$("#home-block-join-text").show();
		$('#home-block-join').css({
				'height': '200px',
				'margin-top': '-100px'
		});
		$('#home-block-join-image').css({
				'margin-top': '100px'
		});
	});
	$('#home-block-join').mouseout(function() {
		$("#home-block-join-text").hide();
		$('#home-block-join').css({
				'height': '100px',
				'margin-top': '0px'
		});
		$('#home-block-join-image').css({
				'margin-top': '0px'
		});
	});

	// MHL FORUM ============================================================
	$('#home-block-forum').mouseover(function() {
		$('#home-block-forum').css({
				'width': '400px'
		});
	});
	$('#home-block-forum').mouseout(function() {
		$('#home-block-forum').css({
				'width': '100px'
		});
	});

	// ASK A QUESTION  ======================================================
	$('#home-block-ask').mouseover(function() {
		$("#home-block-ask-text").show();
		$('#home-block-ask').css({
				'width': '300px',
				'height': '200px',
				'margin-top': '-100px'
		});
		$('#home-block-ask-image').css({
				'margin-top': '100px'
		});
	});
	$('#home-block-ask').mouseout(function() {
		$("#home-block-ask-text").hide();
		$('#home-block-ask').css({
				'width': '100px',
				'height': '100px',
				'margin-top': '0px'
		});
		$('#home-block-ask-image').css({
				'margin-top': '0px'
		});
	});

	// DIY TIPS =============================================================
	$('#home-block-tips').mouseover(function() {
		$("#home-block-tips-text").show();
		$('#home-block-tips').css({
				'height': '300px',
				'margin-top': '-200px'
		});
		$('#home-block-tips-image').css({
				'margin-top': '200px'
		});
	});
	$('#home-block-tips').mouseout(function() {
		$("#home-block-tips-text").hide();
		$('#home-block-tips').css({
				'height': '100px',
				'margin-top': '0px'
		});
		$('#home-block-tips-image').css({
				'margin-top': '0px'
		});
	});

	// VALIDATE FORMS =======================================================
	$('#forumSignup').validate();
	$('#ccoptin').validate();

	// CYCLE ===================================================================
	$('#right-col').cycle({
		fx:			'fade',								// choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed:		5000,
		timeout:	2000
	});
});
