

//============POSITION METHODS ===============
function PlaceDiv(divid, element, height)
{
	var div = document.getElementById(divid);

	if (div.style.display == 'none')
	{
		var divHeight = height ;
		var clientHeight = window.document.body.scrollHeight ;
		var clientWidth = window.document.body.scrollWidth ;

		var divTop = GetTopPixel( document.getElementById( element ) ) ;
		div.style.top = divTop + 15 ;
		var divLeft = (clientWidth*20/100)/* + div.style.width */;
		div.style.left = divLeft ;

		if ( (divTop + divHeight) > clientHeight )
		{
			div.style.top = divTop - divHeight ;
		}

		if ( div.style.top.replace("px","") < 0 )
		{
			div.style.top = 0 ;
		}
		div.style.zIndex = (tempzIndex++) ;

		div.style.display = 'block';
		return true ;
	}
	else
	{
		div.style.display = 'none';
		return false ;
	}
}

var ElementPosX ;
var ElementPosY ;

function GetCoordinates( Element )
{
	//Get Coordinates
	ElementPosX = Element.offsetLeft ;
	ElementPosY = Element.offsetTop;
	var uTempElement = Element.offsetParent;

	while(uTempElement != null)
	{
		ElementPosX += uTempElement.offsetLeft ;
		ElementPosY += uTempElement.offsetTop ;

		uTempElement = uTempElement.offsetParent;
	}
}

function GetTopPixel( Element )
{
	GetCoordinates( Element ) ;
	return ElementPosY ;
}

function GetLeftPixel( Element )
{
	GetCoordinates( Element ) ;
	return ElementPosX ;
}
//============POSITION METHODS END===============


//============CALENDAR METHODS ===============
var CalendarStarted = false ;
function CalendarOpen( Element )
{
	if ( !CalendarStarted )
	{
		Defaults( Element.id ) ;
		CalendarStarted = true ;
	}
	GetCoordinates( Element ) ;

	//Show Div
	var div = document.getElementById('divCalendar') ;
	div.style.top = (ElementPosY+18) ;
	div.style.left = (ElementPosX) ;

	var clientHeight = window.document.body.scrollHeight ;
	if ( (ElementPosY + 18 + 150) > clientHeight )
	{
		div.style.top = clientHeight - 150 ;
	}

	document.getElementById('divCalendar').style.display = "block" ;
	//End Show Div

	SetCalendar( Element.id ) ;
}

function HideCalendar()
{
	document.getElementById('divCalendar').style.display = "none" ;
}
//============CALENDAR METHODS ===============


//============DRAG METHODS ===============
var ie=document.all
var ns6=document.getElementById&&!document.all

var dragapproved=false
var z,x,y, tempzIndex = 1

function move(e){
	if (dragapproved){//For Netscape must declare parentElement
		z.parentElement.parentElement.parentElement.parentElement.style.left=ns6? temp1+e.clientX-x: temp1+event.clientX-x
		z.parentElement.parentElement.parentElement.parentElement.style.top=ns6? temp2+e.clientY-y : temp2+event.clientY-y
		z.parentElement.parentElement.parentElement.parentElement.style.zIndex=ns6? (tempzIndex++) : (tempzIndex++)
		return false
	}
}
function dragclick(e){
	if (!ie&&!ns6)
	return
	var firedobj=ns6? e.target : event.srcElement

	if (firedobj.className=="divformlabel"){
		z.parentElement.parentElement.parentElement.parentElement.style.zIndex=ns6? (tempzIndex++) : (tempzIndex++)
		return false
	}
}

function drags(e){
	if (!ie&&!ns6)
	return
	var firedobj=ns6? e.target : event.srcElement
	var topelement=ns6? "HTML" : "BODY"

	while (firedobj.tagName!=topelement&&firedobj.className!="drag"){
		firedobj=ns6? firedobj.parentNode : firedobj.parentElement
	}

	if (firedobj.className=="drag"){
		dragapproved=true
		z=firedobj
		temp1=parseInt(GetLeftPixel(z)+0)
		temp2=parseInt(GetTopPixel(z)+0)
		x=ns6? e.clientX: event.clientX
		y=ns6? e.clientY: event.clientY
		document.onmousemove=move
		return false
	}
}
//============DRAG METHODS END============

//============On key press============
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
function doClick(buttonName,e)
    {
        var key;
         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
   }
   //============END On key press============

   function showBackBg() {
       var div;

       if (!document.getElementById("divBackBg")) {
           div = document.createElement("div");
           div.id = "divBackBg";
           div.className = "bigImage";
           document.body.appendChild(div);
       }
       else {
           div = document.getElementById("divBackBg");
           div.style.display = "block";
       }

       div.innerHTML = '<table id="tblBigImg" align="center"><tr><td valign="middle" align="center"><table border="0" cellspacing="0" cellpadding="10" bgcolor="#ffffff" style="border: 1px solid #bbbbbb;"><tr><td><div id="divLoading" class="content">We are now uploading you eBrochure...</div></td></tr></table></td></tr></table>';
       div.style.height = window.document.body.scrollHeight;
       var so = new SWFObject("../images/loader.swf", "divLoading", "120", "150", "8", "#ffffff");
        so.addParam("quality", "high");
        so.addParam("wmode", "transparent");
        so.write("divLoading");

       var winWidth = 0;
       var winHeight = 0;
       if (navigator.appName == "Netscape") {
           winWidth = window.innerWidth;
           winHeight = window.innerHeight;
       }
       else if (navigator.appName.indexOf("Microsoft") != -1) {
           winWidth = window.document.body.offsetWidth;
           winHeight = window.document.body.offsetHeight;
       }

       var tbl = document.getElementById("tblBigImg");
       if (window.document.body.scrollTop > 0) {
           tbl.style.position = "absolute";
           tbl.style.top = window.document.body.scrollTop;
           tbl.style.left = 0;
           tbl.setAttribute("width", winWidth - 50);
       }

       tbl.setAttribute("height", winHeight - 10);
   }