
function svmsgWindow(w,h,url,msg,ele) {	
   
	if(!document.getElementById('overlay')){
		 var w, h, l, t;
		 l=getLeft(ele);
		 t=getTop(ele);
		 var BodyID = document.getElementsByTagName("body")[0];
		 dimmerdiv="<div id=\"overlay\">";
		 dimmerdiv+="<img id=\"imgDimmer\" src=\"images/overlay.png\"  border=\"0\" align=\"absmiddle\"></div>";
		 var outerdiv=document.createElement("div");
		 outerdiv.innerHTML=dimmerdiv;
		 BodyID.insertBefore(outerdiv,BodyID.firstChild);	
		 show_overlay();
		 wid=f_dhtmldialog_create('<div id="msg"></div>',msg,'animate;',0,w, h, 0, true);
		 GET_MTH_Request(url,'msg');
		 var tgtid="dhtml_dialog_m_"+wid;
		 var tgtobj=document.getElementById(tgtid);
		 tgtobj.style.top 	=	(Geometry.getVerticalScroll() + Geometry.getViewportHeight())/2 + "px";
		 tgtobj.style.left =	Geometry.getViewportWidth()/2-200 + "px";
	}
	return false;

 }
 
 function svalert(w,h,msg,ele) {	
   
	if(!document.getElementById('overlay')){
		 var w, h, l, t;
		 l=getLeft(ele);
		 t=getTop(ele);
		 var BodyID = document.getElementsByTagName("body")[0];
		 dimmerdiv="<div id=\"overlay\">";
		 dimmerdiv+="<img id=\"imgDimmer\" src=\"images/overlay.png\"  border=\"0\" align=\"absmiddle\"></div>";
		 var outerdiv=document.createElement("div");
		 outerdiv.innerHTML=dimmerdiv;
		 BodyID.insertBefore(outerdiv,BodyID.firstChild);	
		 show_overlay();
		 wid=f_dhtmldialog_create('<div id="msg"></div>',msg,'animate;',0,w, h, 0, true);
		 document.getElementById('msg').innerHTML=msg;
		 var tgtid="dhtml_dialog_m_"+wid;
		 var tgtobj=document.getElementById(tgtid);
		 tgtobj.style.top 	=	(Geometry.getVerticalScroll() + Geometry.getViewportHeight())/2 + "px";
		 tgtobj.style.left =	Geometry.getViewportWidth()/2-200 + "px";
	}
	return false;

 }
   
function svtooltipWindow(w,h,url,msg,ele) {	
   
	if(!document.getElementById('overlay')){
		 var w, h, l, t;
		 l=getLeft(ele);
		 t=getTop(ele);
		 var BodyID = document.getElementsByTagName("body")[0];
		 dimmerdiv="<div id=\"overlay\">";
		 dimmerdiv+="<img id=\"imgDimmer\" src=\"images/overlay.png\"  border=\"0\" align=\"absmiddle\"></div>";
		 var outerdiv=document.createElement("div");
		 outerdiv.innerHTML=dimmerdiv;
		 BodyID.insertBefore(outerdiv,BodyID.firstChild);	
		 show_overlay();
		 wid=f_dhtmldialog_create('<div id="msg"></div>',msg,'animate;',0,w, h, 0, true);
		 GET_MTH_Request(url,'msg');
		 var tgtid="dhtml_dialog_m_"+wid;
		 var tgtobj=document.getElementById(tgtid);
		 tgtobj.style.top 	=	(t-25) + "px";
		 tgtobj.style.left =	l + "px";
	}
	return false;

 }



  
  
function getLeft(obj){
	var curLeft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
		}
	}
	return curleft;
}

function getTop(obj){
	var curtop = 0;
	//alert(obj.offsetParent.tagName);
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop		
			//alert(obj.tagName + " = " + obj.offsetTop + " = " + obj.className);
		}		
	}
	return curtop;
}  


function getTop_ie(obj){
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			if(obj.offsetTop > curtop)
			curtop = obj.offsetTop		
			//alert(obj.tagName + " = " + obj.offsetTop + " = " + obj.className);
		}		
	}
	return curtop;
}  



/*---------OVERLAY-------------------*/
function DisableTab(evt) {

    var evt = (evt) ? evt : ((event) ? event : null);
   
	//alert(evt.keyCode);
	if(evt.keyCode == 9) {

        return false;

    }

}



function isOpera() {
    return navigator.appName.indexOf('Opera') > -1;   
}


function isMSIE() {
    return navigator.appName.indexOf('Microsoft Internet Explorer') > -1;   
}


function isMozilla() {
    return navigator.appName.indexOf('Netscape') > -1;   
}

function getPageScroll(){
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	var arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


function getPageSize(){
	var xScroll, yScroll, windowWidth, windowHeight, pageHeight, arrayPageSize;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}
	

function show_overlay() {
	
	//document.onkeydown=DisableTab;
	//document.onkeyRelease=DisableTab;
	// need to solve this error from link exchange;
	//document.getElementById('imgDimmer').height=  Geometry.getDocumentHeight();	 
	//document.getElementById('imgDimmer').width=  Geometry.getDocumentWidth();	
	if (arguments.length == 0) {
		doResize = true;
	}
	// prep objects
	var objOverlay = document.getElementById('overlay');

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	if (isMSIE()) {
		objOverlay.style.width = (arrayPageSize[0] + 'px');
	}
	objOverlay.style.display = 'block';

	// Hide select boxes as they will 'peek' through the image in IE	
	
	
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
    selects[i].disabled = true;
    }
		
	// After div is loaded, update the overlay height as the new div might have increased the overall page height.
	var arrayPageSize = getPageSize();
	objOverlay.style.height = (arrayPageSize[1] + 'px');
		
	return false;
}


function hide_overlay() {
	// get objects
	var objOverlay = document.getElementById('overlay');

	// hide lightbox and overlay
	objOverlay.parentNode.removeChild(objOverlay);

	// make select boxes visible
	selects = document.getElementsByTagName("select");
    for (var i = 0; i != selects.length; i++) {
		selects[i].disabled = false;
	}
}




function autoClose(x,y) {
//alert('test');
try {
togglepm(x,y);
}
catch(e) {
}

setTimeout("killPopup()",3000000000000)
}


function autoClose_wd(delay) {
setTimeout("killPopup()",delay)
}


function killPopup() {
try {
//document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
hide_overlay();
document.getElementById('dhtml_dialogs_all').parentNode.removeChild(document.getElementById('dhtml_dialogs_all'));
} catch(e) {
}
}




/*--------------------------------*/
var Geometry = {};

function makeGemetry(){
	if (window.screenLeft) { // IE and others
		Geometry.getWindowX = function( ) { return window.screenLeft; };
		Geometry.getWindowY = function( ) { return window.screenTop; };
	}else if (window.screenX) { // Firefox and others
		Geometry.getWindowX = function( ) { return window.screenX; };
		Geometry.getWindowY = function( ) { return window.screenY; };
	}
	
	if (window.innerWidth) { // All browsers but IE
		Geometry.getViewportWidth = function( ) { return window.innerWidth; };
		Geometry.getViewportHeight = function( ) { return window.innerHeight; };
		Geometry.getHorizontalScroll = function( ) { return window.pageXOffset; };
		Geometry.getVerticalScroll = function( ) { return window.pageYOffset; };
	}else if (document.documentElement && document.documentElement.clientWidth) {
		// These functions are for IE 6 when there is a DOCTYPE
		Geometry.getViewportWidth =
			function( ) { return document.documentElement.clientWidth; };
		Geometry.getViewportHeight =
			function( ) { return document.documentElement.clientHeight; };
		Geometry.getHorizontalScroll =
			function( ) { return document.documentElement.scrollLeft; };
		Geometry.getVerticalScroll =
			function( ) { return document.documentElement.scrollTop; };
	}else if (document.body.clientWidth) {
		// These are for IE4, IE5, and IE6 without a DOCTYPE
		Geometry.getViewportWidth =
			function( ) { return document.body.clientWidth; };
		Geometry.getViewportHeight =
			function( ) { return document.body.clientHeight; };
		Geometry.getHorizontalScroll =
			function( ) { return document.body.scrollLeft; };
		Geometry.getVerticalScroll =
			function( ) { return document.body.scrollTop; };
	}
	
	if (document.documentElement && document.documentElement.scrollWidth) {
		Geometry.getDocumentWidth =
			function( ) { return document.documentElement.scrollWidth; };
		Geometry.getDocumentHeight =
			function( ) { return document.documentElement.scrollHeight; };		
	}
	else if (document.body.scrollWidth) {
		Geometry.getDocumentWidth =
			function( ) { return document.body.scrollWidth; };
		Geometry.getDocumentHeight =
			function( ) { return document.body.scrollHeight; };		
	}
}

window.onload = makeGemetry;


function doPosition(target,source) {
	/*-----ie hack-----------------*/
	//alert("here");
	//alert(source.tagName);
	eletgt=document.getElementById(target);
	eletgt.style.display="block";
	l=parseInt(getLeft(source));
	t=parseInt(getTop(source));
	//eletgt.style.left =(l+20)+ "px";
	//eletgt.style.top =(t-4)+ "px";
	
	//add event listener for mouse click
	addListener(document.body, "click", handleHideSearch, false);
	/*-----------------------------------------*/
}

function handleHideSearch(e) {
	//alert("click");
		if (!e) var e = window.event;
		var tg = (window.event) ? e.srcElement : e.target;
		//alert(tg.nodeName);
		if (tg.nodeName=="INPUT") return;
		else
		{
			var eletgt=document.getElementById('popsearch');
			eletgt.style.display="none";
		}
}

function mouseHandle(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY')
		reltg= reltg.parentNode
	if (reltg== tg) return;
	// Mouseout took place when mouse actually left layer
	// Handle event
}

function hideSearch(target,obj){
	if(obj.value=='') obj.value='Enter Your Search';
	eletgt=document.getElementById(target);
    eletgt.style.display="none";
	
}

 function addListener(element, type, expression, bubbling)
{
    bubbling = bubbling || false;
    if(window.addEventListener) 
    { // Standard
        element.addEventListener(type, expression, bubbling);
        return true;
    }
    else if(window.attachEvent) 
    { // IE
        element.attachEvent('on' + type, expression);
        return true;
    }
    else return false;
}