// JavaScript Document

var PopUpWindows = 
{
    docEl: document.getElementById,
    Alert :
    {
        id: 'id_CustomAlert',
        open: function (msg) {
            if (document.getElementById(PopUpWindows.Alert.id)) {
                PopUpWindows.showPopUpBackground();
                PopUpWindows.Alert.messageText(msg);
                document.getElementById(PopUpWindows.Alert.id).style.display = 'block';
            }

        },
        close: function () {
            if (document.getElementById(PopUpWindows.Alert.id)) {
                PopUpWindows.showPopUpBackground();
                document.getElementById(PopUpWindows.Alert.id).style.display = 'none';
                PopUpWindows.hidePopUpBackground();
            }
        },
        headerText: function (v, id) {
            id = (id) ? id : PopUpWindows.Alert.id + 'Header';
            if (document.getElementById(id)) document.getElementById(id).innerHTML = v;
        },
        messageText: function (msg, id) {
            id = (id) ? id : PopUpWindows.Alert.id + 'Message';
			if ( document.getElementById(id) ) document.getElementById(id).innerHTML = msg;
		}
    },
    Failed:
    {
        id: 'id_CustomFailed',
        open: function (msg) {
            if (document.getElementById(PopUpWindows.Failed.id)) {
                PopUpWindows.showPopUpBackground();
                PopUpWindows.Failed.messageText(msg);
                document.getElementById(PopUpWindows.Failed.id).style.display = 'block';
            }

        },
        close: function () {
            if (document.getElementById(PopUpWindows.Failed.id)) {
                PopUpWindows.showPopUpBackground();
                document.getElementById(PopUpWindows.Failed.id).style.display = 'none';
                PopUpWindows.hidePopUpBackground();
            }
        },
        headerText: function (v, id) {
            id = (id) ? id : PopUpWindows.Failed.id + 'Header';
            if (document.getElementById(id)) document.getElementById(id).innerHTML = v;
        },
        messageText: function (msg, id) {
            id = (id) ? id : PopUpWindows.Failed.id + 'Message';
            if (document.getElementById(id)) document.getElementById(id).innerHTML = msg;
        }
    },
    Success:
    {
        id: 'id_CustomSuccess',
        open: function (msg) {
            if (document.getElementById(PopUpWindows.Success.id)) {
                PopUpWindows.showPopUpBackground();
                PopUpWindows.Success.messageText(msg);
                document.getElementById(PopUpWindows.Success.id).style.display = 'block';
            }

        },
        close: function () {
            if (document.getElementById(PopUpWindows.Success.id)) {
                PopUpWindows.showPopUpBackground();
                document.getElementById(PopUpWindows.Success.id).style.display = 'none';
                PopUpWindows.hidePopUpBackground();
            }
        },
        headerText: function (v, id) {
            id = (id) ? id : PopUpWindows.Success.id + 'Header';
            if (document.getElementById(id)) document.getElementById(id).innerHTML = v;
        },
        messageText: function (msg) {
            var id = PopUpWindows.Success.id + 'Message';
            if (document.getElementById(id)) document.getElementById(id).innerHTML = msg;
        }
    },
	ProgressIndicator :
	{
		id : '',
		headerText : function(v,id)
		{
			id = ( id ) ?id :PopUpWindows.ProgressIndicator.id +'Header';
			if ( document.getElementById(id) ) document.getElementById(id).innerHTML = v;
		},
		open : function(id)
		{
			PopUpWindows.ProgressIndicator.id = id;
			PopUpWindows.showPopUpBackground();
			
			if ( document.getElementById(id) )
			{
				document.getElementById(id).style.display = 'block'; 
			}
		},
		close : function(id)
		{
			PopUpWindows.ProgressIndicator.id = id;
			if ( document.getElementById(id) )
			{
				document.getElementById(id).style.display = 'none'; 
			}
			PopUpWindows.hidePopUpBackground();	
		}
	},
	Confirm :
	{
		id : 'id_CustomConfirm',
		returnValue : false,
		messageText : function(msg)
		{
			var id = PopUpWindows.Confirm.id +'Message';
			if ( document.getElementById(id) ) document.getElementById(id).innerHTML = msg;
		},
		open : function(msg)
		{
			if ( document.getElementById(PopUpWindows.Confirm.id) )
			{
				PopUpWindows.showPopUpBackground();
				PopUpWindows.Confirm.messageText(msg);
				document.getElementById(PopUpWindows.Confirm.id).style.display = 'block'; 
				PopUpWindows.Confirm.timeOutVar = setTimeout("PopUpWindows.Confirm.timeOut('"+PopUpWindows.Confirm.id+"');",360000);
			}

		},
		close : function()
		{
			if ( document.getElementById(PopUpWindows.Confirm.id) )
			{
				PopUpWindows.showPopUpBackground();
				document.getElementById(PopUpWindows.Confirm.id).style.display = 'none'; 
				PopUpWindows.hidePopUpBackground();
				clearTimeout(PopUpWindows.Confirm.timeOutVar);
			}
			return PopUpWindows.Confirm.returnValue;
		},
		yes : function()
		{
			PopUpWindows.Confirm.returnValue = true;
			PopUpWindows.Confirm.close();
		},
		no : function()
		{
			PopUpWindows.Confirm.returnValue = false;
			PopUpWindows.Confirm.close();
		},
		timeOutVar : null,
		timeOut : function(id)
		{
			PopUpWindows.Confirm.id = id;
			PopUpWindows.Confirm.no();
		}
	},
	// global methods //////////////////////////////
	showPopUpBackground : function()
	{
		var id = 'addPopUpBackground';
		var height = Number(PopUpWindows.getWindowSize('h')) + Number(PopUpWindows.getScrollXY()[1]);
		
		if ( document.getElementById(id) )
		{
			document.getElementById(id).style.display = 'block'; 
		}
		else
		{
			PopUpWindows.addHTML('<div id="'+id+'" style="position:fixed;z-index:1000;top:0px;left:0px;display:block;width:100%;height:'+height+'px; background-color:#000000;background-color:#000000; -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.5; filter: alpha(opacity = 50);">&nbsp;</div>');
		}
	},
	hidePopUpBackground : function()
	{
		var id = 'addPopUpBackground';
		if ( document.getElementById(id) )
		{
			document.getElementById(id).style.display = 'none'; 
		}
	},
	getWindowSize : function ( wh )
	{
		/* //////////////////////////////////////////
		Developer : Chayne Walsh
		Version Date : 2010 01 06 01
		////////////////////////////////////////// */

		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) 
		{ //Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{ //IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{  //IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		if ( wh == 'w' ) return myWidth;
		if ( wh == 'h' ) return myHeight;
	},
	addHTML : function (html) 
	{
		if (document.all)
			document.body.insertAdjacentHTML('beforeEnd', html);
		else if (document.createRange) 
		{
			var range = document.createRange();
			range.setStartAfter(document.body.lastChild);
			var cFrag = range.createContextualFragment(html);
			document.body.appendChild(cFrag);
		}
		else if (document.layers) 
		{
			var X = new Layer(window.innerWidth);
			X.document.open();
			X.document.write(html);
			X.document.close();
			X.top = document.height;
			document.height += X.document.height;
			X.visibility = 'show';
		}
	},
	getScrollXY : function () 
	{
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) 
		{ //Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} 
		else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
		{ //DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} 
		else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
		{ //IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		 return [ scrOfX, scrOfY ];
	}
}
