function formatNumber (num, decplaces) {
    num = parseFloat(num);
    if (!isNaN(num)) {
        var str = "" + Math.round (eval(num) * Math.pow(10,decplaces));
        if (str.indexOf("e") != -1) {
            return "Out of Range";
        }
        while (str.length <= decplaces) {
            str = "0" + str;
        }
        var decpoint = str.length - decplaces;
        return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
    } else {
        return "NaN";
    }
}

var _res = function(){
	// alert("!");
	$("main").style.marginBottom = "0";
	if($("c_col").getHeight() != $("main").getHeight()){
		$("main").style.marginBottom = "-1px";
	} else {
	}
}
window.onload = _res;
window.onresize = _res;


function toggleClouds(){
	//alert($("cloud_zone").visible());
	var coo = new Cookie(document, "cloud_off", 240, "/");
	coo.load();
	if(!$("cloud_zone").visible()){
		$("cloud_text").hide();
		$("ope").hide();
		$("clo").show();
		coo.s = "off";
		//Effect.SlideDown("cloud_zone");
	} else {
		Effect.toggle("cloud_text", "appear", {duration: 1.0});
		$("clo").hide();
		$("ope").show();
		coo.s = "on";
		//Effect.SlideUp("cloud_zone");
		//$("cloud_zone").hide();
	}
	coo.store();
	Effect.toggle("cloud_zone", "slide", {duration: 0.3, scaleContent: false});
	setTimeout(_res, 1050);
	return false;
}

function loadArt(id){
	return true;
	//alert(windowY());
	$("cont_spinner").show();
	new Ajax.Request('/ajx_art.'+id+'.html', {
		method: 'get',
		onSuccess: function(transport) {
			$('wh_cont').innerHTML = transport.responseText;
			$("cont_spinner").hide();
		},
		onFailure: function(transport) {
			$('wh_cont').innerHTML = transport.responseText;
			$("cont_spinner").hide();
		}
	});

	return false;
}

function windowY(){
	return window.pageYOffset
           || document.documentElement.scrollTop
           || document.body.scrollTop
           || 0;
}

function Cookie(document, name, hours, path, domain, secure){
    this.$document = document;
    this.$name = name;
    if (hours){
        this.$expiration = new Date((new Date()).getTime(  ) + hours*3600000);
    } else {
    	this.$expiration = null;
    }
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
}
Cookie.prototype.store = function (  ) {
    var cookieval = "";
    for(var prop in this) {
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }
    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString(  );
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';
    this.$document.cookie = cookie;
}
Cookie.prototype.load = function(  ) { 
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;
    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false;  
    start += this.$name.length + 1; 
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);
    var a = cookieval.split('&');  
    for(var i=0; i < a.length; i++)
        a[i] = a[i].split(':');
    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }
    return true;
}
Cookie.prototype.remove = function(  ) {
    var cookie;
    cookie = this.$name + '=';
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
    this.$document.cookie = cookie;
}

