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 readCookie(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 eraseCookie(name) {
	createCookie(name,"",-1);
}


function animFade(obj,t){
	if( $(obj).css('display') == "none" )
		$(obj).fadeIn(t,function(){setTimeout('animFade("'+obj+'","'+t+'")',t)});
	else
		$(obj).fadeOut(t,function(){animFade(obj,t)});
}

function attachLoading( obj )
{
	if(obj)
	{
		poz = $(obj).offset();
		h2 = $(obj).height()/2+15;
		at = '<div align="center" id="attachedLoader" style="position:absolute; top:'+poz.top+'px; left:'+poz.left+'px; height:'+$(obj).height()+'px; width:'+$(obj).width()+'px; overflow:hidden; z-index:99999998"><div style="position:relative; top:0px; left:0px; height:'+$(obj).height()+'px; width:'+$(obj).width()+'px; background:#ffffff; filter:alpha(opacity=70); -moz-opacity:0.7; -khtml-opacity: 0.7; opacity: 0.7;"></div><div style="position:relative; top:-'+h2+'px; z-index:99999999"><img src="http://www.ghidulmireselor.ro/images/loading2.gif" /></div></div>';
	}
	else
	{
		h2 = $(window).height()/2+15;	
		w2 = $(window).width()/2+15;		
		at = '<div align="center" id="attachedLoader" style="position:fixed; top:0px; left:0px; height:'+$(window).height()+'px; width:'+$(window).width()+'px; overflow:hidden; z-index:99999998"><div style="position:fixed; top:0px; left:0px; height:'+$(window).height()+'px; width:'+$(window).width()+'px; background:#ffffff; filter:alpha(opacity=70); -moz-opacity:0.7; -khtml-opacity: 0.7; opacity: 0.7;"></div><div style="position:fixed; top:'+h2+'px; left:'+w2+'px; z-index:99999999"><img src="http://www.ghidulmireselor.ro/images/loading2.gif" /></div></div></div>';
	}
	$('body').append(at);
}
function destroyAttachLoading()
{
	$('#attachedLoader').remove();
}
