var Cookie = {
  data: {},
  options: {expires: 1, domain: "", path: "", secure: false},

init: function(options, data) {
  Cookie.options = Object.extend(Cookie.options, options || {});

  var payload = Cookie.retrieve();
        if(payload) {
            Cookie.data = payload.evalJSON();
        }
        else {
            Cookie.data = data || {};
        }
        Cookie.store();
    },
    getData: function(key) {
        return Cookie.data[key];
    },
    setData: function(key, value) {
        Cookie.data[key] = value;
        Cookie.store();
    },
    removeData: function(key) {
        delete Cookie.data[key];
        Cookie.store();
    },
    retrieve: function() {
        var start = document.cookie.indexOf(Cookie.options.name + "=");

        if(start == -1) {
            return null;
        }
        if(Cookie.options.name != document.cookie.substr(start, Cookie.options.name.length)) {
            return null;
        }

        var len = start + Cookie.options.name.length + 1;   
        var end = document.cookie.indexOf(';', len);

        if(end == -1) {
            end = document.cookie.length;
        } 
        return unescape(document.cookie.substring(len, end));
    },
    store: function() {
        var expires = '';

        if (Cookie.options.expires) {
            var today = new Date();
            expires = Cookie.options.expires * 86400000;
            expires = ';expires=' + new Date(today.getTime() + expires);
        }

        document.cookie = Cookie.options.name + '=' + escape(Object.toJSON(Cookie.data)) + Cookie.getOptions() + expires;
    },
    erase: function() {
        document.cookie = Cookie.options.name + '=' + Cookie.getOptions() + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    },
    getOptions: function() {
        return (Cookie.options.path ? ';path=' + Cookie.options.path : '') + (Cookie.options.domain ? ';domain=' + Cookie.options.domain : '') + (Cookie.options.secure ? ';secure' : '');      
    }
};


var jsonObject = [];
function GetJSON(jsonId) {
	if (typeof eval('jsonObject["'+jsonId+'"]') != "object")
		return null;
	else {
		var retObj = eval('jsonObject["'+jsonId+'"]');
		return retObj;
	}
}
dropDownMenu = Class.create();
dropDownMenu.prototype = {
	initialize: function(parent, menu) {
		var item = this;
		this.element = $(parent);
		
		this.menu = $(menu);
		//this.menu.style.position = 'absolute';
		this.menu.style.zIndex = 9999;		
		
		this.timeout = 0.2;
		this.fadeTime = 0.2;

		this.element.onmouseover = function() {
			item.open();
		}
		this.menu.onmouseover = function() {
			item.open();
		}
		this.element.onmouseout = function() {
			item.close();
		}
		this.menu.onmouseout = function() {
			item.close();
		}
	},
	open:function() {
		this.lock = 1;
		//this.menu.appear({duration:this.fadeTime});
		this.open2.delay(0.02, this);
	},
	open2:function(item) {
		if (item.lock == 1) {
			item.menu.appear({duration:item.fadeTime});
		}
	},
	close: function() {
		this.lock = 0;
		this.close2.delay(this.timeout, this);
	},
	close2: function(item) {
		if (item.lock==0){
			item.menu.fade({duration:item.fadeTime});
		}
	}
}

function closeInsert(id) {
	document.getElementById(id).style.display = "none";
	document.getElementById('homeFeature').style.display = "block";
	Cookie.setData('hideInsert', true);
}

function beginInsert(id) {
	Cookie.init({name: 'insert'});
	if (!Cookie.getData('hideInsert')) {
		document.getElementById(id).style.display = "block";
		document.getElementById('homeFeature').style.display = "none";
	}	
}


function starttext(){
	document.getElementById("starttext").style.display = "";	
	Effect.Appear("blender", {duration: 1});
}

function cr_nextlayer(neu){
	var i=1;
	while (document.getElementById('content'+i)){
		document.getElementById('content'+i).style.display = "none";
		i++;
	}
//	document.getElementById(neu).style.display = "";
	var neu = 'content'+neu;
	Effect.Appear(neu, {duration: 1});
}

function show_infotabel(neu){
	var i=0;
	while (document.getElementById('infotable'+i)){
		document.getElementById('infotable'+i).style.display = "none";
		i++;
	}
	Effect.Appear('infotable'+neu, {duration: 1});
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function form_switch(id) {
	document.getElementById('form1_layer').style.display = "none";
	document.getElementById('form2_layer').style.display = "none";
	document.getElementById('form'+id+'_layer').style.display = "";
}

