var str1="Recent_sexywearavenue";
var newid = new Array();
var newmargin = new Array();
var newname = new Array();
var newprice = new Array();
var newsaleprice = new Array();
var neworderable = new Array();
var newimgpath = new Array();
var price = '';
//var saleprice = '';


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,  price)
{
	var i,count;
	
	totalcookie = GetCookie("Total_sexywearavenue");

	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=GetCookie(str1 + m);
					newname[newname.length] = username;
					
					str=str1+m;
					str=str+"_id";
					username = GetCookie(str); 
					newid[newid.length] = username;

					
					str=str1+m;
					str=str+"_imgpath";
					username = GetCookie(str); 
					newimgpath[newimgpath.length] = username;

				}
				
				for(m=1, n=1;m<6;m++, n++)
				{
					
					createCookie(str1+m, newname[n]); 
	
					str=str1+m;
					str=str+"_id";
					createCookie(str,newid[n]); 
					
					str=str1+m;
					str=str+"_imgpath";
					createCookie(str,newimgpath[n]); 							
				
				}
				cookie_store(m, id, name, imgpath,  price);
			}
			else
			{
				i++;
				createCookie("Total_sexywearavenue",i);
				cookie_store(i, id, name, imgpath,  price);
			}
		}
	}
	else
	{
			i=1;
			createCookie("Total_sexywearavenue",i);
			cookie_store(i, id, name, imgpath,  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_swavenue_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 == 7)
			{
				for(m=1;m<=7;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;

				}
				
				for(m=1, n=1;m<7;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]); 
					
				}
				cookie_store(m, id, name, imgpath,  price);
			}
			else
			{
				i++;
				createCookieRV("Total_swavenue_RV",i);
				cookie_store(i, id, name, imgpath,  price);
			}
		}
	}
	else
	{
			i=1;
			createCookieRV("Total_swavenue_RV",i);
			cookie_store(i, id, name, imgpath,  price);
	}

}





function gc1()
{
	var i;
	totalcookie = GetCookieRV("Total_swavenue_RV");

	if(Number(totalcookie) > 1)
	{
		document.getElementById("recent_title").style.display = "";
		i = Number(totalcookie) - 1;
		newcount = 1;

		var ihtml = "<div class='ylp_display'>";
		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); 
			
						
			str=str1;
			str=str+j;
			str=str+'_id';
			lp =GetCookieRV(str); 
			
			if(j > 1)
			{
					ihtml += "<div class='ylp_box'>";
			}
			else
			{
					ihtml += "<div class='ylp_box' style='margin-right:0px;'>";
			}
											
			ihtml += "<div style='height:150px;'><a href='" + lp + ".html'><img src='" + imgpath + "' border='0' alt='" + name + "'></a></div>";
			ihtml +="<h2><a href='" + lp + ".html'>" + name + "</a></h2>$" + price + "</div>";		
		}
		ihtml += "</div>";

		document.getElementById("recentdiv").innerHTML = ihtml;
	}
	else
	{
/*	document.getElementById("recent_title").style.display = "";*/
/*	document.getElementById("recent_title").style.background = 'none';*/
	}
}


function cookie_store(val, id, name, imgpath, price)
{

	createCookieRV(str1+val,name);
	
	str=str1+val;
	str=str+"_price";
	createCookie(str,price);
	
	str=str1+val;
	str=str+"_id";
	createCookieRV(str,id);
	
	str=str1+val;
	str=str+"_imgpath";
	createCookieRV(str,imgpath);


}

function del_cookie(name) {
document.cookie = name +
'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}


function Bookmark(){
if (window.sidebar) // firefox
	window.sidebar.addPanel("www.sexywearavenue.com - " + document.title, window.location , "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',window.location);
	elem.setAttribute('title',document.title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(window.location, 'sexywearavenue.com - ' + document.title);
}


function nreset() {

document.newsletter.semail.value="";

}
function nvalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}


function nvalidate() {

if (document.newsletter.semail.value.length==0) {
alert("please enter your email address");
document.newsletter.semail.focus();
return false;
}
if(!nvalidateEmail(document.newsletter.semail.value)) {
    
alert("please enter your valid email address"); 
document.newsletter.semail.focus();
return false; 
}
else document.newsletter.submit()
return true;
}

function mvalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}


function mvalidate() {

if (document.membernewsletter.semail.value.length==0) {
alert("please enter your email address");
document.membernewsletter.semail.focus();
return false;
}
if(!mvalidateEmail(document.membernewsletter.semail.value)) {
    
alert("please enter your valid email address"); 
document.membernewsletter.semail.focus();
return false; 
}
if (document.membernewsletter.sname.value.length==0) {
alert("please enter your name");
document.membernewsletter.sname.focus();
return false;
}
else document.membernewsletter.submit()
return true;
}
