var YEAR_LENGTH = 3;
var menuXmlURL = "data.xml";
var menuXmlObj = null;
/*Banner::Begin*/
MainPageBanner={}
MainPageBanner.PageVar = '';
MainPageBanner.Items = [];
MainPageBanner.Viewer=null;
MainPageBanner.BackButton=null;
MainPageBanner.NextButton=null;
MainPageBanner.CurrentIndex = 0;
MainPageBanner.TimeOut = 2000;
MainMenu={}
MainMenu.Up=function(__Owner){
	__Owner.childNodes[0].style.marginTop='-10px';
}
MainMenu.Down=function(__Owner){
	__Owner.childNodes[0].style.marginTop='';
}
MainPageBanner.ShowImage=function(){
	RemoveAllChilds(MainPageBanner.Viewer);
	MainPageBanner.Viewer.appendChild(MainPageBanner.Items[MainPageBanner.CurrentIndex]);		
}
MainPageBanner.Next=function(__SkipTimer){
	if(MainPageBanner.CurrentIndex == MainPageBanner.Items.length-1)MainPageBanner.CurrentIndex=-1;
	if(MainPageBanner.CurrentIndex<	MainPageBanner.Items.length-1){
		MainPageBanner.CurrentIndex	+= 1;
		MainPageBanner.ShowImage();	
		if(MainPageBanner.Timer && !__SkipTimer)MainPageBanner.Timer = setTimeout('MainPageBanner.Next()',MainPageBanner.TimeOut);
	}
}
MainPageBanner.Back=function(){
	if(MainPageBanner.CurrentIndex == 0 )MainPageBanner.CurrentIndex=MainPageBanner.Items.length;	
	if(MainPageBanner.CurrentIndex>0){
		MainPageBanner.CurrentIndex	-= 1;
		MainPageBanner.ShowImage();
	}
}
function xmlDataLoaded(){
	var __Child;
	for(var __i=0;__i<menuXmlObj.childNodes.length;__i++){
		__Child = menuXmlObj.childNodes[__i];
		if(__Child.nodeType!=1)continue;
		var __Item;
		var __Path;
		var __Image;
		var __Function;
		for(var __j=0;__j<__Child.childNodes.length;__j++){
			__Item = __Child.childNodes[__j];
			if(__Item.nodeType!=1)continue;
			__Path = __Item.attributes.getNamedItem('img').value;
			__Link = __Item.attributes.getNamedItem('link').value;
			__Link = __Link.replace('_Url_',MainPageBanner.PageVar);
			__Image = new Image();
			__Image.src = __Path;
			__Image.PageLink = __Link;
			__Image.onclick=function(){eval(this.PageLink);}
			setClassName(__Image,'BannerImage');
			MainPageBanner.Items.push(__Image);
		}
	}
	if(MainPageBanner.Items.length>0){
		MainPageBanner.Viewer=$('MainPageViewer');
		MainPageBanner.BackButton=$('MainPageLeftButton');
		MainPageBanner.NextButton=$('MainPageRightButton');		
		disableSelection(MainPageBanner.Viewer);
		MainPageBanner.ShowImage();
		if(MainPageBanner.Items.length>1){
			MainPageBanner.BackButton.onclick=function(e){MainPageBanner.Back()};
			MainPageBanner.NextButton.onclick=function(e){MainPageBanner.Next(true)};
			MainPageBanner.Timer = setTimeout('MainPageBanner.Next()',MainPageBanner.TimeOut);
		}	
	}
}

function getXMLData(__PageVar){
	MainPageBanner.PageVar = __PageVar;
    if (document.implementation && document.implementation.createDocument){ 
	    menuXmlObj = document.implementation.createDocument("", "doc", null);
		menuXmlObj.onload = xmlDataLoaded;
	} 
	else if (window.ActiveXObject){ 
	    menuXmlObj = new ActiveXObject("Microsoft.XMLDOM");
	    menuXmlObj.async = true;
		menuXmlObj.onreadystatechange = function () {
			if (menuXmlObj.readyState == 4) xmlDataLoaded();
	    };
	}
	menuXmlObj.load(menuXmlURL);
}

/*Banner::End*/
/*Contact::Begin*/
Contact={};
Contact.CheckValue=function(__Owner){if(__Owner.value.Trim()=='')__Owner.value=__Owner.title;}
Contact.ClearValue=function(__Owner){if(__Owner.value.Trim()==__Owner.title)__Owner.value='';}
/*Contact::End*/
function ChangeRowColor(__Row,__BGColor,__FGColor,__Except){
	var _FINAL=__Row.cells.length-(__Except>=0?__Except:0);
	for(var _i=0;_i<_FINAL;_i++){
		var _CELLS=__Row.cells[_i];
		_CELLS.style.backgroundColor=__BGColor
		if(__FGColor!=null) _CELLS.style.color=__FGColor
	}	
}

function ChangeStyleBackgroundImage(__Element,__ImageURL){
	__Element.style.backgroundImage='url('+__ImageURL+')';
	}

function Send_RequestNews(_Values){	
	_Values.Url.FV_SendMailName=$('FV_SendMailName').value;
	_Values.Url.FV_SendMailEmail=$('FV_SendMailEmail').value;
	_Send(_Values);
	}
	
function RequestNews_Control(_Values){
	return true;
	}
function RequestNews_Result(_Values){
	alert(_Values.Result);
	}
	
function Send_RequestCall(_Values){
	_Values.Url.FV_AreaCode=$('FV_AreaCode').value;
	_Values.Url.FV_PhoneNumber=$('FV_PhoneNumber').value;
	_Send(_Values);
	}

function RequestCall_Control(_Values){return true;}	
function RequestCall_Result(_Values){alert(_Values.Result);}
//NumericUpDown::Begin

NumericUpDown = function(Properties){
	Properties = Properties|| {};
	this.Owner = Properties.Owner || null;
	this.Container = null;
	if(!this.Owner)throw new Exception();
	this.Container = Properties.Container || (this.Owner.parentNode || document.body);	
	this.Type = Properties.Type || null;
	this.Signed = Properties.Signed || false;	
	this.MaxValue = Properties.MaxValue || 100;
	this.MinValue = Properties.MinValue || (this.Signed ? -100 : 0);
	this.CssPrefix = Properties.CssPrefix || '';
	this.Value = this.Owner.value != '' ? parseInt(this.Owner.value) : 0;
	this.HtmlObject=null;

	if(this.Type){
		this.Signed = false;	
		switch(this.Type){
			case NumericUpDown.Type.Year:
				var __Now = new Date();
				this.MaxValue = __Now.getFullYear()+YEAR_LENGTH;
				this.MinValue = __Now.getFullYear();
			break;
			case NumericUpDown.Type.Month:
				this.MaxValue = 12;
				this.MinValue = 1;
			break;
			case NumericUpDown.Type.Day:
				this.MaxValue = 31;
				this.MinValue = 1;
			break;			
			case NumericUpDown.Type.Hour:
				this.MaxValue = 23;
				this.MinValue = 0;
			break;			
			case NumericUpDown.Type.Minute:
				this.MaxValue = 60;
				this.MinValue = 0;
			break;		
			case NumericUpDown.Type.Second:
				this.MaxValue = 60;
				this.MinValue = 1;
			break;			
		}
	}
	
	this.getValue=function(){
		if(this.Value<this.MinValue)this.Value=this.MinValue;
		if(this.Value>this.MaxValue)this.Value=this.MaxValue;
		return this.Value;	
	}	
	
	this.Increase=function(){
		var __NumericUpDown = this instanceof NumericUpDown ? this : this.NumericUpDown;
		var __Value = __NumericUpDown.getValue();
		if(__Value==__NumericUpDown.MaxValue)return false;
		__NumericUpDown.Value += 1;
		__NumericUpDown.Owner.value = __NumericUpDown.getValue();
		if(__NumericUpDown.HtmlObject)__NumericUpDown.HtmlObject.Label.innerHTML = __NumericUpDown.Owner.value;
	}
	
	this.Decrease=function(){
		var __NumericUpDown = this instanceof NumericUpDown ? this : this.NumericUpDown;
		var __Value = __NumericUpDown.getValue();
		if(__Value==__NumericUpDown.MinValue)return false;
		__NumericUpDown.Value -= 1;
		__NumericUpDown.Owner.value = __NumericUpDown.getValue();
		if(__NumericUpDown.HtmlObject)__NumericUpDown.HtmlObject.Label.innerHTML = __NumericUpDown.Owner.value;		
	}
	
	BuildContainer=function(__NumericUpDown){
		__NumericUpDown.Owner.style.display='none';
		__NumericUpDown.Owner.readOnly = true;
		var __CssPrefix = __NumericUpDown.CssPrefix || '';
		var __Container = _CreateElement({TagName:'DIV'});
		__Container.Parent = __NumericUpDown;
		setClassName(__Container,'NumericUpDown'+ __CssPrefix);
		var __Label = _CreateElement({TagName:'DIV'});
		__Label.Parent = __Container;
		__Label.innerHTML = __NumericUpDown.getValue();
		setClassName(__Label,'Label');
		disableSelection(__Label);
		__Container.Label = __Label;
		var __UpButton = _CreateElement({TagName:'DIV'});
		__UpButton.Parent = __Container;
		__UpButton.NumericUpDown = __NumericUpDown;
		__UpButton.onclick=__NumericUpDown.Increase;
		setClassName(__UpButton,'UpButton');
		disableSelection(__UpButton);
		__Container.UpButton = __UpButton;
		var __DownButton = _CreateElement({TagName:'DIV'});
		__DownButton.Parent = __Container;
		__DownButton.NumericUpDown = __NumericUpDown;		
		setClassName(__DownButton,'DownButton');		
		disableSelection(__DownButton);
		__DownButton.onclick=__NumericUpDown.Decrease;	
		disableSelection(__Container);
		__Container.DownButton = __DownButton;
		__NumericUpDown.HtmlObject = __Container;
		__Container.appendChild(__Label);
		__Container.appendChild(__UpButton);
		__Container.appendChild(__DownButton);
		__NumericUpDown.Container.insertBefore(__Container,__NumericUpDown.Owner);
	}
	
	BuildContainer(this);	
	
}

NumericUpDown.Create=function(Properties){
	Properties = Properties|| {};
	if(Properties.Owner){
		Properties.Owner.NumericUpDown = new NumericUpDown(Properties);	
	}
}
NumericUpDown.Type = {Year:1,Month:2,Day:3,Hour:4,Minute:5,Second:6}
//NumericUpDown::End



