var gAutoPrint = true; // Flag for whether or not to automatically call the print function
function printPage()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		html += '\n';
		html += '\n</HEAD>\n<BODY >\n';
		
		//var printMeElem = document.all.test.src;
		//for( i in printMeElem){
		//document.write(i)
		//}
		//var printMeElem =  document.map.src;
		var printMeElem = document.getElementById('map').src
		//alert(printMeElem);
		if (printMeElem != null)
		{
				//html +="<img src='/scripts/%22%20+%20printMeElem%20+%20%22' width=100%>";
				html +="<img src='" + printMeElem + "' width=100%>";
				//alert(html);
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</BODY>\n</HTML>';
		var printWin = window.open("","printmap","scrollbars=yes, addressbar=no, width=730, height=530, left=0");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
		printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}

function downloadJpg(){
/*		jpgFile = document.getElementById("map").src;
		jpg_File = jpgFile.split("/");
		//alert(jpg_File);
		jpegFile = " ";
			for(i=0; i< jpg_File.length; i++){
			if(i >= jpg_File.length-2){
					jpegFile += jpg_File[i] + "/";
					//alert(jpegFile);
			}
			}
		jpegFile  = jpegFile.slice(1,jpegFile.length-1);
		//alert(jpegFile);
		if(document.all){

		jpgFile1 = window.location.pathname;

		str1 = jpgFile1.split("/")
		jpgFile2 =" ";

		for(i=0; i<str1.length; i++){
			if(i >= str1.length-4 && i <= str1.length-4 ){
					jpgFile2 += str1[i] + "/";
				}
			}
		jpgFile2  = jpgFile2.slice(1,jpgFile2.length-1);
		jpgFile3 = jpgFile2 + "/" + jpegFile; // 
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";

		} else {

		jpgFile3 =" ";
		str2 = jpgFile.split("/")
			for(i=0; i<str2.length; i++){
				if(i >= str2.length-3){
					jpgFile3 += str2[i] + "/";
					}
			} 

		jpgFile3 = jpgFile3.slice(1,jpgFile3.length-1);
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";
		}*/


		
		jpgFile = document.getElementById("map").src;

		if(document.all){

		jpgFile1 = window.location.pathname;
		str1 = jpgFile1.split("/")
		jpgFile2 =" ";

		for(i=0; i<str1.length; i++){
			if(i >= str1.length-3 && i <= str1.length-2 ){
					jpgFile2 += str1[i] + "/";
				}
			}
		jpgFile2  = jpgFile2.slice(1,jpgFile2.length-1);
		jpgFile3 = jpgFile2 + "/" + jpgFile;
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";

		} else {

		jpgFile3 =" ";
		str2 = jpgFile.split("/")
			for(i=0; i<str2.length; i++){
				if(i >= str2.length-4){
					jpgFile3 += str2[i] + "/";
					}
			} 

		jpgFile3 = jpgFile3.slice(1,jpgFile3.length-1);
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";
		}


}

function downloadJpg1(){
		jpgFile = document.getElementById("map").src;

		if(document.all){

		jpgFile1 = window.location.pathname;
		str1 = jpgFile1.split("/")
		jpgFile2 =" ";

		for(i=0; i<str1.length; i++){
			if(i >= str1.length-3 && i <= str1.length-2 ){
					jpgFile2 += str1[i] + "/";
				}
			}
		jpgFile2  = jpgFile2.slice(1,jpgFile2.length-1);
		jpgFile3 = jpgFile2 + "/" + jpgFile;
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";

		} else {

		jpgFile3 =" ";
		str2 = jpgFile.split("/")
			for(i=0; i<str2.length; i++){
				if(i >= str2.length-4){
					jpgFile3 += str2[i] + "/";
					}
			} 

		jpgFile3 = jpgFile3.slice(1,jpgFile3.length-1);
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";
		}
}

function downloadJpggolbal(){
/*		jpgFile = document.getElementById("map").src;

		if(document.all){

		jpgFile1 = window.location.pathname;
		str1 = jpgFile1.split("/")
		jpgFile2 =" ";

		for(i=0; i<str1.length; i++){
			if(i >= str1.length-3 && i <= str1.length-2 ){
					jpgFile2 += str1[i] + "/";
				}
			}
		jpgFile2  = jpgFile2.slice(1,jpgFile2.length-1);
		jpgFile3 = jpgFile2 + "/" + jpgFile;
		//alert("/DownloadServlet.jsp?download=web/" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";

		} else {

		jpgFile3 =" ";
		str2 = jpgFile.split("/")
			for(i=0; i<str2.length; i++){
				if(i >= str2.length-3){
					jpgFile3 += str2[i] + "/";
					}
			} 

		jpgFile3 = jpgFile3.slice(1,jpgFile3.length-1);
		//alert("/DownloadServlet.jsp?download=web/" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";
		}*/




		jpgFile = document.getElementById("map").src;

		if(document.all){

		jpgFile1 = window.location.pathname;
		str1 = jpgFile1.split("/")
		jpgFile2 =" ";

		for(i=0; i<str1.length; i++){
			if(i >= str1.length-3 && i <= str1.length-2 ){
					jpgFile2 += str1[i] + "/";
				}
			}
		jpgFile2  = jpgFile2.slice(1,jpgFile2.length-1);
		jpgFile3 = jpgFile2 + "/" + jpgFile;
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";

		} else {

		jpgFile3 =" ";
		str2 = jpgFile.split("/")
			for(i=0; i<str2.length; i++){
				if(i >= str2.length-4){
					jpgFile3 += str2[i] + "/";
					}
			} 

		jpgFile3 = jpgFile3.slice(1,jpgFile3.length-1);
		//alert("/DownloadServlet.jsp?download=" + jpgFile3 + "");
		location.href="/DownloadServlet.jsp?download=" + jpgFile3 + "";
		}




}

