// ProCMS Javascript 
var proJ={
    version: '1.0.1' , isIE: false
    ,$: function(id)  { return document.getElementById(id);  }
    ,tagArray: function(obj, name){ return obj.getElementsByTagName(name);}
    ,addObject: function(tagName, content){var tag = document.createElement(tagName); tag.innerHTML = html; document.body.appendChild(tag);} 
    ,insertObject: function(id, content) {var control = this.$(id);if(control != undefined) { control.innerHTML = content; } }
    ,addEvent: function(obj, eventName, fun)	{  return document.all ? obj.attachEvent(eventName, fun) : obj.addEventListener(eventName.substr(2), fun, false);	}
    ,getContent : function(id) {  if(this.isIE) { return this.$(id).innerText; } else  {return this.$(id).textContent;} }
    ,checkBrowse: function(){ if(window.ActiveXObject){this.isIE=true;}}
    ,initial: function(){this.checkBrowse();}
    ,urlRequest: function(key, url){return (new RegExp('(\\?|&)' + key + '=([^&]*)').exec(url)) ? RegExp.$2 : '';}
    ,setClassName: function(id, className){var button=this.$(id);if(button){ if(this.isIE){button.className = className;}else{button.setAttribute('class', className);}}}   
    ,getClassName: function(id){var button=this.$(id);if(button){ if(this.isIE){return button.getAttribute('className');}else{return button.getAttribute('class');}}}   
    ,display: function(id){var button=this.$(id);if(button){ if (button.style.display=="block") {button.style.display=="none";} else{button.style.display="block"}}}
    ,sendRequest: function(url, param){var list = this.getLableList(param); if (list.length > 1){ var loadPage = url+ '?'+ param +'=' + list; this.loadScript.push(loadPage, 'utf-8', null); }}
    ,getLableList: function(id){ var arr=this.tagArray(document,'label'), len=arr.length, i, requestList=[];
        for(i=0; i<len; i++){ if(arr[i].id.substring(0, id.length) == id && arr[i].id.split('_')[1]) {requestList[requestList.length] = arr[i].id.split('_')[1];} }return requestList.join(','); }
    ,loadScript: { lock : false, ranks : [], callback : function (startTime, callback) { callback && callback(new Date().valueOf() - startTime.valueOf()); this.luck = false, this.read();}
        ,read: function(){if (!this.luck && this.ranks.length) {var head = document.getElementsByTagName("head")[0];
            if (!head) {ranks.length = 0, ranks = null;throw new Error('head不存在');}
            var obj = this, ranks = this.ranks.shift(), startTime = new Date, script = document.createElement('script');this.luck = true;
            script.onload = script.onreadystatechange = function () {if (script && script.readyState && script.readyState != 'loaded' && script.readyState != 'complete') return;
            script.onload = script.onreadystatechange = script.onerror = null, script.src = '', script.parentNode.removeChild(script), script = null; //清理script标记
            obj.callback(startTime, ranks.callback), startTime = ranks = null;};
            script.charset = ranks.charset || 'gb2312';script.src = ranks.src;head.appendChild(script);}}
        ,push : function (src, charset, callback) {this.ranks.push({ 'src' : src, 'charset' : charset, 'callback' : callback });this.read();}
    }
    ,refreshFrame:function(iframeId){ if (this.$(iframeId).src != undefined){ var url = this.$(iframeId).src;
        if (url != ''){ this.$(iframeId).src  = 'about:blank'; this.$(iframeId).src  = url; /*parent.location.reload();*/}else { window.frames[iframeId].location.reload();}}}
}
String.prototype.trim = function() {return this.replace(/(^\s+)|\s+$/g,""); }
proJ.initial();
// // LilyWed Shop Javascript 
var shop={
    version: '1.0.0'
    , loadOrderPrompt: function(){ proJ.addEvent(window, 'onload', function() { 
        proJ.sendRequest('http://shop.lilywed.cn/controls/orderprompt.ashx', 'orderprompt');});
    } 
    , setOrderPrompt: function(shopId, promptContent){ proJ.insertObject('orderprompt_' + shopId, promptContent);
       proJ.insertObject('orderprompt_' + shopId + '_copy', promptContent);
    }
    , expandList: function(categoryId){ var display = (proJ.getClassName('categorylist_' + categoryId) == "display0");
        proJ.$('categoryname_' + categoryId).title = '点这里'+(display ? '收起' : '展开') +'本栏目商家';
        proJ.setClassName('categorylist_' + categoryId, (display ? 'list': 'display0')); //proJ.setClassName('categorylist_' + categoryId + '_copy',  (display ? 'list': 'display0'));
    }
    , showList: function (byTotal){
        proJ.setClassName('shoplist2', 'display'+ (byTotal ? '1': '0')); proJ.setClassName('shoplist1', 'display'+ (byTotal ? '0': '1'));
        proJ.setClassName('shopscore2', 'xyd'+ (byTotal ? '1': '2'));  proJ.setClassName('shopscore1', 'xyd'+ (byTotal ? '2': '1'));
    }    
}
