/*
====================================================

  http://www.GlobalWebCart.com - Version 2

  Copyright 2011 Internet Specialty Services, LLC.

  ANY UN-AUTHORIZED USE OR DISTRIBUTION OF THIS
  FILE OR IT'S CONTENTS IS STRICTLY PROHIBITED

====================================================
*/

/*
	Version: 1.0.3
	Date: 2011-07-29 20:48
	Desc:
	Log:
	v1.0.3@2011-07-29 20:48
	1. add code to make showHide script can works
	V1.0.2: make it call the getPosition and getBrowser function at global.js
*/

function FreezeSet(tI,tID) {
	var ts='';
	if (tI==1) {
		ts=gH(tID+'_scroll');
		}
	else {
		ts=gH(tID+'_default');
		}
	if (ts!='') {
		try{eval(ts);} catch(err) {}
		}
}


var Froze=0;
var proObj = function(sID){
	this.oObj = document.getElementById(sID);
	if (!this.oObj){return;}
	
	var _this = this;
	var callback = null;
	callback = function(){_this.setPosition();};
	
	this.oriPos = getPosition(this.oObj);
	this.oriStyPos = this.oObj.style.position;
	
	this.sBrowser = getBrowser();//alert(this.sBrowser);
	this.isIE6 = false;
	if (this.sBrowser == "IE6"){
		this.isIE6 = true;
	}
	
	if (this.sBrowser == "IE6"){
		this.setPosition();
		this.oObj.style.position = "absolute";
		window.onscroll = function() {
			_this.setPosition();
		}
	}else{
		this.oObj.style.position = "fixed";
		this.setPosition();
		window.onscroll = function() {
			_this.setPosition();
		}
	}
	window.onresize = callback;
}
proObj.prototype = {
	setPosition : function(){
		var addTop = this.getScrollTop();
		if (addTop >= this.oriPos.top){
			this.setSubDivFreeze(true);
			if (Froze!=1) {Froze=1;FreezeSet(1,this.oObj.id);}

			if (this.isIE6){
				this.oObj.style.top = addTop + "px";
			}else{
				//this.oObj.style.position = "fixed";
				this.oObj.style.top = "0px";
			}
		}else{

			if (Froze!=0) {Froze=0;FreezeSet(0,this.oObj.id);}
			this.setSubDivFreeze(true);
			if (this.isIE6){
				this.oObj.style.top = (this.oriPos.top - addTop - 0) + "px";
			}else{
				//this.oObj.style.position = this.oriStyPos;
				//this.oObj.style.top = (this.oriPos.top) + "px";
				this.oObj.style.top = (this.oriPos.top - addTop - 0) + "px";
			}
		}
	},
	setSubDivFreeze : function(bBool){
		var oEles = this.oObj.getElementsByTagName("div");
		for (var i = 0;i < oEles.length;i++){
			oEles[i].isKFreezed = bBool;
		}
	},
	getScrollTop : function(){
		if (this.sBrowser == "safari"){
			return document.body.scrollTop;
		}else{
			return document.documentElement.scrollTop;
		}
	},
	getScrollLeft : function(){
		if (this.sBrowser == "safari"){
			return document.body.scrollLeft;
		}else{
			return document.documentElement.scrollLeft;
		}
	},
	forIE6 : function(sBbr){
		var addTop = document.documentElement.scrollTop;
		this.oObj.style.top = (addTop) + "px";
	}
}
