
////////CustomPopUp
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
//var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);



var BOX_TITLE ="Incomplete Form:";
var oBoxalert = false;
 
if(document.getElementById) 
{   

    window.alert = function(txt) 
    {
    //alert(document.body.clientHeight);
    //alert(document.body.clientHeight);
	   createCustomBox(txt, 1);
      
    }
    
}
function createCustomBox(txt,objNo)
{
    var scrll=document.documentElement.scrollTop==0?document.body.scrollTop:document.documentElement.scrollTop;
    d = document;
	if(d.getElementById("BoxDiv")) return;
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "BoxDiv";
	mObj.style.height = d.documentElement.scrollHeight + "px";
	
	BoxObj = mObj.appendChild(d.createElement("div"));
	BoxObj.id = "Box";
	//BoxObj.style.top = document.documentElement.scrollTop +1100+ "px";
	var clntHght=document.documentElement.clientHeight;
	
	BoxObj.style.top = scrll + 100 + "px";
	BoxObj.style.left = (d.documentElement.scrollWidth - BoxObj.offsetWidth)/2 + "px";
	BoxObj.style.visiblity="visible";

	h1 = BoxObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(BOX_TITLE));
    h2 = BoxObj.appendChild(d.createElement("h1"));
	msg = BoxObj.appendChild(d.createElement("p"));
//	txt='/n'+txt;
	msg.appendChild(d.createTextNode(txt));
	
	
    TblObj = document.createElement("table");
    TblBody = document.createElement("tbody");

    TR1 = document.createElement("tr");
    TD1 = document.createElement("td");
    TR2 = document.createElement("tr");
    TD2 = document.createElement("td");
    
    BoxObj.appendChild(TblObj)
    TblObj.appendChild(TblBody)
   
 
    
    TblBody.appendChild(TR1)
    TR1.appendChild(TD1)
    TblBody.appendChild(TR2)
    TR1.appendChild(TD2)
    
    
    TblObj.id = "tblBox";
   


   
	btn1 = TD1.appendChild(d.createElement("img"));
	btn1.id = "OkBtn";
	btn1.src = RelativePath1() +"images/btn-ok.jpg";

	
	btn1.onmouseover = function() { this.src=RelativePath1() +"images/btn-ok-o.jpg";}
	btn1.onmouseout = function() { this.src=RelativePath1() +"images/btn-ok.jpg";}	
	
	if(objNo==2)
	{
	    TR1.appendChild(TD2)
	    TD2.style.paddingLeft = "3px";
	    
	    btn2 = TD2.appendChild(d.createElement("img"));
	    btn2.id = "CancelBtn";
	    btn2.src = "images/buttons/btn-cancel.jpg";
	    
	    btn1.onclick = function() { removeCustomAlert(); oBoxalert = true;}
	    btn2.onmouseover = function() { this.src="images/buttons/btn-cancel-o.jpg";}
	    btn2.onmouseout = function() { this.src="images/buttons/btn-cancel.jpg";}
	    btn2.onclick = function() { removeCustomAlert();return false; }	    
	}
	else
	{
	    btn1.onclick = function() { removeCustomAlert();return false; }
	}
	
    h3 = BoxObj.appendChild(d.createElement("h3"));
	BoxObj.style.display = "block";
	
//    try
//    {
//        var oSelect = document.all.tags("SELECT");     
//		if (oSelect!=null)
//		{
//			for (i=0; i<oSelect.length; i++) 
//			oSelect[i].style.visibility = "hidden";
//		}		
//		
//    }
//    catch(Error){}
    
	btn1.focus();
	//if(!oBoxalert) {oBoxalert = false; return false;}
}
function removeCustomAlert() 
{
//    try
//    {
//        var oSelect = document.all.tags("SELECT");     
//		if (oSelect!=null)
//		{
//			for (i=0; i<oSelect.length; i++) 
//			oSelect[i].style.visibility = "visible";
//		}
//    }
//    catch(Error){}
   
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("BoxDiv"));
}


 //gets the relative root path
function RelativePath1()
{
    // Remove any frames
//    if (top.location != self.location) {
//      top.location = self.location;
//    }

    var url = self.location.href;
    url = url.toLowerCase();
    var path = '';
    
    // determine the server   
    var local = 'localhost/';
    var server = 'server/';
    var thevault  = 'thevault-com.sitepreview.ca/';
    var vault  = 'vault.silverwheaton.com/';
        
    if(url.lastIndexOf(local) > 1)
        path = "http://localhost/illusion/";
    else if(url.lastIndexOf(server) > 1)
        path = "http://localhost/illusion/";
    else if(url.lastIndexOf(thevault) > 1)
        path = "http://localhost/illusion/";
    else if(url.lastIndexOf(vault) > 1)
        path = "http://localhost/illusion/";  
    
    return path;
}