﻿// JScript File

function WriteLatLon(lblLat, lblLon, lat, lon) {
	WriteStatus('<span class=jAWARDVE_Statusbar_Copy title="Copy Latitude" onclick=ClipBoard("' + lat + '");  onmouseover="showStatus(\'Click to add this latitude to your clipboard...\');" onMouseOut="return showStatus(\'\');">' + lblLat + lat + '</span> <span class=jAWARDVE_Statusbar_Copy title="Copy Longitude" onclick=ClipBoard("' + lon +'"); onmouseover="showStatus(\'Click to add this longitude to your clipboard...\');" onMouseOut="return showStatus(\'\');">' + lblLon + lon + '</span>');
}                            

function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function ClipBoard(str) 
{
	if (str != "")
	{
		window.clipboardData.setData("Text", str);		
		showStatus(str + " is now copied to your clipboard.");
	}
}

function WriteStatus(str)
{
	document.getElementById('jAWARDVE_message').innerHTML = str;	
}

//ALERT FUNCTIONALITY

/************************************
	Custom Alert Demonstration
	version 1.0
	last revision: 02.02.2005
	steve@slayeroffice.com

	Should you improve upon this source please
	let me know so that I can update the version
	hosted at slayeroffice.

	Please leave this notice in tact!
************************************/

//var DragHandler = {


//	// private property.
//	_oElem : null,


//	// public method. Attach drag handler to an element.
//	attach : function(oElem) {
//		oElem.onmousedown = DragHandler._dragBegin;
//       // callbacks
//	oElem.dragBegin = new Function();
//	oElem.drag = new Function();
//	oElem.dragEnd = new Function();
//    return oElem;
//	},


//	// private method. Begin drag process.
//	_dragBegin : function(e) {
//		var oElem = DragHandler._oElem = this;

//		if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
//		if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

//		var x = parseInt(oElem.style.left);
//		var y = parseInt(oElem.style.top);

//		e = e ? e : window.event;
//		oElem.mouseX = e.clientX;
//		oElem.mouseY = e.clientY;

//		oElem.dragBegin(oElem, x, y);

//		document.onmousemove = DragHandler._drag;
//		document.onmouseup = DragHandler._dragEnd;
//		return false;
//	},


//	// private method. Drag (move) element.
//	_drag : function(e) {
//		var oElem = DragHandler._oElem;

//		var x = parseInt(oElem.style.left);
//		var y = parseInt(oElem.style.top);

//		e = e ? e : window.event;
//		oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
//		oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

//		oElem.mouseX = e.clientX;
//		oElem.mouseY = e.clientY;

//		oElem.drag(oElem, x, y);

//		return false;
//	},


//	// private method. Stop drag process.
//	_dragEnd : function() {
//		var oElem = DragHandler._oElem;

//		var x = parseInt(oElem.style.left);
//		var y = parseInt(oElem.style.top);

//		oElem.dragEnd(oElem, x, y);

//		document.onmousemove = null;
//		document.onmouseup = null;
//		DragHandler._oElem = null;
//	}

//};

//    //Begin mouse coordinate capture
//    var IE = document.all?true:false;
//    if (!IE) document.captureEvents(Event.MOUSEMOVE)
//    document.onmousemove = getMouseXY;
//    var tempX = 0;
//    var tempY = 0;
//    function getMouseXY(e) 
//    {
//        if (IE) 
//        { // grab the x-y pos.s if browser is IE
//            tempX = event.clientX + document.body.scrollLeft;
//            tempY = event.clientY + document.body.scrollTop;
//        }
//        else 
//        {  
//            // grab the x-y pos.s if browser is NS
//            tempX = e.pageX;
//            tempY = e.pageY;
//        }  
//        if (tempX < 0){tempX = 0;}
//        if (tempY < 0){tempY = 0;}  
//        return true;
//    }
    
    
    
var ie=document.getElementById('modalContainer');
var nn6=document.getElementById('modalContainer');
var isdrag=false;
var x,y;
var dobj;
function movemouse(e)
{
  if (isdrag)
  {
    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    return false;
  }
}

function selectmouse(e) 
{
    var fobj       = nn6 ? e.target : event.srcElement;
      if (fobj.id=="msghead")
        {
        fobj =document.getElementById('modalContainer');
        var topelement = nn6 ? "HTML" : "BODY";
        if (fobj.id=="modalContainer")
            {
            isdrag = true;
            dobj = fobj;
            tx = parseInt(dobj.style.left+0);
            ty = parseInt(dobj.style.top+0);
            x = nn6 ? e.clientX : event.clientX;
            y = nn6 ? e.clientY : event.clientY;
            document.onmousemove=movemouse;
            return false;
            }
        }
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
    
// constants to define the title of the alert and button text.
var ALERT_TITLE = "Message!";
var ALERT_BUTTON_TEXT = "Close";

if(document.getElementById) 
{
	window.alert = function(title,txt) 
	{
	    ALERT_TITLE = title;
		createCustomAlert(txt);
	};
}

function createCustomAlert(txt) 
{
	d = document;
	if(d.getElementById("modalContainer"))
	{ // if object already found, get back from here
	    return;
	}
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	mObj.style.height = d.documentElement.scrollHeight + "px";
	   
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
    
    if (txt.substring(0,3)!="<b>")
    {
        mObj.style.display="none";
        alertObj.style.display="none";
        return;    
    }
    else
    {
        mObj.style.display="block";
        alertObj.style.display="block";
       // alertObj.style.height=mObj.style.height;
    }
//    mObj.style.visibility="visible";
      
	if(d.all && !window.opera) 
//	alertObj.style.top = document.documentElement.scrollTop + "px";
//	alertObj.style.left =((d.documentElement.scrollWidth - alertObj.offsetWidth)/2)-10 + "px";

    // To bring the Popup in the center of the Module , 
    // we need to get the Module Top property which is stored in the 
    // hidMap hidden field.

    var hidMapVar = document.getElementById('hidMap').value;
    var vMap = document.getElementById(document.getElementById('hidMap').value);
	
	alertObj.style.top = vMap.firstChild.offsetTop+ 10 +  "px"; //  "500 px";//((screen.height/2) - 100) + "px";
	alertObj.style.left =((screen.width/2) - 200) + "px";
  
    msghead=alertObj.appendChild(d.createElement("div"));
    msghead.appendChild(d.createTextNode(ALERT_TITLE));
    msghead.className = "alerttitle";
    msghead.id="msghead";
//    msghead.onmousedown = function () { calldrag();return false; }
//    msghead.onmouseup = function () { detachdrag(); return false; }
    
//    msgsubheadPrint=msghead.appendChild(d.createElement("div"));
//    msgsubheadPrint.id = "alertprint";
//    msgsubheadPrint.className = "alertPrint";
//    msgsubheadPrint.appendChild(d.createTextNode("Print"));
    
    //replaced above 4 lines for print image
    msgsubheadPrint=msghead.appendChild(d.createElement("IMG"));
    msgsubheadPrint.id = "alertprint";
    msgsubheadPrint.className = "alertPrint";
    var url = document.getElementById('hidModulePath').value + "images/print.gif";
    msgsubheadPrint.setAttribute("src",url);
    msgsubheadPrint.setAttribute("width","16");
    msgsubheadPrint.setAttribute("height","16");
    msgsubheadPrint.setAttribute("border","0");
    msgsubheadPrint.setAttribute("title","Print"); // ToolTip
    
    msgsubheadPrint.onclick = function() { printAlert();return false; }
    
//    msgsubhead=msghead.appendChild(d.createElement("div"));
//    msgsubhead.id = "alertclose";
//    msgsubhead.className = "alertclose";
//    msgsubhead.appendChild(d.createTextNode("Close"));

    //replaced above 4 lines for close image
    msgsubhead=msghead.appendChild(d.createElement("IMG"));
    msgsubhead.id = "alertclose";
    msgsubhead.className = "alertclose";
    var url = document.getElementById('hidModulePath').value + "images/delete.gif";
    msgsubhead.setAttribute("src",url);
    msgsubhead.setAttribute("width","16");
    msgsubhead.setAttribute("height","16");
    msgsubhead.setAttribute("border","0");
    msgsubhead.setAttribute("title","Close"); // ToolTip
    
    msgsubhead.onclick = function() { removeCustomAlert();return false; }
    
    msgdiv=alertObj.appendChild(d.createElement("div"));
    msgdiv.id="msgdiv";
    msgdiv.className="msgdiv";
    
	msg = msgdiv.appendChild(d.createElement("div"));
	//msg.appendChild(d.createTextNode(txt));
	msg.id= "msg";
	msg.className= "msg";
	msg.innerHTML = txt;
	
	//alertObj.style.display = "block";
}

function printAlert()
{
	var a = window.open('','','menubar=1,scrollbars=1,width=400,height=300');	
	a.document.open("text/html");
	//a.document.write(document.getElementById('msg').innerHTML);
	a.document.write('<html><head><style type="text/css">body{font:normal 10px verdana,arial;} #frame{background-image:none;background-color:#FFFFFF;}</style></head><body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">');
    a.document.write(document.getElementById('msg').innerHTML);
    a.document.write('</body></html>');
    a.document.close();	
	a.print();
}

function calldrag() 
{
    var msghead = document.getElementById('msghead');
    getMouseXY();
    var top = msghead.parentElement.offsetTop;
    var left= msghead.parentElement.offsetLeft;
    var right= msghead.offsetWidth + left;
    var bottom= msghead.offsetHeight + top;
     if(left<= tempX && right>=tempX)
        if(top<= tempY && bottom>=tempY)
        {  
            var dragable = DragHandler.attach(document.getElementById('modalContainer'));
        }
        else
        {
            dragable=null;
        }
    return false;
}

function detachdrag()
{
    dragable=null;
    return false;
}

function removeCustomAlert() {

	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}


//END ALERT




