﻿
/// static class providing basic 
/// dom functionality


window.px = {
 // required by .net ClientScript Sys - Validated by Type
 __namespace : true,
 GetType: function() { return "px"; },
    Application: {
        IsLive: false
    },
	Loaded : false,
	OnLoad : function()
	{
		if(!this.Loaded)
		{
			this.Loaded = true;
			// initialize all other hooks to onload
			window.onload();
		}
		else
			return;
		var n = 0;
		while(n < px.Event.Listners.length)
		{
				px.Event.Listners[n].Obj[px.Event.Listners[n].Name]();
			++n;
		}
		document.onclick = px.documentClick;
	},
	byID : function(el)
	{
		switch(typeof(el))
		{
			case "string":
				return document.getElementById(el);
			case "object":
				return el;
				break;
		}
	},
	openElement : function openElement(object,tweenstyle,start,end,duration)
	{
		this.byID(object).style.display = "block";
	},
	closeElement : function closeElement(object,tweenstyle,start,end,duration)
	{
		this.byID(object).style.display = "none";
	},
	registeredDocumentClickMethods : [],
	registerDocumentClick : function registerDocumentClick(method)
	{
		var registered = false;
		for(var x = 0; x < px.registeredDocumentClickMethods.length; x++)	
			if(px.registeredDocumentClickMethods[x] == method)
				registered = true;
		if(!registered)
			px.registeredDocumentClickMethods[px.registeredDocumentClickMethods.length]=method;
	},
	documentClick : function documentClick()
	{
		for(var i = 0; i < px.registeredDocumentClickMethods.length; i++)
		{
			px.registeredDocumentClickMethods[i]();
		}
	}
};
window.onload = px.OnLoad;
px.Namespace = {

    Register: function(_Name)
    {
        var o = window;
        var x = false;
        for (var a = _Name.split("."); a.length > 0; )
        {
            var s = a.shift();
            if (a.length == 0) { if (o[s]) { x = true; } }
            if (!o[s]) { o[s] = {}; }
            o = o[s];
            if (!o.__namespace)
                o.__namespace = true;
        }

        if (x) { return 1; }
    }
}



px.Namespace.Register("px.UI");
px.Namespace.Register('px.UI.StaticFunctions');
px.Namespace.Register("px.Security");
px.Namespace.Register("px.Event");
px.Namespace.Register("px.Objects");
px.Namespace.Register("px.Formatters");
px.Namespace.Register("px.Events");

px.Event.Listners = [];
px.Formatters.Date = 
{
	Formatter : function(){ return {
		Cotr : function(/*string format, string date*/)
		{
			this.sFormat = arguments[0][0];
			this.value = arguments[0][1];
			return this;
			//alert(this.value);
		},
		value : "",
		sFormat : "mm-dd-yyyy",
		ToString : function()
		{
			return px.Formatters.Date.GetFormatted(this.value, px.Formatters.Date.GetFormat(this.sFormat));
		}
	}.Cotr(arguments)},
	Formats : {"mm/dd/yyyy":0,"MM/dd/yyyy":1,"MMMM/DD/yyyy":2},
	Days : {"Mon":"01","Tue":"02","Wed":"03","Thu":"04","Fri":"05","Sat":"06","Sun":"07"},
	Months : {"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"},
	GetFormat : function(frmat)
	{
		return px.Formatters.Date.Formats[frmat];
	},	
	GetFormatted : function(sVal, Format)
	{
		switch(Format)
		{
			case 0:				
				var s = "";
				s = sVal.toString();
				var y = s.split(" ")[3];
				var m = s.split(" ")[1];
				var d = this.Days[s.split(" ")[0]];
				return m + "/" + d + "/" + y;
				break;
			case 1:
				break;
			case 2:
				break;
		}
	}
}

px.Formatters.Money = 
{
	Formatter : function(){ return {
		Cotr : function(/*string format, string date*/)
		{
			return this;
		},
		value : "",
		sFormat : "$0.00",
		ToString : function()
		{
			return px.Formatters.Money.GetFormatted(this.value, px.Formatters.Money.GetFormat(this.sFormat));
		}
	}.Cotr(arguments)},
	CssClass : "",
	Value : "",	
	Formats : {0:"$0.00",1:"0[dollars]",2:"MMMM/DD/yyyy"},
	GetFormat : function(frmat)
	{
		return px.Formatters.Date.Format[frmat];
	},
	
	GetFormatted : function(sVal, Format)
	{
		switch(Format)
		{
			case 0:
				var a;
				var b;
				if(sVal.indexof(".")>0)
				{
					a = sVal.split(".")[0];
					b = sVal.split(".")[1];
				}
				else if(sVal.indexof(".")==0)
				{
					a = "";
					b = sVal.replace(".","")
				}
				else
				{
					a = sVal;
					b = "00";
				}				
				return "$" + a + "." + b;
			case 1:
				break;
			case 2:
				break;
		}
	}
}
///<summary>conversion to a money to this format $0.00 with the dolarsign</summary>
///<param name="value">   string: an integer to format to money</param>
///<param name="cssClass">string: value of a css classname that chan be applied to the string</param>
///<returns></returns>
/*
function FormatMoney(value,cssClass){
		this.GetType=function(){return 'FormatMoney';}
		if(value&&value.length>0){
				if(value.indexOf('$')>0){
				value=value.replace('$','');
				}
		}
	var	tval=new String()
		tval=(cssClass)?'<span class="'+cssClass+'">$</span>'+_formatmoney(value):_formatmoney(value);
	return tval;
}
_formatmoney=function(val){
	var Result;
var number = val;
  var n = parseFloat (number);
  var trunc = parseInt (n);
  Result = new Number (trunc). toString () + ".";
  n = (n - trunc) * 10;
  trunc = parseInt (n);
  Result = Result + new Number (trunc).toString ();
  n = (n - trunc) * 10;
  trunc = parseInt (n);
  Result = Result + new Number (trunc).toString ();

  return Result;
}
*/
px.Event.AddListner = function(obj)
{
	px.Event.Listners.push(obj);
}
px.Event.EventListner = function() {	return	{
  GetType : function(){ return "px.Event.EventListner"; },
		Cotr : function()
		{
			this.Name = arguments[0][0];
			this.Obj = arguments[0][1];
			return this;
		},
		Name : null,
		Obj : null
}.Cotr(arguments)}


px.Browser = function(){ return {

    Agent : null,
    App_Version : null,
    Major : null,
    IsOpera : false,
    IsSafari : false,
    IsSafari1_3up : false,
    IsKonqeror : false,
    IsIe : false,
    IsIeMac : false,
    IsIe3 : false,
    IsIe4 : false,
    IsIe5 : false,
    IsIe5_5 : false,
    IsIe5_5up : false,
    IsIe6up : false,
				IsIe8 : false,
				IsIe8up : false,
    IsMozilla : false,
    IsNetscape6 : false,
    ///<summary>
				/// Gets the type of object
				///</summary>
				///<returns>string: Type Name</returns>
    GetType : function(){ return "px.Browser"; },
    //--------------------------------------------------------------------
    
    //Initializer---------------------------------------------------------
    Cotr : function()
    { 
						this.Agent										=(navigator==null||navigator.userAgent==null)?'':navigator.userAgent.toLowerCase();
						this.App_Version				=(navigator==null||navigator.appVersion==null)?'':navigator.appVersion;
						this.Major										=parseInt(this.App_Version);
						this.IsOpera								=this.Agent.indexOf('opera')!=-1;
						this.IsIe											=!this.IsOpera&&(this.Agent.indexOf('msie')!=-1);
						this.IsIeMac								=this.IsIe&&(this.Agent.indexOf('mac')!=-1);
						this.IsSafari							=this.Agent.indexOf('safari')!=-1;
						this.IsSafari1_3up		=this.IsSafari&&(this.Agent.indexOf('safari/125.')==-1)&&(this.Agent.indexOf('safari/85.')==-1);
						this.IsKonqeror					=this.Agent.indexOf('konqueror')!=-1;
						this.IsMozilla						=!this.IsIe&&!this.IsOpera&&((this.Agent.indexOf('netscape')!=-1)||(this.Agent.indexOf('mozilla')!=-1))&&(this.Major>=5);
						this.IsIe3										=this.IsIe&&(this.Major<4);
						this.IsIe4										=this.IsIe&&(this.Major==4)&&(this.Agent.indexOf("msie 4")!=-1);
						this.IsIe5_5								=this.IsIe&&(this.Major==4)&&(this.Agent.indexOf("msie 5.5")!=-1);
						this.IsIe5										=this.IsIe&&(this.Major==4)&&(this.Agent.indexOf("msie 5")!=-1)&&!this.IsIe5_5;
						this.IsIe5_5up						=this.IsIe&&!this.IsIe3&&!this.IsIe4&&!this.IsIe5;
						this.IsIe6up								=this.IsIe&&!this.IsIe3&&!this.IsIe4&&!this.IsIe5&&!this.IsIe5_5up;
						this.IsIe8          =this.IsIe&&(this.Agent.indexOf("msie 8")!=-1);
						this.IsIe8up        =this.IsIe&&!this.IsIe3&&!this.IsIe4&&!this.IsIe5&&!this.IsIe5_5up&&!this.IsIE6up&&!this.IsIe8;
						this.IsNetscape6				=(this.Agent.indexOf('netscape6')!=-1);
        return this; 
    }
    //--------------------------------------------------------------------

}.Cotr(arguments);}
px.Cart = {};
px.Cart.Browser = new px.Browser();


px.Page = {}
px.Page.Footer = {}
px.Page.Footer.Element = function()
{
    return px.byID("Footer");
}
px.Page.Footer.Close = function()
{

}
px.Res = [];
px.Res.CLASS_OBSOLETE = 'the {0} class is obsolete, use the {1} class instead';

/* Obsolete classes.. */
px.UI.DropTabPanel = function() { throw px.Res.CLASS_OBSOLETE.replace('{0}', 'px.UI.DropTabPanel').replace('{1}', 'px.UI.HeaderPanel'); }























