// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// =-=-=-=-=-=- [ MAIN ] =-=-=-=-=-=-=-=
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

var redirect = function (url) {
	window.location = url; 
}
var trim = function (value) {
	value = value.replace(/^\s+/,'');
	value = value.replace(/\s+$/,'');
	return value;
}

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// =-=-=-=-=-= [ COOKIE ] =-=-=-=-=-=-=-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

var cookie_set = function (name, value) {
		var days = 1;
		var date = new Date();
			date.setTime( date.getTime() + ( days * 24 * 60 * 60 * 1000 ) );
		var expires = "; expires="+date.toGMTString();

	document.cookie = name+"="+value+";expires="+expires+";path=/";
};

var cookie_read = function (name) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if (! start && name != document.cookie.substring(0, name.length)) {
		return null;
	}
	
	if (start == -1) {
		return null;
	}
	var end = document.cookie.indexOf(";", len);
	
	if (end == -1) {
		end = document.cookie.length;
	}
	return document.cookie.substring(len, end);
};

var cookie = {
	set : function (name, value) {
		return cookie_set(name, value);
	},
	read : function (name) {
		return cookie_read(name);
	}
};

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// =-=-=-=-=-=- [ TABS ] =-=-=-=-=-=-=-=
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

var tab = {
	current : false,
	click : function(id) {
		if (this.current == id) {
			this.current = null;
			return this.close(id);
		}
		if (this.current) {
			this.close(this.current);
			this.current = false;
		}		
		if (id) {
			this.open(id);
			this.current = id;
		}
	},	
	open : function(id) {
		$(id).show();
	},
	close : function(id) {
		$(id).hide();
	}
};



// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// =-=-=-=-=-=- [ NAV MENU ] =-=-=-=-=-=
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

var nav = {
	
	classname : 'active_state',
	
	go : function (page) {		
		redirect(root_url + page + '/');
	},
	
	change_class : function (node) {
		this.change_img(node);
		$(node).addClassName(this.classname);
	},
		
	change_img : function (node) {	
		if ( $(node) == null || $(node) == '' ) {
		} else {
			var prev_image = Element.descendants(node);
				prev_image.each(function(n) { 
					if (Element.hasClassName(n, 'fixpng')) {
						var	next_image = n.src.replace('off', 'on');
						n.src = next_image;
					}
				});
		}
	},
	
	set : function (node) {
		if ( $(node) == null || $(node) == '' ) {
		} else {
			this.change_class(node);
		}
	}
	
}

Event.observe(window, 'load', function(event) { 	
	nav.set(current_label);
});

function checkDomain (domain) {
	redirect(root_url + 'domaincheck/name='+domain+'/');
}






