
var NUM=5;

c_codeList = getCookie("conumList");
c_nameList = getCookie("conameList");


codeList = c_codeList.split("|");
nameList = c_nameList.split("|");


function getCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function setCookie( name, value, expiredays )
{
	if(expiredays == 0) {
		document.cookie = name + "=" + escape( value ) + "; path=/;"
	}
	else {
		var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
	}
}

function stockclass_visited_Add(code, name) 
{
	var n_CodeList = new Array;
	var n_NameList = new Array;
	

	n_CodeList[0] = code;
	n_NameList[0] = name;
	
	
	for(i=0,index=1; i<NUM && i<codeList.length-1 ; i++) {
		if(code != ""+codeList[i]) {
			n_CodeList[index] = codeList[i];
			n_NameList[index] = nameList[i];
	
			index++;
		}
	}

	codeList = n_CodeList;
	nameList = n_NameList;
	

	stockclass_visited_Save();
}

function stockclass_visited_Del(code)
{
	var n_CodeList = new Array;
	var n_NameList = new Array;
	

	for(i=0,index=0; i<codeList.length && i<NUM; i++) {
		if(code != ""+codeList[i]) {
			n_CodeList[index] = codeList[i];
			n_NameList[index] = nameList[i];
	
			index++;
		}
	}

	codeList = n_CodeList;
	nameList = n_NameList;
	

	stockclass_visited_Save();
	stockclass_Visited();
}

function stockclass_visited_Save() {
	c_codeList="";
	c_nameList="";
	
	
	for(i=0; i<codeList.length; i++) {
		tempCode = ""+codeList[i];
		if(tempCode != "undefined" && tempCode.length > 0) {
			c_codeList = c_codeList+codeList[i]+"|";
			c_nameList = c_nameList+nameList[i]+"|";
	
		}
	}

	setCookie("conumList",c_codeList,5);
	setCookie("conameList",c_nameList,5);
	
}

function stockclass_Visited() {
	Express_list = "<table width=682 cellspacing=0 cellpadding=0 border=0><tr><td background='images/visited_line_bg.gif' height=29 width=682>";	
	Express_list += "<table width=682 cellspacing=0 cellpadding=0 border=0><tr><td height=4></td></tr>"	Express_list += "<tr><td height=20 width=95></td><td width=570>";
	for(i=0; i<codeList.length && i < 5; i++) {
		if (nameList[i] == '') {
		}
		else{			Express_list += "<a href=javascript:stockclass_visited_Del('"+codeList[i]+"')><img src=\"http://www.pstock.co.kr/2005pstock/common/ncomclub/images/conum_del.gif\" width=\"11\" height=\"11\" border=0 alt=\"»θΑ¦\"></a> <a href='http://www.pstock.co.kr/2005pstock/common/ncomclub/ncomclub_list.asp?nco_num="+codeList[i]+"'style=font-size:12;color=#000000;text-decoration:none><b>"+nameList[i].substring(0,8)+"</b></a>&nbsp;&nbsp;&nbsp;&nbsp;";
		}
	}
	Express_list += "</td><td width=17></td></tr>";	Express_list += "</table></td></tr></table>";

	stockclass_visited_list.innerHTML = Express_list;
}
