/**
 *  sets cookie with name and value
 *
 * @param	cookiename
 * @param	cookievalue
 * @return	void
 */
function dmcLayers_setCookie (cookieName, cookieValue){

	var date = new Date();
	date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
	
	if(cookieValue != "" && cookieValue != undefined){
		document.cookie = "dmcLayers_" + cookieName + "=" + cookieValue + ";expires=" + date.toGMTString();
	}
}


/**
 *  gets cookie
 *
 * @param	cookieName
 * @return	void
 */
function dmcLayers_getCookie (cookieName) {
	var arg = "dmcLayers_" + cookieName + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

/**
 *  gets random value with min and max counts
 *
 * @param	name
 * @return	void
 */
function dmcLayers_getRandom( min, max ) {
	if( min > max ) {
		return( -1 );
	}
	if( min == max ) {
		return( min );
	}
 
    return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}


/**
 *  closes layer
 *
 * @param	id
 * @return	void
 */
function dmcLayers_close(id){
	$('#'+id).fadeOut("slow");
}
