






var slider
var Sectionform
var Sectionwindow
var view


//Sizeobj对象实例
function Sizeobj(_Pw,_Ph,_Sw,_Sh,_Pd,_Sd,_Pbc,_Sbc){
		var _size={};
		_size.Pw=_Pw;
		_size.Ph=_Ph;
		_size.Sw=_Sw;
		_size.Sh=_Sh;
		_size.Pd=_Pd;
		_size.Sd=_Sd;
		_size.Pbc=_Pbc;
		_size.Sbc=_Sbc;
		_size._Wbi=_size.Sw/_size.Pw;
		_size._Hbi=_size.Sh/_size.Ph;
		_size._Dbi=_size.Sd/_size.Pd;
		
	return _size;
	}
	

// Sizechange(尺寸对象（屏幕及实际尺寸，要求尺寸）)
function  Sizechange(_Size,_Rsize){
			//aa
			if(_Rsize.Pw){
				_Rsize.Sw=_Rsize.Pw*_Size._Wbi;
				
				}else {
					_Rsize.Pw=_Rsize.Sw/_Size._Wbi;
					
					}
			if(_Rsize.Ph){
				_Rsize.Sh=_Rsize.Ph*_Size._Hbi;
				
				}else {
					_Rsize.Ph=_Rsize.Sh/_Size._Hbi;
					
					}
			if(_Rsize.Pd){
				_Rsize.Sd=_Rsize.Pd*_Size._Dbi;
				_Rsize.Sbc=_Rsize.Pbc*_Size._Dbi;
				}else {
					_Rsize.Pd=(_Rsize.Sd-_Rsize.Sbc)/_Size._Dbi;
					_Rsize.Pbc=_Rsize.Sbc/_Size._Dbi;
					}
				_Rsize._Dbi=_Size._Dbi;
		return  _Rsize;
	}
	
//初始化 VSection
function countSectionsize(){
	VSection.w.autoNum=0
	VSection.w.length=0
		for (var i=0 ;i<Pvar.ncfg;i++){
				if(Pvar.sectionSize[i].w){
						VSection.w.length+=Pvar.sectionSize[i].w;
						VSection.w.size[i]=Pvar.sectionSize[i].w;
						VSection.w.autoTag[i]=0;
					}else{
						
							VSection.w.autoNum+=1;
							VSection.w.autoTag[i]=1;
						
						
						}
			
			}
	
	}
	
//计算单元显示尺寸
function countUnitSize(i){
		var _Rsize,_H,_D;
		if(Pvar.sectionSize[i].h){
			_H=	Pvar.sectionSize[i].h
			}else{
				_H=boxSize.Sh;
				}
		if(Pvar.sectionSize[i].d){
			_D=	Pvar.sectionSize[i].d
			}else{
				_D=boxSize.Sd;
				}
		if(VSection.w.autoTag[i]){
			
			 _Rsize=new Sizeobj(0,0,Math.floor(((boxSize.Sw- VSection.w.length)/VSection.w.autoNum)),_H,0,_D,0,Pvar.sectionSize[i].bc);

		}else{
			 _Rsize=new Sizeobj(0,0,VSection.w.size[i],_H,0,_D,0,Pvar.sectionSize[i].bc);


		}
			return Sizechange(boxSize,_Rsize);
	
	}
//初始化boxSize VSection(w=屏幕尺寸,h=屏幕尺寸)
function initPsize(_w,_h,_d){
	if(!_d){
		_d=100;
	}
		//Pvar.boxSize.w-Pvar.Tpanels  Pvar.Totals
		//alert(Pvar.Totals)
		boxSize=new Sizeobj (_w,_h-_d,Pvar.boxSize.w,Pvar.boxSize.h,_d,Pvar.boxSize.d);
		countSectionsize();


	}
	
//重置Pvar	
function setFormToPvar( _formvar ,_relation){
	
	
		for( key in _formvar ){
			
				var _Pkey=_relation[key]
				if(undefined!=_Pkey){
					var dotNum=_Pkey.indexOf(".")
					if(dotNum>0){
						
						Pvar[_Pkey.substring(0,dotNum)][_Pkey.substring(dotNum+1)]=_formvar[key];
					}else {
						Pvar[_Pkey]=_formvar[key];
						}
				}
			}
	}
	
//获得Pvartoform  
function getPvarToFrom( _relation){
	var _formvar={}
		for(key in _relation){
				var _Pkey=_relation[key]
				if(undefined!=_Pkey){
					var dotNum=_Pkey.indexOf(".")
					if(dotNum>0){
						_formvar[key]=Pvar[_Pkey.substring(0,dotNum)][_Pkey.substring(dotNum+1)]
						
					}else {
						_formvar[key]=Pvar[_Pkey]
						
						}
				}
			
			}
			
	
	return  _formvar
	}

//设置section数据给2020
function setSectionTo2020(_i){
	
	var _j=parseInt(_i)+1
	var VAR2020=""
		VAR2020+="CFW2["+_j+"]="+Pvar.sectionSize[_i].w +";";
		VAR2020+="ch3["+_j+"]="+Pvar.sectionSize[_i].h+";";
		VAR2020+="CFd1["+_j+"]="+Pvar.sectionSize[_i].d+";";
		VAR2020+="CFd2["+_j+"]="+Pvar.sectionSize[_i].bc;
	updata(VAR2020)
	
	}
	
function syncSectionHD(_newvar,_oldvar){
		for (var i=0 ; i<maxncfg ;i++){
			if(_oldvar.h==Pvar.sectionSize[i].h && Pvar.sectionSize[i].h!=0 ){
					Pvar.sectionSize[i].h= _newvar.h 		
				}
			if(_oldvar.d==Pvar.sectionSize[i].d  && Pvar.sectionSize[i].d!=0 ){
					Pvar.sectionSize[i].d= _newvar.d 		
				}			
			}

	}
	
function mode32(_value,_offset){
	
		if(!_offset){
			_offset=offset
			}
		return (_value-_offset)%32==0
	}	

//initPsize(600,300);