onload = function()
{
ckUtil = new CJL_CookieUtil("portfolio", 500,"/");
lastValue = '';
total = 0;
if( ckUtil.cookieExists() )
{
var portfolioHtml = '';
total = ckUtil.getSubValue('total') ;
var cookieName = 'clip'+total;
lastValue =ckUtil.getSubValue(cookieName);
profolio = createPortfolio();
setMessage(profolio);
}
}
function createPortfolio(){
var portfolioHtml = '';
var portfolioHtml2 = '';
var portCount = 0;
var visitCount = 0;
for(x=1;x<=total;x++){
cookieName ='clip'+x;
var paramValue = ckUtil.getSubValue(cookieName);
params = paramValue.split(",");
if(params[0].match(new RegExp("port")) && portCount < 3 ){
portCount++;
portfolioHtml = ""+params[3] + "
"+params[5]+" €,"+params[4]+" Bedroom

" + portfolioHtml
}
if(params[0].match(new RegExp("visit")) && visitCount < 3 && (portCount-visitCount) <4 ){
visitCount++;
portfolioHtml2 += ""+params[3] + "
"+params[4]+" m2,"+params[5]+' Bedroom
'
}
}
if(total>=1){
portfolioHtml2 += '
[+] view all';
}
portfolioHtml += portfolioHtml2
return portfolioHtml;
}
function setNewClip(value)
{
if(lastValue != value){
if(ckUtil.getSubValue('total')>0) {
total = ckUtil.getSubValue('total') ;
total++;
ckUtil.setSubValue('total',total)
}else{
ckUtil.setSubValue('total',1)
total = 1;
}
newCookie = 'clip'+total;
lastValue = value;
ckUtil.setSubValue(newCookie,value)
if( ckUtil.cookieExists() )
{
profolio = createPortfolio();
setMessage(profolio);
}
}
}
function CJL_CookieUtil(name, duration, path, domain, secure)
{
this.affix = "";
if( duration )
{
var date = new Date();
var curTime = new Date().getTime();
date.setTime(curTime + (1000 * 60 * duration));
this.affix = "; expires=" + date.toGMTString();
}
if( path )
{
this.affix += "; path=" + path;
}
if( domain )
{
this.affix += "; domain=" + domain;
}
if( secure )
{
this.affix += "; secure=" + secure;
}
function getValue()
{
var m = document.cookie.match(new RegExp("(" + name + "=[^;]*)(;|$)"));
return m ? m[1] : null;
}
this.cookieExists = function()
{
return getValue() ? true : false;
}
this.expire = function()
{
var date = new Date();
date.setFullYear(date.getYear() - 1);
document.cookie=name + "=noop; expires=" + date.toGMTString();
}
this.setSubValue = function(key, value)
{
var ck = getValue();
if( /[;, ]/.test(value) )
{
//Mac IE doesn't support encodeURI
value = window.encodeURI ? encodeURI(value) : escape(value);
}
if( value )
{
var attrPair = "@" + key + value;
if( ck )
{
if( new RegExp("@" + key).test(ck) )
{
document.cookie =
ck.replace(new RegExp("@" + key + "[^@;]*"), attrPair) + this.affix;
}
else
{
document.cookie =
ck.replace(new RegExp("(" + name + "=[^;]*)(;|$)"), "$1" + attrPair) + this.affix;
}
}
else
{
document.cookie = name + "=" + attrPair + this.affix;
}
}
else
{
if( new RegExp("@" + key).test(ck) )
{
document.cookie = ck.replace(new RegExp("@" + key + "[^@;]*"), "") + this.affix;
}
}
}
this.getSubValue = function(key)
{
var ck = getValue();
if( ck )
{
var m = ck.match(new RegExp("@" + key + "([^@;]*)"));
if( m )
{
var value = m[1];
if( value )
{
//Mac IE doesn't support decodeURI
return window.decodeURI ? decodeURI(value) : unescape(value);
}
}
}
}
}