function cSetCookie(c_name,value,exSeconds)
{
    var exdate=new Date();
    exdate.setTime(exdate.getTime() + exSeconds*1000);
    var c_value=escape(value) + ((exSeconds==null) ? "" : "; expires="+exdate.toUTCString()) + "; domain=acasa.ro;";
    document.cookie=c_name + "=" + c_value;
}

function cGetCookie(c_name)
{
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");
        if (x==c_name)
        {
            return unescape(y);
        }
    }
}


function initCartoon() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    if (_timer) clearInterval(_timer);
    
    var clientClosed = cGetCookie("cartoonClosed");
    if (clientClosed != null && clientClosed != ""){
        return;
    }
    var domain = 'http://www.acasa.ro';

    // do stuff
    divCartoon = document.createElement('div');
    divCartoon.setAttribute('id', 'cartoon');
    divCartoon.style.position = 'fixed';
    divCartoon.style.top = '1px';
    divCartoon.style.left = '5px';
    divCartoon.style.zIndex = '9999';
//    aCartoon = document.createElement('a');
//    aCartoon.href = 'http://www.acasa.ro/sejur-dubai?utm_source=www.acasa.ro&utm_medium=emoticon&utm_campaign=Emoticon_acasa.ro_Dubai';
    
    var embed = document.createElement('embed');
    embed.setAttribute('width',220);
    embed.setAttribute('height',300);
    embed.setAttribute('allowScriptAccess', 'always');
    embed.setAttribute('quality', 'high');
    embed.setAttribute('pluginspage', 'http://www.macromedia.com/go/getflashplayer');
    embed.setAttribute('src', domain + '/swf/BFR-10_iconhpPrincess(4).swf');
//    embed.setAttribute('flashvars',"clickTAG=" + domain + "/sejur-paris?utm_source=www.acasa.ro&utm_medium=emoticon&utm_campaign=Emoticon_acasa.ro_EuropaTravel_PARIS");
    embed.setAttribute('wmode', 'transparent');
    embed.setAttribute('type',"application/x-shockwave-flash");

//     aCartoon.appendChild(embed);
//    
//    imgCartoon = document.createElement('img');
//    imgCartoon.src = 'http://www.acasa.ro/images/cartoon/dubai.png';

//    aCartoon.appendChild(imgCartoon);
    divCartoon.appendChild(embed);

    xCartoon = document.createElement('a');
    xCartoon.innerHTML='Inchide';
    xCartoon.setAttribute('style', "background: url(" + domain + "/images/close_icon.png) no-repeat 0 -68px;padding-left: 13px;cursor: pointer;color: #666; top:275px; left:131px;position: absolute;");
    xCartoon.onclick = function () {
        document.body.removeChild(document.getElementById('cartoon'));
        cSetCookie("cartoonClosed","1",1800);

    };
//    xCloseContainer = document.createElement('p');
//    divCartoon.appendChild(xCloseContainer);
    divCartoon.appendChild(xCartoon);
    
    document.body.appendChild(divCartoon);    

};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", initCartoon, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
    if (this.readyState == "complete") {
      initCartoon(); // call the onload handler
    }
  };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            initCartoon(); // call the onload handler
        }
    }, 10);
}

/* for other browsers */
window.onload = initCartoon;





