var str1="Recent_Sec_wiz";

function createCookie(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 GetCookie(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 checkCookie(id, name, imgpath)
{
	var i,count;
	totalcookie = GetCookie("Total_Sec_wiz");
	if(totalcookie != null)
	{
		i = Number(totalcookie);
		count=0;
		for(j=1;j<=i;j++)
		{
			username = GetCookie(str1 + j + "_id");
			if(username == id)
			{
				count++;
			}
		}
		
		if(count == 0)
		{
			if(i == 4)
			{
				for(m=1;m<4;m++)
				{
					n=m+1;
					
					username=GetCookie(str1+n);
					createCookie(str1+m,username); // product name
	
				/*	str=str1+n;
					str=str+"_price";
					username=GetCookie(str);
					str=str1+m;
					str=str+"_price";
					createCookie(str,username); // product price*/
				
					str=str1+n;
					str=str+"_id";
					username=GetCookie(str);
					str=str1+m;
					str=str+"_id";
					createCookie(str,username); // product id
					
					str=str1+n;
					str=str+"_imgpath";
					username=GetCookie(str);
					str=str1+m;
					str=str+"_imgpath";
					createCookie(str,username); // image path
				
				}
				cookie_store(m, id, name, imgpath);
			}
			else
			{
				i++;
				createCookie("Total_Sec_wiz",i);
				cookie_store(i, id, name, imgpath);
			}
		}
	}
	else
	{
			i=1;
			createCookie("Total_Sec_wiz",i);
			cookie_store(i, id, name, imgpath);
	}

}



function gc1()
{

	var i;
	var d = document;
	totalcookie = GetCookie("Total_Sec_wiz");
	
	if(Number(totalcookie) > 1)
	{
		i = Number(totalcookie) - 1;
		count=1;
		maindiv = d.getElementById("recentdiv");
		var ihtml = "";
		for(j=i; j>0; j--)
		{
			
			id = GetCookie(str1 + j + "_id");
			name = GetCookie(str1 + j);
			imgpath = GetCookie(str1 + j + "_imgpath");

/*			elem = d.createElement("div");
			elem.setAttribute("class","fp-product");*/

			if(count ==3)
			{
//				elem.setAttribute("style","background: none;");
				ihtml += "<div class='recentview-pro-details' style='background: none;'>";
			}
			else
			{
				ihtml += "<div class='recentview-pro-details'>";
			}
			count++;
			ihtml += "<h2><a href='" + id + ".html' class='fp-title'>" + name + "</a></h2>";
			ihtml += "<div class='recentview-pro-img'>";
			ihtml += "<a href='" + id + ".html'><img src='" + imgpath + "' border='0' alt='" + name + "' title='" + name + "'></a>";
			ihtml += "</div>";
		//	ihtml += "<span class='fp-dollar'>$ </span> <span class='fp-price'>" + price.toFixed(2) + "</span><a href='https://order.store.yahoo.net/cgi-bin/wg-order?yhst-33021441641232+" + id + "'><img src='http://209.85.100.184/ystore/Sec_wiz/images/buynow-btn.gif' alt='Buy Now' class='fp-buynow'></a>";										
			ihtml += "<a href='" + id + ".html' style='color: #f60; text-decoration: underline;'>view more</a>";										
			ihtml += "</div>";
			
	//		elem.innerHTML = ihtml;
//			maindiv.appendChild(elem);
		}
		document.getElementById("recentdiv").innerHTML = ihtml;
	}
}


function cookie_store(val, id, name, imgpath, price)
{
	createCookie(str1+val,name);
/*	str=str1+val;
	str=str+"_price";
	createCookie(str,price);*/
	str=str1+val;
	str=str+"_id";
	createCookie(str,id);
	str=str1+val;
	str=str+"_imgpath";
	createCookie(str,imgpath);
}