// JavaScript Document
var $j = jQuery.noConflict();

include_css('/banners/main.css');
    
$j(document).ready(function(){
			show_banner();
});

function show_banner(){
	  if(!jQuery.cookie('bannerCH')){
		  $j('body').append('<div id="ch_overlay"></div>');
		  $j('body').append('<div id="ch_banner"><a href="http://www.colonhelp.ro" target="_blank"><img src="http://colonhelp.ro/wp-content/themes/colonhelp/banners/images/banner.png" width="624" height="529" border="0" /></a></div>');
		  $j('body').append('<div id="ch_banner_close">Veti fi automat redirectionat in 5 secunde...<br /><a href="javascript://" onclick="hide_banner()">Mergi la pagina solicitata</a></div>');
		  
		  $j('html').css('overflow', 'hidden');
		  $j('#ch_overlay').show();
		  $j('#ch_banner').show();
		  $j('#ch_banner_close').show();
		  
		  //set cookie
		  jQuery.cookie('bannerCH', '1', { expires: 1 });
		  
		  //close after 5 sec
		  setTimeout("hide_banner()", 8000);
	  }
}

function hide_banner(){
	$j('html').css('overflow', 'auto');
	$j('#ch_overlay').hide();
	$j('#ch_banner').hide();
	$j('#ch_banner_close').hide();
}


function include_css(file){
	$j('head').append('<link rel="stylesheet" href="http://colonhelp.ro/wp-content/themes/colonhelp'+ file +'" type="text/css" media="screen" />');
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};