// JScript 文件

var utility = new HttpUtility();
//layoutCookie=username|layoutStyle
function Layout(){
   var self=this;
   var __utility__=new HttpUtility();
   
     
   this.load=function(){
      gE("progress").style.display="block";
      var cookie=new Cookie();
      var __layout__=cookie.getCookie("layout");
      if(__layout!=null&&__layout!=""){
         var _layoutArray=__layout__.split('|');
         var _layoutUser=_layoutArray[0];
         var _layoutStyle=_layoutArray[1];
         switch (_layoutStyle){
            case "3-row":
              break;
            case "2-row":
              break;
            case "1-row":
              break;
            case "undeifned":
              break;
            case default:
              break;
         }
      }
      else{
        self.layoutSet(3);
      }
   }
   
   this.layoutSet=function(rowNums){
     var _layoutObj;
     for(var i=0;i<parseInt(rowNums);i++){
       _layoutObj=document.createElement("div");
       _layoutObj.setAttribute("id","DragContainer"+i);
       _layoutObj.setAttribute("class","DragContainer");
      gE("PageContent").appendChild(_layoutObj);
     }
     CreateDragContainer();
     gE("progress").style.display="none";
   }
}

UserWindow.prototype = new Object();
UserWindow.superclass = Object.prototype;
function UserWindow(){
   var self = this;
   var __utility__ = new HttpUtility();
   
   this.load = function() {
		var cookie = new Cookie();
	    var userView = cookie.getCookie("userView"); //get cookie
	    if (userView != null && userView != "") { //if browser has cookie
	        var userPanelSet = userView.split('|'); //split them
	        var count = 0;
	        var list = "";
	        list = "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" style=\"width: 100%;\">";     
	        for (var j = 0; j < userPanelSet.length; j += 2) {
		        var PanelID = userPanelSet[j];
		        var PanelName = userPanelSet[j + 1];
		        var PanelRssUrl=userPanelSet[j+2];
		        var PanelRssNums=userPanelSet[j+3];
		        count++;
		        list += "<tr><td align=\"left\" valign=\"middle\"><img src=\"images/r.jpg\" style=\"width: 6px; height: 9px; margin-right: 3px;\" alt=\"\" />";
		        list += "<a href=\"javascript:top.page.productList.getProdDetails(" + id + ",'" + name + "',false);\" class=\"ColorBlack\">" + name + "</a>";
		        list += "</td></tr>";
	        }
	        if (count == 0) {
		        list += "<tr><td style=\"width: 100%; height: 80px;\" align=\"center\" valign=\"middle\" class=\"InvalidMessage\">没有任何商品。</td></tr>";
		    }
		    list += "</table>";
		    gE("bodyMyRecentViewed").innerHTML = list;
	    }
	    else {
	        gE("bodyMyRecentViewed").innerHTML = "<div style=\"width: 100%; height: 40px; padding-top: 30px;\" align=\"center\" class=\"InvalidMessage\">没有任何商品。</div>";
	    }
	}


}
function LoadRss(url,id,rssNum,refresh){
   	var __RssTable__ = new Dragable();
	__RssTable__.controlId = id+"_Content";;
	__RssTable__.handlerId = id+"_Title";
	__RssTable__.bind(); 

    $(id).innerHTML="<img src=\"../IMS_Img/Loading.gif\"/>正在连接网站，请稍候..."
    var xmlhttp=GetAjaxObject();
    
    var submitURL=ServiceUrl+"?Action=GetRssContent&rssurl="+url;
    if(parseInt(refresh)==1)
    {
       submitURL=ServiceUrl+"?Action=GetRssContent&rssurl="+url+"&rnd="+Math.random();      
    }
   
    rssNum=parseInt(rssNum);      
//    if(!IsNaN(rssNum))
   //  rssNum=10;   
       xmlhttp.onreadystatechange=function()
       {  
           if(xmlhttp.readystate==4)
           {  
              if(xmlhttp.status==200)
              {
                 
                 title.length=0;
                 link.length=0;
                 pubDate.length=0;
                 description.length=0;                
                 var rssobj=xmlhttp.responseXML;              
                 var news=rssobj.getElementsByTagName("item");
                 if(news.length<rssNum)
                   rssNum=news.length;             
                 for(var i=0;i<rssNum;i++)
                 {           
                    title[i]=news[i].getElementsByTagName("title")[0].firstChild.nodeValue; 
                    link[i]=news[i].getElementsByTagName("link")[0].firstChild.nodeValue;                   
                    pubDate[i]=news[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue;                    
                     if(news[i].getElementsByTagName("description")[0].hasChildNodes())
                     {
                        description[i]=news[i].getElementsByTagName("description")[0].firstChild.nodeValue;  
                     }       
                     else
                     {
                        description[i]="略";
                     }  
                 }
                 var result="<ul>";
                 for(var i=0;i<title.length;i++)
                 {
                    result+="<li><a href='"+link[i]+"' target='_blank' onmouseover='showdescription("+i+");'onmouseout='hidedescription();'>"+title[i]+"</a></li>";
                 }
                 result+="</ul>"
                 $(id).innerHTML=result;
              }
              else
                 $(id).innerHTML="网站暂时未能连接请稍候重试";    
           }
      }
     xmlhttp.open("GET",submitURL,true); 
     xmlhttp.send(null);    
}