

/*********************************************************
浏览纪录使用函数 -- 开始
**********************************************************/
function makeRecentHistory(img,url)
{   
	var history; 	
	var temp_ImgUrl;
	var temp,tmp;
	var isHave;
	temp_ImgUrl = img + "^" + url;

	history =  getCookieHistory("HTR");
	if( history == null )
	{		
		setCookieHistory("HTR", temp_ImgUrl);
		history = getCookieHistory("HTR");
		
		if( history == null)
			history = temp_ImgUrl;
	}
	else
	{	

		temp = history.split("|");			
		isHave = false;
		
		for (var i=0; i < temp.length; i++)
		{
			tmp = temp[i].split("^");	
			if (tmp[1] == url)
			{
				isHave = true;
				break;
			}
		}			
		if (isHave == false)
		{			
	        history = temp_ImgUrl + "|" + history;
		}
		
	}	
	setCookieHistory("HTR", history);	
	
}


function countHistory() 
{
		
	var history;
	var tmp;	

	history =  getCookieHistory("HTR");
   
	if (history != null)
	{		
		tmp = history.split("|");
		return tmp.length;		
	} 
	else 
	{
		return 0;
	}
}


function setCookieHistory(name, value)
{   
    var argv = setCookieHistory.arguments;
    var argc = setCookieHistory.arguments.length;

    var expires = (argc > 2) ? argv[2] : null;    
    var path = "/";	
    var domain = null;
    var secure = (argc > 5) ? argv[5] : false;
	//var path = (argc > 3) ? argv[3] : null;
    //var domain = (argc > 4) ? argv[4] : null;
	
    document.cookie = name + "=" + escape(value) +";path=" + path;
    /*
                      ( expires == null  ? "" : ("; expires=" + expires.toGMTString())) +
                      ( path == null     ? "" : ("; path=" + path) ) +
                      ( domain == null   ? "" : ("; domain=" + domain) ) +
                      ( secure == true   ? "; secure" : "" );
                      */
    
}

function getCookieHistory(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen=document.cookie.length;
    var i=0;

    while(i< clen)
	{
        var j = i+alen;
        if(document.cookie.substring(i,j)==arg) 
		{
            var end = document.cookie.indexOf(";",j);
            if (end == -1) 
			{
                end = document.cookie.length;
            }
            return unescape(document.cookie.substring(j,end));
        }
        i = document.cookie.indexOf(" ",i)+1;
        if (i==0) 
		{
            break;
        }
    }
    return null;
}

/*********************************************************
浏览纪录使用函数 -- 结束
**********************************************************/

function get_scrollDiv(parentDiv,strDivPrefix,arrContent)
{
	this.arrScrollContent  = new Array();
	this.parentDiv         = document.getElementById(parentDiv);
	this.strDivPrefix      = strDivPrefix;	
	this.arrScrollContent  = arrContent;
	
	this.scrollDirection   = "V";  //H,horizontal /V,vertical,控制滚动方向，V垂直
	this.scrollLength      = 20;
	this.scrollSpeed       = 1;
	this.scrollDivWidth    = 260; 
	this.scrollDivHeight   = 20;	
	this.intervalTime      = 4000;
	
	this.isMouseOver       = false;
	this.isStop            = false;		
	this.countScrollDiv    = null;	
	
	
	this.set_scrollDirection = function (direction) 
	                           { this.scrollDirection = direction; };
							   
    this.set_scrollLength    = function (length)
	                           { this.scrollLength = length; };
	
    this.set_scrollSpeed     = function (speed)
	                           { this.scrollSpeed = speed; };
	
    this.set_scrollDivWidth  = function (divWidth)
	                           { this.scrollDivWidth = divWidth; };
	
    this.set_scrollDivHeight = function (divHeight)
	                           { this.scrollDivHeight = divHeight; };	
	
	this.set_intervalTime    = function (millisecond)
	                           { this.intervalTime = millisecond; };	
	
	this.set_isMouseOver     = function (boolean)
	                           { this.isMouseOver = boolean; };
	
    this.set_isStop          = function (boolean)
	                           { this.isStop = boolean; };	
	
	this.set_countScrollDiv  = function (millisecond)
	                           { this.countScrollDiv = millisecond; };	


    this.insertDiv = function()
					 {	
						var strDiv;	
						var i;
						var positionStr;
						positionStr = "position:absolute;width:"+ this.scrollDivWidth +"px;height:"+ this.scrollDivHeight +"px;";
						
						if (this.scrollDirection == "V")
						{
							positionStr = positionStr + "left:0px; top:";
						}
						else if(this.scrollDirection == "H")
						{
							positionStr = positionStr + "top:0px; left:";
						}
						
						for (i = 0; i < this.arrScrollContent.length; i++)
						{
							strDiv  = "";
							strDiv += " <div id='scrollDiv_" + this.strDivPrefix + i + "' ";
							strDiv += " style='" + positionStr + (this.scrollLength * i) + "px;'>";
							strDiv +=   this.arrScrollContent[i];
							strDiv += " </div>";
							document.write(strDiv);
						}
													
	                    this.countScrollDiv    = this.parentDiv.getElementsByTagName('div').length;
					 };
	
	this.scrollDiv = function()
					 {	
						var tempStyle;
						var i;
						if ((this.isMouseOver == false) && (this.isStop == false))
						{
							for(i = 0; i < this.countScrollDiv; i++) 
							{	
								tempStyle = document.getElementById('scrollDiv_' + this.strDivPrefix + i).style;
								
								if (this.scrollDirection == "V")
								{											
								    tempStyle.top = parseInt(tempStyle.top) - this.scrollSpeed;	
									
									if (parseInt(tempStyle.top) <= -this.scrollLength)
									{
										tempStyle.top = this.scrollLength * (this.countScrollDiv - 1);			
									}

									if (parseInt(tempStyle.top) == 0)
									{
										this.isStop = true;										
										window.setTimeout("this.isStop=false;", this.intervalTime);										
									}
								}
								else if (this.scrollDirection == "H")	
								{	
								    tempStyle.left = parseInt(tempStyle.left) - this.scrollSpeed;	
									
									if (parseInt(tempStyle.left) <= -this.scrollLength)
									{
										tempStyle.left = this.scrollLength * (this.countScrollDiv - 1);			
									}
																	
									if (parseInt(tempStyle.left) == 0)
									{
										this.isStop = true;										
										window.setTimeout("this.isStop=false;", this.intervalTime);											
									}										
								}																	
							}
						}
						//window.setTimeout("get_scrollDiv.prototype.scrollDiv();", 0);
						//window.setTimeout(this.scrollDiv(), 8000);						
						this.scrollDiv();
						//window.setTimeout("this.scrollDiv();", 5000);
					 };
	
	this.nextDiv  = function()
					{    	
						var tempStyle;
						var i;
						
						for(i = 0; i < this.countScrollDiv; i++) 
						{
							tempStyle = document.getElementById('scrollDiv_' + this.strDivPrefix + i).style;
							
							if (this.scrollDirection == "V")
							{				
								tempStyle.top = parseInt(tempStyle.top) - this.scrollLength;	
							
								if (parseInt(tempStyle.top) <= -this.scrollLength)
								{
									tempStyle.top = this.scrollLength * (this.countScrollDiv - 1);			
								}
							}
							else if (this.scrollDirection == "H")	
							{				
								tempStyle.left = parseInt(tempStyle.left) - this.scrollLength;	
							
								if (parseInt(tempStyle.left) <= -this.scrollLength)
								{
									tempStyle.left = this.scrollLength * (this.countScrollDiv - 1);			
								}	
							}								
						}		
					};
	
	this.previousDiv =  function()
						{		
							var tempStyle;
							var i;
							
							for(i = 0; i < this.countScrollDiv; i++) 
							{
								tempStyle = document.getElementById('scrollDiv_' + this.strDivPrefix + i).style;
								
								if (this.scrollDirection == "V")
								{								
									if (parseInt(tempStyle.top) >= this.scrollLength * (this.countScrollDiv - 1))
									{
										tempStyle.top = -this.scrollLength;			
									}				
									tempStyle.top = parseInt(tempStyle.top) + this.scrollLength;	
								}
								else if (this.scrollDirection == "H")	
								{				
									if (parseInt(tempStyle.left) >= this.scrollLength * (this.countScrollDiv - 1))
									{
										tempStyle.left = -this.scrollLength;			
									}
									tempStyle.left = parseInt(tempStyle.left) + this.scrollLength;	
								}								
							}		
						};
	
	this.checkMouseOver =   function()
							{			
								var tempStyle;
								var i;
								var over = 0;	
								
								for (i = 0; i < this.countScrollDiv; i++)
								{
									tempStyle = document.getElementById('scrollDiv_' + this.strDivPrefix + i).style;
									
									if (this.scrollDirection == "V")
									{										
										if (parseInt(tempStyle.top) % this.scrollLength != 0)
										{
											over++;
										}
									}
									else if(this.scrollDirection == "H")	
									{										
										if (parseInt(tempStyle.left) % this.scrollLength != 0)
										{
											over++;
										}
									}									
								}
								
								if(over == 0)
								{
									this.isMouseOver = true;
								}			
							};
}
