window.onload = changenewsform;

function changenewsform() {
	//when the error fields display the newsletter needs its height changed, main code doesn't resize iframe
	var $newsIFrame = $('#innerIframe');
	var $newsSubmit = $newsIFrame.contents().find('body p#submitWrapper input#submit');
	var $test = $newsIFrame.contents().find('body').filter("p:first").text();
	
	//submit has no value, see /BrandContact/js/gallo.newsletterFrom.js line 6, this fixes that for now
	if ($newsSubmit.val() != 'Submit') {
		$newsSubmit.val('Submit');
	}
	
	$($newsSubmit).click(function() {
		if ($newsIFrame.contents().find('body ul#error-list').length > 0) {
		$('#innerIframe').css('height','840px').css('margin-top','3px');
		//if there are still errors on a subsequent submit this will execute
		} else {
			
			if ( ($newsIFrame.contents().find('body').filter("p:first").text()) === ('Thank you for signing up for the Ecco Domani newsletter.') ) { 
				$('#innerIframe').css('height','400px').css('margin-top','3px');
				//currently the response 'thank you' iframe has html#iframe, this error is preventing jquery access to elements
				} else {
				$('#innerIframe').css('height','840px').css('margin-top','3px');
				//this executes on first submit, currently on thank you response 1.5.2011
				}
			
		}
	});
	
	
	
}




