
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);
}

menu_status = new Array();

function showHide(theid) {
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);
	
        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else {
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
	var x = readCookie('menu_ck');
	if (!x && menu_status[theid] == 'hide') {
		createCookie("menu_ck", "0", 0);
	}
	else if (!x && menu_status[theid] == 'show') {
		createCookie("menu_ck", "1", 0);
	}
	else if (theid == 'service_links' && menu_status[theid] == 'hide') {
		createCookie("menu_ck", "0", 0)
	}
	else if (theid == 'service_links' && menu_status[theid] == 'show') {
		createCookie("menu_ck", "1", 0)
	}
	
}

function menu_set() {
	var links = readCookie("menu_ck");
	if (links == 1) {
		showHide('service_links');
	}	
}
