/**************************************
1. Common
2. TabControl
3. ProvinceCityCombo
4. ModalDialog
5. Couplets
6. Invite
a. CheckHeaderForms.js
b. price.js
**************************************/

if (typeof TAOKE == 'undefined') {
	var TAOKE = {
		Version: '0.0.1'
	}
}

TAOKE.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; ++i) {
        d=a[i].split(".");
        o=TAOKE;

        // TAOKE is implied, so it is ignored if it is included
        for (j=(d[0] == "TAOKE") ? 1 : 0; j<d.length; ++j) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
}

TAOKE.Util = {
	getNumber : function(value, defVal) {
		if ((value == null) || (typeof(value) != "number")) {
			return defVal;
		} else {
			return value;
		}
	},
	
	raiseError : function (focusElement, message) {
    	focusElement.focus();
    	alert(message);
    	return false;
    }
}

String.prototype.getLength = function() {
	var cArr = this.match(/[^\x00-\xff]/ig);
	return this.length + (cArr == null ? 0 : cArr.length);
}

TAOKE.Constants = {
    TEXT_OPEN : "&#25171;&#24320;",
    TEXT_CLOSE : "&#20851;&#38381;",
    
    TOKEN_TOP : "top",
    TOKEN_RIGHT : "right",
    TOKEN_BOTTOM : "bottom",
    TOKEN_LEFT : "left",
    
    CLASSNAME_ENABLED : "enabled",
    CLASSNAME_ACTIVED : "actived",
    CLASSNAME_HIGHLIGHTED : "highlighted",
    CLASSNAME_PASS : "pass",
    CLASSNAME_WARN : "warn",
    
	EVENT_CLICK : 'click',
	EVENT_FOUCS : 'foucs',
	EVENT_KEYUP : 'keyup',
	EVENT_CHANGE : 'change',
	EVENT_BLUR : 'blur',
	EVENT_SUBMIT : 'submit'
}

// TAOKE.UI.TabControl
// COPYRIGHT (C) www.taoke.com 2006-2007

TAOKE.namespace("TAOKE.UI");

TAOKE.UI.TabControl = Class.create();

TAOKE.UI.TabControl.prototype = {
    initialize: function(tabs, hlClassName) {
        if (tabs == null) {
            return;
        }
        
        if (typeof(tabs) == "string") {
            tabs = $A(arguments);
            hlClassName = null;
        }
        
        if (hlClassName == null) {
            this.hlClassName = TAOKE.Constants.CLASSNAME_HIGHLIGHTED;
        }
        else {
            this.hlClassName = hlClassName;
        }
        
        for (var i = 0; i < tabs.length; i++) {
            var tabPage = $(tabs[i]);
            if (tabPage) {
                var tabCtrl = $("t_" + tabPage.id);
                if (tabCtrl) {
                    if (tabCtrl.hasClassName(this.hlClassName)) {
                        this.selectedTabCtrl = tabCtrl;
                        this.selectedTabPage = tabPage;
                    }
                    
                    var link = tabCtrl.down();
                    if (link != null && link.tagName == "A") {
                        link.href = "javascript:;";
                    }
                    else {
                        tabCtrl.style.cursor = "pointer";
                    }
                    tabCtrl.observe("click", this.toggleTab.bindAsEventListener(this, tabCtrl, tabPage));
                    tabCtrl.observe("focus", this.focusTab.bindAsEventListener(this, tabCtrl, tabPage));
                }
            }
        }
    },
    
    toggleTab: function(event, tabCtrl, tabPage) {
        if (this.selectedTabCtrl == tabCtrl) {
            return;
        }
        
        this.selectedTabCtrl.removeClassName(this.hlClassName);
        tabCtrl.addClassName(this.hlClassName);
        tabCtrl.blur();
        
        this.selectedTabPage.hide();
        tabPage.show();
        tabPage.down().focus();

        this.selectedTabCtrl = tabCtrl;
        this.selectedTabPage = tabPage;
    },
    
    focusTab: function(event, tabCtrl, tabPage) {
        if (this.selectedTabCtrl == tabCtrl) {
            tabCtrl.blur();
            var links = tabPage.getElementsByTagName("A");
            if (links.length > 0) {
                links[0].focus();
            }
        }
    }
}




TAOKE.UI.ProvinceCityCombo = Class.create();

TAOKE.UI.ProvinceCityCombo.prototype = {
    initialize : function(provParams, cityParams, dataProvider, showContainer) {
        this.provParams = this.parseParams(provParams);
        this.cityParams = this.parseParams(cityParams);
        if (showContainer) {
        	this.showContainer = showContainer;
      	} 
       
        this.dataProvider = dataProvider;
        
        var provSelect = this.provParams.element;
        if (provSelect.onchange == null) {
            provSelect.onchange = this.doChange.bindAsEventListener(this);
        } else {
            provSelect.onchange = this.provinceChangeWrapper.bindAsEventListener(this, provSelect.onchange);
        }

        var citySelect = this.cityParams.element;
        this.cityParams.onchange = citySelect.onchange;
        // citySelect.onchange = null;
        citySelect.onchange = this.doChangeForCity.bindAsEventListener(this);
        
        this.sourceElem = provSelect;
        this.targetElem = citySelect;

        this.fillSource();
    },
    
    parseParams : function(params) {
        if (!params.element) {
            params = { element: params };
        }
        params.element = $(params.element);
        if (params.initValue == "") {
            params.initValue = null;
        }
        if (!params.defaultText) {
            params.defaultText = "";
        }
        return params;
    },
    
    provinceChangeWrapper : function(event, oldHandler) {
        var citySelect = this.cityParams.element;
        if (this.cityParams.onchange != null) {
            citySelect.onchange = null;
        }
        
        citySelect.options.length = 1;
        
        var option = citySelect.options[0];
        option.text = this.cityParams.defaultText;
        option.value = "";
        option.param_1 = null;
        option.param_2 = null;
        option.selected = "selected";
        oldHandler();        
    },
    
    doChange : function() {
        var citySelect = this.cityParams.element;
        // if (this.cityParams.onchange != null) {
        //     citySelect.onchange = null;
        // }
        
        citySelect.options.length = 1;
        var option = citySelect.options[0];
        option.text = this.cityParams.defaultText;
        option.value = "";
        option.param_1 = null;
        option.param_2 = null;
        option.selected = "selected";

        var provSelect = this.provParams.element;
        var province = this.dataProvider[provSelect.value];
        if (province) {
            citySelect.show();
            this.fillTarget();
        } else {
            citySelect.hide();
            if (citySelect.onchange != null) {
                citySelect.onchange();
            }
        }
        
        if (this.showContainer) {
        	var provName = provSelect.options[provSelect.selectedIndex].text;
        	provName = provName.length < 2 ? "*" : provName    
        	this.showContainer.innerHTML = this.showContainer.innerHTML.replace(/[\u4e00-\u9fa5]+|\*/, provName);
        }
    },
    
    doChangeForCity : function() {
    		var citySelect = this.cityParams.element;        
    		if (this.showContainer) {
        	var cityName = citySelect.options[citySelect.selectedIndex].text;
        	if (cityName) {
        		this.showContainer.innerHTML = this.showContainer.innerHTML.replace(/([\u4e00-\u9fa5]+|\*)/, cityName);
        	} else {
        		var provSelect = this.provParams.element;
        		var provName = provSelect.options[provSelect.selectedIndex].text;
        			provName = provName.length < 1 ? "*" : provName   
        		this.showContainer.innerHTML = this.showContainer.innerHTML.replace(/([\u4e00-\u9fa5]+|\*)/, provName);
        	}
        }

    },
        
    fillSource : function() {
        var provSelect = this.provParams.element;
        var options = provSelect.options;
        
        options.length = 1;
        options[0].text = this.provParams.defaultText;
        options[0].value = "";
        options[0].selected = "selected";

        var found = false;
        for (var pid in this.dataProvider) {
            var province = this.dataProvider[pid];
            var option = new Option(province.name, pid);
            options[options.length] = option;
            
            if (option.value == this.provParams.initValue) {
                option.selected = "selected";
                found = true;
            }
        };
        
        if (found == true) {
            this.fillTarget();
            this.cityParams.element.show();
        }
    },
    
    fillTarget : function() {
        var provSelect = this.provParams.element;
        var province = this.dataProvider[provSelect.value];
        var citySelect = this.cityParams.element;
        var options = citySelect.options;
        
        options.length = 1;
        options[0].text = this.cityParams.defaultText;
        options[0].value = "";
        options[0].selected = "selected";
        
        for (var cid in province.cities) {
            var city = province.cities[cid];
            var option = new Option(city.name, cid);
            option.param_1 = city.postcode;
            option.param_2 = city.telecode;
            options[options.length] = option;
            
            if (option.value == this.cityParams.initValue) {
                option.selected = "selected";
                this.cityParams.initValue = null;
            }
        }
        
        if (options.length == 2) {
            citySelect.remove(0);
        }
        
        if (this.cityParams.onchange != null) {
            citySelect.onchange = this.cityParams.onchange;
        } else if (citySelect.onchange != null) {
            citySelect.onchange();
        }
    }
};




/*
=== USAGE ===
window.dialogSettings = {
	style : {
		top: "50px",
		marginLeft: "-400px",
		width: "800px",
		height: "480px"
	},
	behavior : {
		easyClose : false
	},
	onclose : function() {
		// do something...
		return false;
	}
};
window.dialogDelegate = { };
*/

var ModalDialog = Class.create();

ModalDialog.prototype = {
	initialize : function(clickable, delegate) {
		if (!clickable) {
			return;
		}
		
		if (typeof(clickable) == "string") {
			clickable = $(clickable);
		} else if (typeof(clickable) != "object") {
			return;
		}
		
		if (clickable.id != null && clickable.tagName == "A") {
			Event.observe(clickable, "click", this.clickHandler.bindAsEventListener(this, clickable.href, clickable.title));
		} else if (clickable.element) {
			var eventRaiser = $(clickable.element);
			if (!eventRaiser) {
				return;
			}

			if (!clickable.url || eventRaiser.tagName != "A") {
				return;
			}

			clickable.url = (clickable.url) ? clickable.url : eventRaiser.href;
			clickable.title = (clickable.title) ? (clickable.title) : eventRaiser.title;
			Event.observe(eventRaiser, "click", this.clickHandler.bindAsEventListener(this, clickable.url, clickable.title));
		} else {
			return;
		}
	
		this.delegate = delegate;
	},
	
	clickHandler : function(e, url, title) {
		try {
			this.open(url, title);
			Event.stop(e);
		} catch (ex) {
		}
	},
	
	open : function(url, title) {
		if (!this.overlay) {
			this.overlay = this.createOverlay();
		}
		if (!this.loader) {
			this.loader = this.createLoader();
		}
		
		this.overlay.onclick = this.close.bind(this);
		this.overlay.init();
		
		this.content = this.loader.load(url, title);
	},
	
	close : function() {
		var stop = false;

		if (this.content) {		
			if (typeof(this.content.onclose) == "function") {
				try {
					stop = this.content.onclose();
				} catch (ex) {
				}
			}
		}
		
		if (stop != true) {
			if (this.content) {
				this.content.dispose();
				this.content = null;
			}
			if (this.loader) {
				this.loader.dispose();
				this.loader = null;
			}
			this.overlay.dispose();
		}
	},
	
	createOverlay : function() {
		var overlay = document.createElement("DIV");
		
		overlay.init = function() {
			document.body.appendChild(this);
			Event.observe(window, "resize", this.resize);
			overlay.resize();
		}.bind(overlay);
		
		overlay.dispose = function() {
			Event.stopObserving(window, "resize", this.resize);
			document.body.removeChild(this);
		}.bind(overlay);
	
		overlay.resize = function() {
			this.style.width = document.documentElement.scrollWidth + "px";
			
			var height = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
			height = Math.max(height, document.documentElement.clientHeight);
			this.style.height = height + "px";
		}.bind(overlay);

		Object.extend(overlay.style, {
			position : "absolute",
			top : "0px",
			left : "0px",
			backgroundColor : "#333333",
			opacity : 0.6,
			filter : "alpha(opacity:60)",
			zIndex : 11000
		});
		
		return overlay;
	},
	
	createLoader : function() {
		var loader = document.createElement("DIV");
		Object.extend(loader.style, {
			position : "absolute",
			left : "50%",
			top : (document.documentElement.scrollTop + 150) + "px",
			marginLeft : "-50px",
			height : "100px",
			width : "100px",
			zIndex : 12000,
			backgroundImage : "url('/rainbow/Design/Themes/v3_9/images/loadingAnimation.gif')",
			backgroundRepeat : "no-repeat"
		});
		
		loader.load = function(contentFactory, url, title) {
			this.loading = true;
			document.body.appendChild(this);
			
			var content = contentFactory(this, title);
			content.show(url);
			return content;
		}.bind(loader, this.createIFrame.bind(this));
		
		loader.dispose = function() {
			if (this.loading == true) {
				this.loading = false;
				document.body.removeChild(this);
			}
		}.bind(loader);
		
		loader.loading = false;
		
		return loader;
	},
	
	createIFrame : function(loader, title) {
		var wrapper = document.createElement("DIV");
		Object.extend(wrapper.style, {
			position : "absolute",
			backgroundColor : "#ffffff",
			left : "50%",
			top : "150px",
			marginLeft : "-150px",
			width : "300px",
			height : "200px",
			zIndex : 13000,
			visibility : "hidden"
		});
		
		if (title && title != "") {
			wrapper.innerHTML = "<div>" + title + "</div>";
		}
		
		var iframe = document.createElement("IFRAME");
		iframe.width = "300px";
		iframe.height = "200px";
		iframe.frameBorder = 0;

		iframe.wrapper = wrapper;
		wrapper.appendChild(iframe);

		Event.observe(iframe, "load", function(e, iframe) {
			if (iframe.src != "") {
				var wrapper = iframe.wrapper;
				
				var settings = iframe.contentWindow.dialogSettings;
				if (settings) {
					if (settings.style) {
						Object.extend(wrapper.style, settings.style);
						iframe.width = wrapper.style.width;
						iframe.height = wrapper.style.height;
					}
					
					if (settings.behavior) {
						if (settings.behavior.easyClose == false) {
							this.overlay.onclick = null;
						}
					}
					
					if (typeof(settings.onclose) == "function") {
						wrapper.onclose = settings.onclose;
					}
				}
				
				var delegate = iframe.contentWindow.dialogDelegate;
				if (!delegate) {
					delegate = { };
					iframe.contentWindow.dialogDelegate = delegate;
				}
				delegate.close = function() {
					this.close();
				}.bind(this);
					
				if (this.delegate) {
					Object.extend(delegate, this.delegate);
				}
			
				wrapper.style.top = (document.documentElement.scrollTop + wrapper.offsetTop) + "px";
				wrapper.style.visibility = "";
				
				if (this.loader) {
					this.loader.dispose();
				}
			}
		}.bindAsEventListener(this, iframe));
		
		wrapper.show = function(url) {
			document.body.appendChild(this.wrapper);
			this.src = url;
		}.bind(iframe);
		
		wrapper.dispose = function() {
			document.body.removeChild(wrapper);
		}.bind(wrapper);
		
		return wrapper;
	}
};

var ModalDialogFactory = {
	createByCssRule : function(cssRule) {
		this.createMany($$(cssRule));
	},
	
	createMany : function(elements) {
		elements.each(function(element) {
			new ModalDialog(element);
		});
	}
};




// TAOKE.UI.Couplets
// COPYRIGHT (C) www.taoke.com 2006-2007

TAOKE.UI.Couplets = Class.create();

TAOKE.UI.Couplets.prototype = {
    initialize: function(container, bodyWidth, coupletWidth, marginTop, closeText) {
        var bodyWidth = TAOKE.Util.getNumber(bodyWidth, 776);
        var coupletWidth = TAOKE.Util.getNumber(coupletWidth, 100);
        if (window.screen.width < bodyWidth + coupletWidth * 2) {
            return;
        }
        
        if (closeText == null || closeText.strip().length == 0) {
            this.closeText = TAOKE.Constants.TEXT_CLOSE;
        }
        else {
            this.closeText = closeText.strip();
        }
        
        this.marginTop = TAOKE.Util.getNumber(marginTop, 20);
        this.marginLR = ((window.screen.width - bodyWidth) / 2 - coupletWidth) / 4;
        
        var container = $(container);
        this.couplets = new Array();

        var inners = container.select(".couplet");
        for (var i = 0, length = inners.length; i < length; ++i) {
            var inner = inners[i];
            var leftCouplet = null;
            var rightCouplet = null;

            if (inner.hasClassName(TAOKE.Constants.TOKEN_LEFT)) {
                leftCouplet = this.createCouplet(inner, TAOKE.Constants.TOKEN_LEFT);
            } 
            
            if (inner.hasClassName(TAOKE.Constants.TOKEN_RIGHT)) {
                rightCouplet = this.createCouplet(inner, TAOKE.Constants.TOKEN_RIGHT);
                if (leftCouplet == null) {
                    container.removeChild(inner);
                    rightCouplet.insertBefore(inner, rightCouplet.closeButton);
                }
                else {
                    var rightInner = inner.cloneNode(true);
                    inner.removeClassName(TAOKE.Constants.TOKEN_RIGHT);
                    rightInner.removeClassName(TAOKE.Constants.TOKEN_LEFT);
                    
                    container.removeChild(inner); 
                    leftCouplet.insertBefore(inner, leftCouplet.closeButton);
                    container.appendChild(leftCouplet);
                    this.couplets.push(leftCouplet);
                    
                    rightCouplet.insertBefore(rightInner, rightCouplet.closeButton);
                }
                container.appendChild(rightCouplet);
                this.couplets.push(rightCouplet);
            }
            else if (leftCouplet != null) {
                container.removeChild(inner);
                leftCouplet.insertBefore(inner, leftCouplet.closeButton);
                container.appendChild(leftCouplet);
                this.couplets.push(leftCouplet);
            }
        }
        
        if (this.couplets.length == 0) {
            this.marginTop = this.marginLR = this.couplets = null;
            return;
        }
        
        container.show();
        this.scroll();
        
        Event.observe(window, "scroll", this.scroll.bindAsEventListener(this));
        Event.observe(window, "resize", this.scroll.bindAsEventListener(this));
        Event.observe(window, "load", this.scroll.bindAsEventListener(this));
    },
    
    createCouplet: function(inner, position) {
        var couplet = document.createElement("DIV");
        couplet.className = "wrapper clearfix " + position;
        couplet.style.position = "absolute";
        couplet.style.zIndex = 1000;
        
        var closeButton = document.createElement("A");
        closeButton.href = "javascript:;";
        closeButton.className = "closeAction";
        closeButton.innerHTML = this.closeText;
        closeButton.onclick = function() {
            this.parentNode.style.display = "none";
        }
        
        couplet.closeButton = closeButton;
        couplet.appendChild(closeButton);
        
        return couplet;
    },
    
    scroll: function(event) {
        for (var i = 0, length = this.couplets.length; i < length; ++i) {
            var couplet = this.couplets[i];
            if (couplet.style.display == "none") {
                continue;
            }

            couplet.style.top = (document.documentElement.scrollTop + this.marginTop) + "px";
            if (Element.hasClassName(couplet, TAOKE.Constants.TOKEN_LEFT)) {
                couplet.style.left = (document.documentElement.scrollLeft + this.marginLR) + "px";
            }
            else if (Element.hasClassName(couplet, TAOKE.Constants.TOKEN_RIGHT)) {
                couplet.style.left = (document.documentElement.scrollLeft + document.documentElement.clientWidth
                    - couplet.offsetWidth - this.marginLR) + "px";
            }
        }
    }
}


TAOKE.UI.SingleCouplet = Class.create();

TAOKE.UI.SingleCouplet.prototype = {
    initialize: function(content, bodyWidth, coupletWidth, marginTop) {
        var bodyWidth = TAOKE.Util.getNumber(bodyWidth, 776);
        var coupletWidth = TAOKE.Util.getNumber(coupletWidth, 100);
        if (window.screen.width < bodyWidth + coupletWidth * 2) {
            return;
        }
                
        this.marginTop = TAOKE.Util.getNumber(marginTop, 20);
        this.marginLR = ((window.screen.width - bodyWidth) / 2 - coupletWidth) / 4;
                
        this.content= $(content);
        this.content.style.position = "absolute";
        this.content.style.zIndex = "1000";
        
        var closeActions = this.content.select('[class="closeAction"]');
        for (var i = 0, length = closeActions.length; i < length; ++i) {
            var closeAction = closeActions[i];
            closeAction.onclick = function() {
                this.parentNode.style.display = "none";
            }
        }
        
        this.content.show();
        this.scroll();
        
        this.scrollHandler = this.scroll.bindAsEventListener(this);
        Event.observe(window, "scroll", this.scrollHandler);
        Event.observe(window, "resize", this.scrollHandler);
        Event.observe(window, "load", this.scrollHandler);
    },
    
    scroll: function(event) {
        if (this.content.style.display == "none") {
            Event.stopObserving(window, "scroll", this.scrollHandler);
            Event.stopObserving(window, "resize", this.scrollHandler);
            Event.stopObserving(window, "load", this.scrollHandler);
            return;
        }
        
        this.content.style.top = (document.documentElement.scrollTop + this.marginTop) + "px";
        if (Element.hasClassName(this.content, TAOKE.Constants.TOKEN_LEFT)) {
            this.content.style.left = (document.documentElement.scrollLeft + this.marginLR) + "px";
        }
        else if (Element.hasClassName(this.content, TAOKE.Constants.TOKEN_RIGHT)) {
            this.content.style.left = (document.documentElement.scrollLeft + document.documentElement.clientWidth
                - this.content.offsetWidth - this.marginLR) + "px";
        }
    }
}




TAOKE.UI.Invite = Class.create();

TAOKE.UI.Invite.prototype = {
    initialize: function(dialog, dialogWidth, marginTop) {
        dialog = $(dialog);
        if (!dialog) {
			return;
        }
        
        this.dialog = dialog;
        var dialogWidth = TAOKE.Util.getNumber(dialogWidth, 439);        
        this.marginTop = TAOKE.Util.getNumber(marginTop, 200);
        this.marginLeft = (window.screen.width - dialogWidth) / 2;     
        this.dialog.style.left = this.marginLeft + 'px';  
    	this.dialog.style.top = (document.documentElement.scrollTop + this.marginTop) + "px";	   
        if (this.dialog != null) {
        	Event.observe(window, "scroll", this.scroll.bindAsEventListener(this));
        	Event.observe(window, "resize", this.scroll.bindAsEventListener(this));
        }
    },
    
    scroll: function(event) {
    	if (this.dialog != null && this.dialog.visibility != "hidden") {
    		var _dailog = $('InviteWindow');
    		if (_dailog == null) {
    			return;
    		}
    		_dailog.style.top = (document.documentElement.scrollTop + this.marginTop) + "px";
    	}
    }
    
}




var checkingLC = false;

function checkLoginConditions(userName, password) {
	var uidLength = userName.value.getLength();
	if (uidLength == 0) {
		return TAOKE.Util.raiseError(userName, "\u8BF7\u8F93\u5165\u60A8\u7684\u7528\u6237\u540D\u3002");
	} else if (uidLength < 4) {
		return TAOKE.Util.raiseError(userName, "\u60A8\u8F93\u5165\u7684\u7528\u6237\u540D\u957F\u5EA6\u4E0D\u591F\uFF0C\u8BF7\u68C0\u67E5\u60A8\u7684\u8F93\u5165\u3002\r\n\u4E2D\u6587\u4E24\u4E2A\u6C49\u5B57\u4EE5\u4E0A\uFF0C\u82F1\u6587\u56DB\u4E2A\u5B57\u6BCD\u4EE5\u4E0A\u3002");
	} else {
		var pwdLength = password.value.getLength();
		if (pwdLength == 0) {
			return TAOKE.Util.raiseError(password, "\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801\u3002");
		}
	}
	return true;
}

function checkSearchConditions(keywords) {
	if (checkingLC == true) {
		return false;
	}
	
	keywords.value = keywords.value.strip();
	if (keywords.value.getLength() == 0) {
		return TAOKE.Util.raiseError(keywords, "\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u5B57\u3002");
	}
	return true;
}




 function ClearPriceTip(ObjID)
 {
	var ObjPrice = document.getElementById(ObjID);	
	if (ObjPrice.value == "\u6700\u4F4E\u4EF7" || ObjPrice.value == "\u4E0D\u9650\u6700\u4F4E\u4EF7" || ObjPrice.value == "\u6700\u9AD8\u4EF7" || ObjPrice.value == "\u4E0D\u9650\u6700\u9AD8\u4EF7")
	{
		ObjPrice.value = "";
	}
}

 function FillPriceTip(ObjID,objName,newObjName,minObj)
 {
	var ObjPrice = document.getElementById(ObjID);
	if (ObjPrice.value != "" && ((parseInt(ObjPrice.value)).toString() == "NaN" || parseInt(ObjPrice.value) < 0))
	{
		alert("\u8BF7\u8F93\u5165\u5927\u4E8E\u6216\u7B49\u4E8E0\u7684\u6574\u6570\u6570\u636E");
		ObjPrice.value = "";
		ObjPrice.focus();
	}	
	else if (ObjPrice.value == "")
	{
		if (minObj == "1")
		{
			ObjPrice.value = "\u4E0D\u9650\u6700\u4F4E\u4EF7";
		}
		else
		{
			ObjPrice.value = "\u4E0D\u9650\u6700\u9AD8\u4EF7";
		}
	}
	else
	{
		ObjPrice.value = parseInt(ObjPrice.value);
		var otherObj = GetObj(ObjID,objName,newObjName);
		if (minObj == "1")
		{
			CompareMinMaxPrice(ObjID,otherObj);
		}
		else
		{
			CompareMinMaxPrice(otherObj,ObjID);
		}		
	}
 }
 	
function CompareMinMaxPrice(ObjMinPriceID, ObjMaxPriceID)
{
	if (ObjMaxPriceID != null && ObjMinPriceID != null)
	{
		var ObjMinPrice = document.getElementById(ObjMinPriceID);
		var ObjMaxPrice = document.getElementById(ObjMaxPriceID);
		if (ObjMaxPrice.value != "" && (parseInt(ObjMaxPrice.value)).toString() != "NaN" && ObjMinPrice.value != "" && (parseInt(ObjMinPrice.value)).toString() != "NaN" && parseInt(ObjMinPrice.value) > parseInt(ObjMaxPrice.value))
		{
			alert("\u63D0\u9192\uFF1A\u6700\u4F4E\u4EF7\u683C\u4E0D\u8981\u5927\u4E8E\u6700\u9AD8\u4EF7\u683C.");
		}
	}
}

function GetObj(objID,objName,newObjName)
{
	var parentIDlength = objID.length - objName.length;
	var parentID = objID.substring(0, parentIDlength);
	var newObjID = parentID + newObjName;
	return newObjID;
}

function getCookie(name) {
    var start = document.cookie.indexOf(name + "=");
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length))) {
        return null;
    }
    if (start == -1) return null;
    var end = document.cookie.indexOf(';', len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len, end));
}

function setCookie(name, value, expires, path, domain, secure) {
    var today = new Date();
    today.setTime(today.getTime());
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));
    document.cookie = name + '=' + escape(value) +
	((expires) ? ';expires=' + expires_date.toGMTString() : '') + //expires.toGMTString()
	((path) ? ';path=' + path : '') +
	((domain) ? ';domain=' + domain : '') +
	((secure) ? ';secure' : '');
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + '=' +
		((path) ? ';path=' + path : '') +
		((domain) ? ';domain=' + domain : '') +
		';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    }
}

