// JavaScript Document

function showAnswer(who,contentLetter) {
	var sign = document.getElementById("sign_" + contentLetter);	
	var content = document.getElementById("content_" + contentLetter);
	var bottomQ = document.getElementById('bottomQ');
	var rightC = document.getElementById("right_corner");
	var leftC = document.getElementById("left_corner");
	if (who.className.indexOf("active")>-1) {
		who.className = who.className.replace("active", "passive");
		sign.className = sign.className.replace("active", "passive");
		content.style.display = "none";
		if (who.className.indexOf("last")>-1) {
			bottomQ.style.backgroundColor = "#FFFFFF";
			rightC.style.backgroundPosition = "-12px -720px";
			leftC.style.backgroundPosition = "-12px -712px";
		}
	}
	else if (who.className.indexOf("passive")>-1) {
		who.className = who.className.replace("passive", "active");
		sign.className = sign.className.replace("passive", "active");
		content.style.display = "block";
		if (who.className.indexOf("last")>-1) {
			bottomQ.style.backgroundColor = "#EDEDED";
			rightC.style.backgroundPosition = "-12px -981px";
			leftC.style.backgroundPosition = "-12px -962px";
		}
	}
	setBottomCorners();
}

function showAll(who) {
	var ulContent = document.getElementById("ulContent");
	if (who.innerHTML == "פתח הכל") {
		for (var i=0; i<ulContent.childNodes.length; i++) {
			if (ulContent.childNodes[i].className && ulContent.childNodes[i].className.indexOf("answer")>-1) {
				ulContent.childNodes[i].style.display = "block";
				try {document.getElementById('bottomQ').style.backgroundColor = "#EDEDED";} catch(e) {}
			}
			else {
				if (ulContent.childNodes[i].className && ulContent.childNodes[i].className.indexOf("passive")) {
					ulContent.childNodes[i].className = ulContent.childNodes[i].className.replace("passive", "active");
					for (var j=0; j<ulContent.childNodes[i].childNodes.length; j++) {
						if (ulContent.childNodes[i].childNodes[j].id)
							ulContent.childNodes[i].childNodes[j].className = ulContent.childNodes[i].childNodes[j].className.replace("passive", "active");
					}
				}
			}
		}
		try {document.getElementById("right_corner").style.backgroundPosition = "-12px -981px";} catch(e) {}
		try {document.getElementById("left_corner").style.backgroundPosition = "-12px -962px";} catch(e) {}
	}
	else if (who.innerHTML == "סגור הכל") {
		for (var i=0; i<ulContent.childNodes.length; i++ ) {
			if (ulContent.childNodes[i].className && ulContent.childNodes[i].className.indexOf("answer")>-1) {
				ulContent.childNodes[i].style.display = "none";
				try {document.getElementById('bottomQ').style.backgroundColor = "#FFFFFF";} catch(e) {}
			}
			else {
				if (ulContent.childNodes[i].className && ulContent.childNodes[i].className.indexOf("active")) {
					ulContent.childNodes[i].className = ulContent.childNodes[i].className.replace("active", "passive");
					for (var j=0; j<ulContent.childNodes[i].childNodes.length; j++) {
						if (ulContent.childNodes[i].childNodes[j].id)
							ulContent.childNodes[i].childNodes[j].className = ulContent.childNodes[i].childNodes[j].className.replace("active", "passive");
					}
				}					
			}
		}
		try {document.getElementById("right_corner").style.backgroundPosition = "-12px -720px";} catch(e) {}
		try {document.getElementById("left_corner").style.backgroundPosition = "-12px -712px";} catch(e) {}
	}
	setBottomCorners();
}

function setBottomCorners() {
	try {
		var currentHeight = document.getElementById("yk_qna").offsetHeight;
		if (navigator.appName == "Microsoft Internet Explorer") {
			var ieVersion = (navigator.userAgent.split("MSIE")[1]).split(";")[0];
			if (ieVersion == 6.0) {
				if (document.getElementById("right_corner").style.backgroundPosition == "-12px -720px") {
					document.getElementById("right_corner").style.top = (currentHeight - 9) + "px";
					document.getElementById("left_corner").style.top = (currentHeight - 9) + "px";
				}
				else {
					document.getElementById("right_corner").style.top = (currentHeight - 8) + "px";
					document.getElementById("left_corner").style.top = (currentHeight - 8) + "px";
				}
			}
			if (ieVersion == 7.0) {
				document.getElementById("right_corner").style.top = (currentHeight - 9) + "px";
				document.getElementById("left_corner").style.top = (currentHeight - 9) + "px";
			}
		}
		else {
			document.getElementById("right_corner").style.top = (currentHeight - 6) + "px";
			document.getElementById("left_corner").style.top = (currentHeight - 6) + "px";
		}
	}
	catch(e) {}
}
