$(document).ready(function() {
	// Shorten header images
	$("img[src*='/top_images/']").css({ marginTop: "-190px" }).parents("div:first").css({ height: "100px", overflow: "hidden" });
	
	// No SSL support
	var rl_Protocol = "http://"; //(("https:" == document.location.protocol) ? "https://" : "http://");
	
	var rl_Host = "www.rigrodskylong.com";
	// Different host if on the development server
	if (location.host.toLowerCase().indexOf("development") >= 0){
		rl_Host = "development.rigrodskylong.com";
	}
	
	// Add stylesheet
	var rl_RigrodskyLongStyle = document.createElement('link');
	rl_RigrodskyLongStyle.href = rl_Protocol + rl_Host + "/addon.css";
	rl_RigrodskyLongStyle.type = "text/css";
	rl_RigrodskyLongStyle.rel = "stylesheet";
	rl_RigrodskyLongStyle.id = "RigrodskyLongCSS";
	
	// Add elements to the document head
	var rl_Head = document.getElementsByTagName("head").item(0);
	rl_Head.appendChild(rl_RigrodskyLongStyle);
	
	// Current path
	var path = location.pathname.toLowerCase();
	
	// If the form is present, let's set it up
	if ($("#inline-form").length > 0){

		// Load other scripts and proceed
		$.getScript(rl_Protocol + rl_Host + "/jquery/jquery.jqURL.js", function() {
		
			// Url to the embedded contact form
			var contactUrl = rl_Protocol + rl_Host + '/Contact-Embedded.php';
			
			var intro = '';
			
			// Contact form for news releases
			if (path.indexOf("/news/") >= 0){
				$("#our-offices").before('<p class="note">If you own this stock, have information about this case, would like to learn more or wish to discuss this matter conerning your rights or interests, contact us now:</p><a href="#join-action"><img src="' + rl_Protocol + rl_Host + '/images/JoinTheActionButton.png" alt="Join the action" border="0" id="join-action-btn" /></a>');
				
				// Hide contact methods
				$(".contact-methods").hide();
				$("#header p:first").hide();
				
				contactUrl = contactUrl + '?url=' + path.replace("/news/", "");
				//iframeHeight = "1115";
				
				intro = '<a name="join-action"></a><h4>Join the action:</h4>';
				
				$("p:contains('CONTACT:')").hide();
			}
			// Contact form for all other cases
			else{
				//iframeHeight = "1115";
			}

			// iframe the contact form
			$("#inline-form").replaceWith('<div>' + intro + '<iframe id="contactframe" src="' + contactUrl + '" style="height: ' + iframeHeight + 'px; width: 596px; border: 0px;" frameborder="0" scrolling="no"></iframe></div>');
		})
	}
	else{
		if ((path.indexOf("invcontact.php") < 0) && (path.indexOf("joinmailer.php") < 0)){
			$("#header a:first").attr("href", "/contact.php").removeAttr("onclick").html('<img src="' + rl_Protocol + rl_Host + '/images/ContactButton.png" alt="Contact us for a free consultation" border="0" id="contact-btn" />');
		}
	}
});