/*Script for Recently view*/
var str1="Recent_HINKY";
var newid = new Array();
var newname = new Array();
var newprice = new Array();
var newsaleprice = new Array();
var newimgpath = new Array();
var price = '';

function createCookieRV(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function GetCookieRV(name) 
{  
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function checkCookieRV(id, name, imgpath, price)
{
	var i,count;
	totalcookie = GetCookieRV("Total_HINKY_RV");

	if(totalcookie != null)
	{
		i = Number(totalcookie);
		count=0;
		for(j=1;j<=i;j++)
		{
			username = GetCookieRV(str1 + j + "_id");
			if(username == id)
			{
				count++;
			}
		}
		if(count == 0)
		{
			if(i == 6)
			{
				for(m=1;m<=6;m++)
				{
					username=GetCookieRV(str1 + m);
					newname[newname.length] = username;
	
					str=str1+m;
					str=str+"_id";
					username = GetCookieRV(str); 
					newid[newid.length] = username;

					
					str=str1+m;
					str=str+"_imgpath";
					username = GetCookieRV(str); 
					newimgpath[newimgpath.length] = username;
					
					/*str=str1+m;
					str=str+"_price";
					username = GetCookieRV(str); 
					newprice[newprice.length] = username;*/

				}
				
				for(m=1, n=1;m<6;m++, n++)
				{
					
					createCookieRV(str1+m, newname[n]); 
	
					str=str1+m;
					str=str+"_id";
					createCookieRV(str,newid[n]); 
					
					str=str1+m;
					str=str+"_imgpath";
					createCookieRV(str,newimgpath[n]);
					
					/*str=str1+m;
					str=str+"_price";
					createCookieRV(str,newprice[n]);*/
					
				}
				//cookie_store(m, id, name, imgpath, price);
				cookie_store(m, id, name, imgpath);
			}
			else
			{
				i++;
				createCookieRV("Total_HINKY_RV",i);
				//cookie_store(i, id, name, imgpath, price);
				cookie_store(i, id, name, imgpath);
			}
		}
	}
	else
	{
			i=1;
			createCookieRV("Total_HINKY_RV",i);
			//cookie_store(i, id, name, imgpath, price);
			cookie_store(i, id, name, imgpath);
	}
}

function gc1()
{
	var i;
	totalcookie = GetCookieRV("Total_HINKY_RV");

	if(Number(totalcookie) > 1)
	{
		if(document.getElementById("recent_title"))
		{
			document.getElementById("recent_title").style.display = "";
		}
		i = Number(totalcookie) - 1;
		newcount = 1;

		var ihtml = "<table cellpadding='0' cellspacing='0' border='0'><tr>";
		for(j = i; j > 0; j--)
		{
			id = GetCookieRV(str1 + j + "_id");
			name = GetCookieRV(str1 + j);
			imgpath = GetCookieRV(str1 + j + "_imgpath");
			//price = GetCookieRV(str1 + j + "_price");
			str=str1;
			str=str+j;
			str=str+'_id';
			lp =GetCookieRV(str);
			
			//var fprice = parseFloat(price);
			
			if(j==1)
			{
				ihtml += "<td width='19%' align='center' valign='top'>";
			}
			else
			{
				ihtml += "<td width='19%'  align='center' valign='top'>";
			}
			ihtml += "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>    <tr>  <td height='150' align='center' valign='middle' class='img'>";
			ihtml += "<a href='" + lp + ".html'><img src='" + imgpath + "' border='0' alt='" + name + "'></a></td>    </tr> <tr><td align='center' valign='middle'><h3>";
			ihtml +="<a href='" + lp + ".html'>" + name + "</a></h3>";
			//ihtml += "<font face='Arial.'>$" + fprice.toFixed(2) + "</font>";
			ihtml += "</td></tr></table></td>";
			ihtml += "<td width='8' align='center' valign='middle'>&nbsp;</td>";
		}
		for(j = i; j < 5; j++)
		{
				ihtml += "<td width='19%' align='center' valign='top'>&nbsp;</td><td width='8' align='center' valign='middle'>&nbsp;</td>";
		}
		ihtml += "</tr></table>";

		document.getElementById("recentrow").innerHTML = ihtml;
	}
	else
	{

	}
}


function cookie_store(val, id, name, imgpath)
{

	createCookieRV(str1+val,name);
	
	str=str1+val;
	str=str+"_id";
	createCookieRV(str,id);
	
	str=str1+val;
	str=str+"_imgpath";
	createCookieRV(str,imgpath);

	/*str=str1+val;
	str=str+"_price";
	createCookieRV(str,price);*/
}

function del_cookie(name) {
document.cookie = name +

'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
