var __PageURL='';
//GetNumeric::Begin
function getNumeric(__Value,__Type,__Default){
	if(typeof(__Default)!='number')__Default = 0;
	switch(__Type){
		case 'I' : __Type = 'Int'; break;
		case 'F' : __Type = 'Float'; break;
		default: __Type = 'Int'; break;
	}		
	__Value = eval('parse'+__Type+'("'+__Value+'")');
	if(isNaN(__Value))return __Default;
	return __Value;
}
//GetNumeric::Begin
//PointClass::Begin
Point=function(__x,__y){
	this.x=getNumeric(__x,'F',0);
	this.y=getNumeric(__y,'F',0);
	
	this.Equals=function(__Obj){
		if(!(__Obj instanceof Point))return false;
		if(__Obj.x!=this.x)return false;
		if(__Obj.y!=this.y)return false;
		return true;
	}
}	
//PointClass::End

BrowserProperties = function() {
    this.Name = navigator.appName;
    this.Explorer = null;
    this.Description = navigator.appVersion;
    this.UserAgent = navigator.userAgent;
	this.CultureInfo = {CurrentCulture:'',CurrentUICulture:''};
    this.Width = 0;
    this.Height = 0;
	this.Resolution = new Point(screen.width,screen.height);
    this.isIE = (/msie/.test(this.UserAgent.toLowerCase())) && !(/opera/.test(this.UserAgent.toLowerCase())) && (/win/.test(this.UserAgent.toLowerCase()));
	this.OS = BrowserProperties.OS.Other;
	if(/win/.test(this.UserAgent.toLowerCase()))
		this.OS = BrowserProperties.OS.Windows;
	else if(/linux/.test(this.UserAgent.toLowerCase()))
		this.OS = BrowserProperties.OS.Linux;
	else if(/x11/.test(this.UserAgent.toLowerCase()))
		this.OS = BrowserProperties.OS.Unix;
	else if(/mac/.test(this.UserAgent.toLowerCase()))
		this.OS = BrowserProperties.OS.Mac;	
	this.CultureInfo.CurrentUICulture = (navigator.language || ( navigator.browserLanguage || '' )).toLowerCase();
	this.CultureInfo.CurrentCulture = (navigator.systemLanguage || this.CultureInfo.CurrentUICulture).toLowerCase();

    switch (this.Name) {
        case "Microsoft Internet Explorer":
            this.Type = 0;
            if (this.Description.indexOf("MSIE 7") >= 0)
                this.Explorer = BrowserProperties.Explorer.IE7;
            else if (this.Description.indexOf("MSIE 6") >= 0)
                this.Explorer = BrowserProperties.Explorer.IE6;
            break;
        case "Netscape":
            this.Type = 1;
			if(/safari/.test(this.UserAgent.toLowerCase()))
				this.Explorer = BrowserProperties.Explorer.Safari;
			else if(/chrome/.test(this.UserAgent.toLowerCase()))	
				this.Explorer = BrowserProperties.Explorer.Chorme;
			else if(/firefox/.test(this.UserAgent.toLowerCase()))
				this.Explorer = BrowserProperties.Explorer.Firefox;
            break;
        case "Opera":
            this.Type = 2;
            break;
        default:
            this.Type = -1
            break;
    }		

    this.TestWindow = function() {
        if (typeof (window.innerWidth) == 'number') {
            //Non-IE			
            this.Width = window.innerWidth;
            this.Height = window.innerHeight;
        }
        else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'			
            this.Width = document.documentElement.clientWidth;
            this.Height = document.documentElement.clientHeight;
        }
        else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            //IE 4 compatible			
            this.Width = document.body.clientWidth;
            this.Height = document.body.clientHeight;
        }		
    }
	
	this.GetSize=function(){this.TestWindow();return new Point(this.Width,this.Height);}
    this.TestWindow();
	this.Maximize=function(){if(this.GetSize().x!=this.Resolution.x){window.resizeTo(this.Resolution.x,this.Resolution.y-20);window.moveTo(0,0);}}
	
    this.CopyToClipboard = function(__Data) {
		if(this.Type==0){
			var __ControlRange;
			switch(typeof(__Data)){
				case 'object':
					if (document.body.createControlRange) {
						__Data.contentEditable = true;
						__ControlRange = document.body.createControlRange();
						__ControlRange.addElement(__Data);
						__ControlRange.execCommand('Copy');
						__Data.contentEditable = false;
					}				
				break;
				case 'string':
					if(window.clipboardData){ 
						clipboardData.setData('Text',__Data); 
					}				
				break;
			}
		}
    }

}
BrowserProperties.OS={
	Other:0,
	Windows:2,
	Linux:4,
	Unix:8,
	Mac:16
}
BrowserProperties.Explorer = {
		IE6 : '00.10',
		IE7 : '00.11',
		Firefox : '01.10',
		Safari : '01.11',
		Chrome : '01.12'
	}

var UsedBrowser=new BrowserProperties();

function $(__Id) {
    var __Element = document.getElementById(__Id);
    if (__Element == null) {
        var __Test = document.getElementsByName(__Id);        
        __Element = __Test[0];
    }
    return __Element;
}

function setClassName(__Element,__ClassName){
	__Element.setAttribute('class',__ClassName);
	__Element.setAttribute('className',__ClassName);
}

function Replacer(__Input,__OldChar,__NewChar){
	var __Output='';
	for(var __i=0;__i<__Input.length;__i++){
		if(__Input.charAt(__i)==__OldChar)
			__Output += __NewChar;
		else
			__Output += __Input.charAt(__i);
		}
	return __Output;
	}
	
function NumberControl(__Input,__DotFree,__Minus){
	if(__DotFree==null)__DotFree=false;
	if(__Minus==null)(__Minus=false);
	var __Output='';
	var __DotCount=0;
	var __ValidChars='1234567890';
	var __StartIndex=0;
	if(__Input.charAt(0)=='-' && __Minus){
		__Output += '-';
		__StartIndex=1;
		}
	for(var __i=__StartIndex;__i<__Input.length;__i++){
		if(__ValidChars.indexOf(__Input.charAt(__i))!=-1){
			__Output += __Input.charAt(__i);								   
			}
		else if(__DotFree && __DotCount==0){
		    if(__Input.charAt(__i)=="."){
		        __Output += __Input.charAt(__i);
		        __DotCount++;
		       }
		    }
		}
	if(__Output=='-')__Output=0;
	if(__Output=='')__Output=0;
	return parseFloat(__Output);
	}

function appendStyle(__Element,Styles){
	if(Styles!=null){
		for(__Key in Styles)
			__Element.style[__Key]=Styles[__Key];
		}
	}
	
function RemoveAllChilds(__Element){
	if(__Element!=null && __Element.childNodes.length>0){
		var __NodesCount=__Element.childNodes.length;
		var __Child;
		for(var __i=0;__i<__NodesCount;__i++){
			__Child = __Element.childNodes[0];
			RemoveAllChilds(__Child);
			__Element.removeChild(__Child);
			}
		}
	}

function appendAttribute(__Element,__Attributes){
    for(var __Key in __Attributes)
        __Element.setAttribute(__Key,__Attributes[__Key]);
}

function _CreateElementID(TagName){
	var __Date=new Date();
	var __Id='_System'+(TagName!=null?TagName:'Default')+'_'+__Date.valueOf();
	return __Id;
	}
	
function _CreateElement(Properties){
    if(Properties==null)return null;
    if(Properties.TagName==null)return null;
	var __Date=new Date();
	var __Id='_System'+Properties.TagName+'_'+__Date.valueOf();
	var __Element=document.createElement(Properties.TagName);
	__Element.setAttribute("id",(Properties.Name==null?__Id:Properties.Name));
	if(Properties.StyleName!=null)
		appendStyle(__Element,Properties.StyleName);
	if(Properties.Attributes!=null)
	    appendAttribute(__Element,Properties.Attributes);		
	return __Element;
}

//SetOpacity::Begin
function setOpacity(__Element,__Opacity){
	if(__Element.nodeType!=1)return false;
	if(__Opacity==null)return false;
	__Opacity = parseInt(__Opacity);
	with(__Element.style){
		filter = "Alpha(opacity=" + __Opacity + ")";
		MozOpacity = __Opacity / 100;
		opacity = __Opacity / 100;
	}
}
//SetOpacity::End

//Prototype Functions::Begin
String.prototype.LTrim=function(){
	var re = /\s*((\S+\s*)*)/;
	return this.replace(re, "$1");
}

String.prototype.RTrim=function(){
	var re = /((\s*\S+)*)\s*/;
	return this.replace(re, "$1");
}	

String.prototype.Trim=function(){
    return this.LTrim().RTrim();
}

String.prototype.CharReplace = function(__OldChar, __NewChar) {
    var __Output = '';
    for (var __i = 0; __i < this.length; __i++) {
        if (this.charAt(__i) == __OldChar)
            __Output += __NewChar;
        else
            __Output += this.charAt(__i);
    }
    return __Output;
}

Array.prototype.MySearch = function(__Value) {
    for (var _i = 0; _i < this.length; _i++) {
        if (this[_i] == __Value) { return _i; }
    }
    return -1;
}
Array.prototype.Count=function(){return this.length;}
//Prototype Functions::End

//CreateCss::Begin
function createCSS(__className, __Value) {

    var isIE = UsedBrowser.isIE

    var __Style = document.createElement("style");
    __Style.setAttribute("type", "text/css");
    __Style.setAttribute("media", "screen");

    if (!isIE) __Style.appendChild(document.createTextNode(__className + " {" + __Value + "}"));

    document.getElementsByTagName("head")[0].appendChild(__Style);

    if (isIE && document.styleSheets && document.styleSheets.length > 0) {
        var last___Style = document.styleSheets[document.styleSheets.length - 1];
        if (typeof (last___Style.addRule) == "object") last___Style.addRule(__className, __Value);
    }
}
//CreateCss::End
//GetStyle::Begin
function getStyle(__Obj,__Style)
{
	var __Result = null;
	var CurrentStyle=null;
	__Result = __Obj.style[__Style.replace(/\-(.)/g, function(m, l){return l.toUpperCase()})];
	if(__Result)return __Result;
    if (__Obj.currentStyle){
        CurrentStyle=	__Obj.currentStyle;
		__Style = __Style.replace(/\-(.)/g, function(m, l){return l.toUpperCase()});
		__Result = CurrentStyle[__Style];
	}
    else if (window.getComputedStyle){
        CurrentStyle=	document.defaultView.getComputedStyle(__Obj, null);
		__Result =  CurrentStyle.getPropertyValue(__Style)
	}
	return __Result;
}
//GetStyle::End
function PageLink(_Values){
	var __FormAction=(_Values.Action!=null?_Values.Action:__PageURL);
	var __Form=_CreateElement({TagName:'FORM',Attributes:{name:'LinkForm',method:(_Values.SendMethod!=null?_Values.SendMethod:'POST'),action:__FormAction}});	
	if(_Values.Target)__Form.target=__Values.Target;
	if(__Form){
		if(_Values.Url!=null){
			for(var __Key in _Values.Url){
				var __Input=_CreateElement({TagName:'INPUT',Attributes:{type:'hidden',name:__Key,'value':_Values.Url[__Key]}});
				if(__Input)__Form.appendChild(__Input)
				}
			}
			document.body.appendChild(__Form);
			__Form.submit();
		}
	}
	
function CreateRequestElement()
{
  var xmlHttp=null;
  try{        
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)    {
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

	
function _Send(_Values){  
    if(_Values!=null && _Values!=""){
    xmlHttp=CreateRequestElement();
        if (xmlHttp==null){
            PageLink(_Values);
        }        
        else{   
            try{
                if(!eval(_Values.FunctionName+'_Control(_Values)'))return false;
            }
            catch(ex){
                alert(ex.description);
                return false;
            }
            var _Url = "";
            for (var __Key in _Values.Url){
                _Url += (_Url==""?"":"&")+__Key+"="+escape(_Values.Url[__Key]);
            }     
			_Url += (_Url==""?"":"&")+"Ajax=true";
            xmlHttp.open((_Values.SendMethod==null?"POST":_Values.SendMethod),_Values.Action,(_Values.Sync==null?true:_Values.Sync));	
				
            xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;');
			//xmlHttp.overrideMimeType('text/xml; charset=iso-8859-9');
            xmlHttp.onreadystatechange=function(){
                if (xmlHttp.readyState==4)	{  
						if(xmlHttp.status!=200)return;
						if(_Values.Wait!=null)eval(_Values.Wait+'_Stop(_Values)');							
						if(_Values.ReturnMethod && _Values.ReturnMethod=='XML')_Values.Result=xmlHttp.responseXML; 
						else _Values.Result=xmlHttp.responseText; 
                        eval(_Values.FunctionName+'_Result(_Values)') 
                }
                else if(xmlHttp.readyState==1){
                	if(_Values.Wait!=null)eval(_Values.Wait+'_Start(_Values)');				   
                }
                else{
                //Waiting ...  
				if(_Values.Wait!=null)eval(_Values.Wait+'_Start(_Values)');
                }
            }
			if(UsedBrowser.Type==1 && (UsedBrowser.Explorer == BrowserProperties.Explorer.Safari || UsedBrowser.Explorer == BrowserProperties.Explorer.Chrome))if(_Values.Wait!=null)eval(_Values.Wait+'_Start(_Values)');	
            xmlHttp.send(_Url);
        }
    }
    else{
        
    }
}



//MousePosition::Begin
function GetMousePosition(__Event){
		__Event = __Event || window.event;
		if(__Event.pageX || __Event.pageY){
			return (new Point(__Event.pageX,__Event.pageY));
		}	
		return (new Point(
						  (__Event.clientX + document.body.scrollLeft - document.body.clientLeft),
						  (__Event.clientY + document.body.scrollTop  - document.body.clientTop)
						  )
				);
}
//MousePosition::End

//GetScrollPosition::Begin
function GetScrollPosition(__Event) {
    var __x = 0, __y = 0;
    
    if (typeof (window.pageYOffset) == 'number') {
        __x = window.pageXOffset;
        __y = window.pageYOffset;
    }
    else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        __x = document.body.scrollLeft;
        __y = document.body.scrollTop;
    }
    else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        __x = document.documentElement.scrollLeft;
        __y = document.documentElement.scrollTop;
    }
    /**/
    return (new Point(__x, __y));
}
//GetScrollPosition::End

//ObjectPosition::Begin
function ObjectPosition(__Element){
	var __left = 0;
	var __top  = 0;
	while (__Element.offsetParent){
		__left += __Element.offsetLeft;
		__top  += __Element.offsetTop;
		__Element     = __Element.offsetParent;
	}
	__left += __Element.offsetLeft;
	__top  += __Element.offsetTop;
	return (new Point(__left,__top));
}
//ObjectPosition::End

//Catch Mouse Position::Begin
function CatchMousePosition(__E){
	__E=(__E || window.event);
	document.MousePosition = GetMousePosition(__E);	
}
//Catch Mouse Position::End

//Catch Scroll Position::Begin
function CatchScrollPosition(__E) {
    __E = __E || window.event;
    document.ScrollPosition = GetScrollPosition();    
}
//Catch Scroll Position::End

//GetStyle::Begin
function GetElementStyle(__Element){
	var CurrentStyle;
    if (__Element.currentStyle)
        CurrentStyle=	__Element.currentStyle;
    else if (window.getComputedStyle)
        CurrentStyle=	document.defaultView.getComputedStyle(__Element, null);
    else
        CurrentStyle=	__Element.style;	
	return CurrentStyle;
}
//GetStyle::End

//DisableSelection::Begin
function disableSelection(__Target){
	if (typeof(__Target.onselectstart)!="undefined")
		__Target.onselectstart=function(){return false;}
	else if (typeof(__Target.style.MozUserSelect)!="undefined")
		__Target.style.MozUserSelect="none"
}
//DisableSelection::End
//EmailFormatCheck::Begin
function CheckMailAddress(__EmailAddress){
	__EmailAddress = __EmailAddress.Trim();
	var __Pattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	var __RegEx = new RegExp(__Pattern);
	return (!__RegEx.test(__EmailAddress) || __EmailAddress == '' ? false : true)	;
}
//EmailFormatCheck::End
//getKeyNum::Begin
function getKeyNum(e){
	var __KeyNum=null;
	if(window.event){__KeyNum=window.event.keyCode;}
	else if(e && e.which){__KeyNum=e.which;}
	return __KeyNum;
}
//getKeyNum::End
//CaptureMouseWheel::Begin
function __MouseWheel(event){
	function TriggerWheelEvents(__Delta){
		var __WheelEvent = null;
		if(!document.MouseWheelEvents)return false;
		if(!document.MouseWheelEvents instanceof Array)return false;
		for(var __i=0;__i<document.MouseWheelEvents.length;__i++){
			__WheelEvent = document.MouseWheelEvents[__i];
			if(typeof(__WheelEvent)!='function')continue;
			__WheelEvent(__Delta);
		}
	}
    var __Delta = 0;
    if (!event)event = window.event;
    if (event.wheelDelta) {
		__Delta = event.wheelDelta/120;
        if (window.opera)__Delta = -__Delta;
    }
	else if (event.detail) {
    	__Delta = -event.detail/3;
	}
    if (__Delta)TriggerWheelEvents(__Delta);
	/*
    if (event.preventDefault)event.preventDefault();
	event.returnValue = false;	
	*/
}
document.AttachWheelEvent=function(__Event){return this.MouseWheelEvents.push(__Event);}
document.DetachWheelEvent=function(__Event){
	for(var __i=0;__i<this.MouseWheelEvents.length;__i++){
		if(this.MouseWheelEvents[__i]===__Event){
			this.MouseWheelEvents.splice(__i,1);
			break;
		}
	}	
}
document.MouseWheelEvents = [];
document.MouseWheelEvents.push=function(__Event){if(typeof(__Event)!='function')return false;this[this.length]=__Event;return true;}
if (window.addEventListener)
        window.addEventListener('DOMMouseScroll', __MouseWheel, false);
window.onmousewheel = document.onmousewheel = __MouseWheel;
//CaptureMouseWheel::End

CalculateResize=function(__Current,__Limit){
	var __Ratio=1;		
	if(__Current.x>__Limit.x || __Current.y>__Limit.y){
		if(__Current.x<=__Limit.x){
			__Ratio = __Limit.y/__Current.y;
		}
		else if(__Current.y<=__Limit.y){
			__Ratio = __Limit.x/__Current.x;
		}
		else{
			if(__Current.x>__Current.y)
				__Ratio = __Limit.x/__Current.x;
			else
				__Ratio = __Limit.y/__Current.y;
		}
	__Current = new Point(Math.round(__Current.x*__Ratio),Math.round(__Current.y*__Ratio));
	if(__Current.x>__Limit.x || __Current.y>__Limit.y)
		__Current = CalculateResize(__Current,__Limit);
	}
	return __Current;
}
MiddleMargin=function(__Sender,__Size,__Border){
			var __Diff = 0;
			if(!__Size){
				if(__Sender.offsetWidth)
					__Size = new Point(__Sender.offsetWidth,__Sender.offsetHeight);
				else if(__Sender.width)
					__Size = new Point(__Sender.width,__Sender.height);		
				else
					__Size = new Point(getStyle(__Sender,'width'),getStyle(__Sender,'height'));
			}

			if(!__Border)__Border=new Point(__Sender.parentNode.offsetWidth,__Sender.parentNode.offsetHeight);
			__Sender.Margin = new Point(0,0);

			if(__Size.x<__Border.x)__Diff = Math.ceil((__Border.x-__Size.x)/2);
			__Sender.style.marginLeft = __Diff+'px';
			__Sender.style.marginRight = __Diff+'px';
			__Sender.Margin.x = __Diff;
			__Diff=0;
			if(__Size.y<__Border.y)__Diff = Math.ceil((__Border.y-__Size.y)/2);						
			__Sender.style.marginTop = __Diff+'px';	
			__Sender.style.marginBottom = __Diff+'px';	
			__Sender.Margin.y = __Diff;
}
//AddRemoveEventHandler::Begin
function AddEventHandler(__Event,__Handler,__Obj){
	if(!__Obj)__Obj = document;
	if(__Obj.addEventListener)
		__Obj.addEventListener(__Event,__Handler,false);
	else if(__Obj.attachEvent)
		__Obj.attachEvent(('on'+__Event),__Handler);	
}
function RemoveEventHandler(__Event,__Handler,__Obj){
	if(!__Obj)__Obj = document;
	if(__Obj.removeEventListener)
		__Obj.removeEventListener(__Event,__Handler,false);
	else if(__Obj.detachEvent)
		__Obj.detachEvent(('on'+__Event),__Handler);
}
//AddRemoveEventHandler::End




