function closeUrModal() {
	// 2009.11.19 DLS: Call to parent window function to properly close the Iframe fix
	window.parent.closeWindowModal()
}

// 2009.11.19 DLS: Close dialog window 
function closeWindowModal() {
	var tag;
	tag = window.document.body;
	$(tag).children(".ui-widget-overlay").remove();
	$(tag).children(".ui-dialog").remove();
}

function submitgetQuoteForm()
{
  thisIframe.document.forms['getQuoteForm'].submit();
}
 

$(document).ready(function(){ 

	$('.modal').click(function(){

		// 2009.10.13 KJD: Added if we want absolutes
		var strUrl	= $(this).attr('href');
		if(	( strUrl.length > 0 ) && ( "/" == strUrl.substr(0, 1) )	)	{	strUrl=window.location.protocol+"//" + window.location.host+strUrl;	}

		serverFlag=window.location.hostname.toString();
			
		var pageUrl = getPageUrl($(this).attr('href'));
		var serverPort = (location.port != "") ? ":"+location.port : "";
			
		params = checkModalDefaults(pageUrl);
		params = getParams($(this).attr('href'),params);

		// set chrome values (check for buttons)
		var yChrome = 16;
		var xChrome = (typeof params.buttons == 'undefined') ? 0 : 65;
		xChrome += (typeof params.title == 'undefined') ? 0 : 55; 
	
		//alert(params.buttons);
	
		var iHeight = params.height; 
		var iWidth = params.width;
		
		params.height = params.height + xChrome;
		params.width = params.width + yChrome;

		var thisSrc	= ( ( strUrl.indexOf( 'http://' ) > -1 )? ( strUrl ) : ("'http://" + serverFlag + serverPort + pageUrl) );
		
		// 2009.10.14 KJD: Make work in IE
		$(this)
			.after("<div class='clear'></div>")
			.next()
			.dialog(params)
			.html("<iframe width='" + iWidth + "' name='thisIframe' height='" + iHeight + "' frameborder='0' scrolling='auto' allowtransparency='true' src='" + thisSrc + "' ></iFrame>");
		$(".ui-dialog-buttonpane button:nth-child(1)").addClass("primary")
		$(".ui-dialog-buttonpane button:nth-child(2)").addClass("secondary");
		return false;
	});
			
	if($('#closeWindowModal').length>0){
		window.top.location = window.top.location ;
		var tag;
		tag = window.top.document.body;
		$(tag).children(".ui-widget-overlay").remove();
		$(tag).children(".ui-dialog").remove();
	}

//	if($('#closeModal').length>0){
//		$('#closeModal').click(function(){
//			 closeUrModal();
//		});
//	}
});	
