/* Begin - ASPX Postback Cancel Script src: http://www.irt.org/script/1693.htm */
if (window.captureEvents){
    window.captureEvents(Event.KEYDOWN);
    window.onkeydown = CheckKeyPress;    
} else {
   document.onkeydown = CheckKeyPress;
}

function CheckKeyPress(e){
    var el = (typeof event!=='undefined')? event.keyCode: e.which;
    //alert(el);
    if(el == 13){
        return false;
    }
    else{
        return true;
    }
}

/* End - ASPX Postback Cancel Script */

function encodeMyHtml(htmlToEncode) {
    encodedHtml = escape(htmlToEncode);
    encodedHtml = encodedHtml.replace(/\//g,"%2F");
    encodedHtml = encodedHtml.replace(/\?/g,"%3F");
    encodedHtml = encodedHtml.replace(/=/g,"%3D");
    encodedHtml = encodedHtml.replace(/&/g,"%26");
    encodedHtml = encodedHtml.replace(/@/g,"%40");
    return encodedHtml;
} 

$(function() 
{
	//Function called on the "Enter" keyup event
	//Calls the Map_SearchButton click event
	$("#Map_Query:text").keyup(function(event)
	{
		if(event.keyCode == 13)
		{
			$('#Map_SearchButton').click();
                                            
		}
	});

	//Click function to load the map and the SimpleModal Plugin
	$('#Map_SearchButton').click(function(){
		var src = 'http://www.batchgeo.com/map/?i=7c415297ec16b7278b4845f556292b48&q=' + encodeMyHtml(document.getElementById('Map_Query').value);
		$.modal('<div><div class="MapLinks"><a class="Close" href="#">Close</a></div><iframe id="MapFrame" name="MapFrame" src="' + src + '" height="500" width="800" style="border:0"></div>', {
        	closeClass: "Close",
		opacity:80,
		overlayCss: {backgroundColor:"#fff"},
		containerCss:{
			backgroundColor:"#333",
			borderColor:"#333",
			height:500,
			padding:25,
			width:800
		},
		overlayClose:true
		});
                $('.Print').bind('click', function() {
                    window.print();
return false;
                });
	});
});
