function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return ""
}

function delSubstr(geheleString,value)
{
   emptyStr = "";
   SplitString = geheleString.split(",")
   for (num = 0; num < SplitString.length; num++) {
      if(SplitString[num]!=value) {
      	  if(emptyStr == "") {
      	      emptyStr = SplitString[num];
      	  }
      	  else {
      	  emptyStr = emptyStr + "," + SplitString[num];
      	  }
      }
   }
   return emptyStr;
}

function setDelSubstr(c_name,geheleString,value,expiredays)
{

   var exdate=new Date();
   exdate.setDate(exdate.getDate()+expiredays);
   emptyStr = "";
   SplitString = geheleString.split(",")
   
   for (num = 0; num < SplitString.length; num++) {
      if(SplitString[num]!=value) {
      	  if(emptyStr == "") {
      	      emptyStr = SplitString[num];
      	  }
      	  else {
      	  emptyStr = emptyStr + "," + SplitString[num];
      	  }
      }
   }
    alert('Welcome again test '+emptyStr+'!');
   document.cookie=c_name+ "=" +escape('2211')+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());

}

function isMember(geheleString,value)
{
   emptyBool = false;
   SplitString = geheleString.split(",")
   for (num = 0; num < SplitString.length; num++) {
      if(SplitString[num]==value) {
      	 emptyBool = true;
      }
   }
   return emptyBool;
}


function setCookie(c_name,value,expiredays)
{
lastCookie=getCookie(c_name);
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
var myArray;


if (isMember(lastCookie,value)) {
    myArray = delSubstr(lastCookie,value)
    //alert('Welcome again test '+myArray+'!');
}

else if (lastCookie != "" && lastCookie !=null){
	//myArray = lastCookie;

	myArray = lastCookie + "," + value;
		//alert('Welcome again '+myArray+'!');
}
else{
	myArray = value;
}

document.cookie=c_name+ "=" +escape(myArray)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function checkCookie()
{
username=getCookie('check');
if (username!=null && username!="")
  {
  //alert('Welcome again '+username+'!');
  }
else
  {
  username=prompt('Please enter your name:',"");
  if (username!=null && username!="")
    {
    setCookie('check',username,1);
    }
  }
}

function disp_alert()
{
   cookie=getCookie('check');
   if (cookie!=null && cookie!=""){
   	 document.location.href="assortiment_vergelijk.asp";
   }
   else {
     alert('No product selected');
   }
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) 
{
   if ( Get_Cookie( name ) ) document.cookie = name + "=" +
   ( ( path ) ? ";path=" + path : "") +
   ( ( domain ) ? ";domain=" + domain : "" ) +
   ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function Del_C(c_name,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
var myArray;
myArray = ""

document.cookie=c_name+ "=" +escape(myArray)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}
