var alloccasion_timeout = 0;
var alloccasions_preImage = new Image();
alloccasions_preImage.src = "/images/alloccasions_on.gif";

function hideAllOccasionsDelay(){
	alloccasion_timeout = setTimeout("hideAllOccasions()",300);
}

function showAllOccasions(){
	clearTimeout(alloccasion_timeout);
	var li = document.getElementById("alloccasions_li");
	var a;
	if(document.all)	a = li.childNodes[0];
	else				a = li.childNodes[1];
	a.style.backgroundImage = "url(/images/sideMenu_bgon02.png)";

	document.getElementById("all_occasions").style.visibility = "visible";
}

function hideAllOccasions(){
	var li = document.getElementById("alloccasions_li");
	var a;
	if(document.all)	a = li.childNodes[0];
	else				a = li.childNodes[1];
	a.style.backgroundImage = "";

	document.getElementById("all_occasions").style.visibility = "hidden";
}

function newEle(type){
	return document.createElement(type);
}

function newText(text){
	return document.createTextNode(text);
}

function createAllOccasions(){
	var li = document.getElementById("alloccasions_li");
	var list = new Array();
	var px = (document.all)?"":"px";
	var url = window.location.href.toLowerCase();
	var ai_list = ["employee","service","retirement","pastor","achievement","sales","teach","safety","leader","star-plaque"];

	list.push({"name":"Achievement Awards","link":"http://www.diyawards.com/Achievement-Award-Ideas.html"});
	list.push({"name":"Community Service Awards","link":"http://www.diyawards.com/Community-Service-Award-Ideas.html"});
	list.push({"name":"Customer Service Awards","link":"http://www.diyawards.com/Customer-Service-Award-Ideas.html"});
	list.push({"name":"Employee Recognition","link":"http://www.diyawards.com/Award-Ideas-Employee-Awards.html"});
	list.push({"name":"Leadership Awards","link":"http://www.diyawards.com/Award-Ideas-Leadership-Awards.html"});
	list.push({"name":"Pastor Appreciation","link":"http://www.diyawards.com/Pastor-Appreciation-Gifts.html"});
	list.push({"name":"Retirement Plaques","link":"http://www.diyawards.com/Award-Ideas-Retirement-Awards.html"});
	list.push({"name":"Safety Awards","link":"http://www.diyawards.com/Award-Ideas-Safety-Awards.html"});
	list.push({"name":"Sales Recognition","link":"http://www.diyawards.com/Award-Ideas-Sales-Awards.html"});
	list.push({"name":"Teaching Excellence","link":"http://www.diyawards.com/Teaching-Excellence-Awards.html"});
	list.push({"name":"Valentine Day Gifts","link":"http://www.diyawards.com/Crystal-Valentine-Gifts.html"});
	list.push({"name":"Wedding Anniversary Gifts","link":"http://www.diyawards.com/Wedding-Anniversary-Gifts.html"});
	list.push({"name":"Years of Service Awards","link":"http://www.diyawards.com/Award-Ideas-Service-Awards.html"});

	if(document.all){
		li.attachEvent("onmouseover",showAllOccasions);
		li.attachEvent("onmouseout",hideAllOccasionsDelay);
	}
	else{
		li.setAttribute("onMouseOver","showAllOccasions()");
		li.setAttribute("onMouseOut","hideAllOccasionsDelay()");
	}

	div = newEle("div");
	div.id = "all_occasions";

	// Patch for Award Ideas Pages.
	var found = false;
	for(var i=0;i<ai_list.length;i++){
		var reg = new RegExp(ai_list[i]);
		if( reg.test(url) )	found = true;
	}
	if( found ){
		div.style.left = "141" + px;
	}
	li.appendChild(div);
	// Patch End

	// Patch for IE6
	var browser = navigator.appName;
	var version = navigator.appVersion;
	if(/Internet Explorer/.test(browser) && /MSIE 6/.test(version)){
		p_ul = li.parentNode;
		p_ul.style.height = "174" + px;
		p_ul.style.overflow = "hidden";
	}
	// Patch End

	// Title
	title_div = newEle("div");
	title_div.id = "alloccasions_title";
	title_div.appendChild(newText("Awards by Occasion"));
	div.appendChild(title_div);
	// Title End


	// Link List
	content_div = newEle("div");
	content_div.id = "alloccasions_content";
	div.appendChild(content_div);

	ul = newEle("ul");
	content_div.appendChild(ul);

	for(var i=0;i<list.length;i++){
		var li_2 = newEle("li");
		var a_2 = newEle("a");

		//li_2.style.lineHeight = "25px";
		ul.appendChild(li_2);
		li_2.appendChild(a_2);
		a_2.appendChild( newText(list[i]["name"]) );
		a_2.href = list[i]["link"];
	}
	// Link List End

}

var allstyle_timeout = 0;
function hideAllStyleDelay(){
	allstyle_timeout = setTimeout("hideAllStyle()",300);
}

function showAllStyle(){
	clearTimeout(allstyle_timeout);
	var li = document.getElementById("allstyle_li");
	var a;
	if(document.all)	a = li.childNodes[0];
	else				a = li.childNodes[1];
	a.style.backgroundImage = "url(/images/sideMenu_bgon02.png)";

	document.getElementById("all_style").style.visibility = "visible";
}

function hideAllStyle(){
	clearTimeout(allstyle_timeout);
	var li = document.getElementById("allstyle_li");
	var a;
	if(document.all)	a = li.childNodes[0];
	else				a = li.childNodes[1];
	a.style.backgroundImage = "url(/images/sideMenu_bgon02.png)";

	document.getElementById("all_style").style.visibility = "visible";
}

function hideAllStyle(){
	var li = document.getElementById("allstyle_li");
	var a;
	if(document.all)	a = li.childNodes[0];
	else				a = li.childNodes[1];
	a.style.backgroundImage = "";

	document.getElementById("all_style").style.visibility = "hidden";
}

function showList(type, aEle) {
	if (type == "AI") {
		if ($("#aAI").hasClass("open"))
			toggleList("CA");
		else
			toggleList("AI");
	}
	else if (type == "CA") {
		if ($("#aCA").hasClass("close"))
			toggleList("CA");
		else
			toggleList("AI");
	}
}

function toggleList(type) {
	if (type == "AI") {
		$("#ulByProfession").show("blind");
		$("#ulByCA").hide("blind");
		$("#aAI").removeClass("close");
		$("#aAI").addClass("open");
		$("#aCA").removeClass("open");
		$("#aCA").addClass("close");
	}
	else if (type == "CA") {
		$("#ulByProfession").hide("blind");
		$("#ulByCA").show("blind");
		$("#aCA").removeClass("close");
		$("#aCA").addClass("open");
		$("#aAI").removeClass("open");
		$("#aAI").addClass("close");
	}
}
