﻿function showDiv(d_id) {
	d_id.style.display = d_id.style.display == "none" ? "" : "none"
}

/////////////// RESPONSES ///////////////
function addCodeResponse(str) {
	document.addResponseForm.responseContent.value=document.addResponseForm.responseContent.value + str;
}

function checkResponse() {
	responseBy = document.addResponseForm.responseBy.value;
	responseSubject = document.addResponseForm.responseSubject.value;
	responseContent = document.addResponseForm.responseContent.value;

	if (responseBy == 0) {
		alert("אנא מלא את שמך");
		document.addResponseForm.responseBy.focus();
		return false;
	}
	if (responseSubject  == 0) {
		alert("אנא מלא את נושא התגובה");
		document.addResponseForm.responseSubject.focus();
		return false;
	}
	if (responseContent == 0) {
		alert("אנא מלא את תוכן התגובה");
		document.addResponseForm.responseContent.focus();
		return false;
	}
	document.addResponseForm.submit();
}
/////////////// RESPONSES ///////////////

function Exchange()
{
	if (document.form1.name.value=="") {
		alert (".אנא רשום את שמך");
		return false;
	}
	if (document.form1.yoursite.value=="") {
		alert (".אנא רשום את כתובת אתרך");
		return false;
	}
	var emailStr = document.form1.mail.value;
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert(".כתובת המייל איננה תקינה");
		return false;
	}
}

function Contact()
{
	if (document.form1.name.value=="") {
		alert (".אנא רשום את שמך");
		return false;
	}
	if (document.form1.subject.value=="") {
		alert (".אנא רשום את נושא ההודעה");
		return false;
	}
	if (document.form1.contents.value=="") {
		alert (".אנא רשום את תוכן ההודעה");
		return false;
	}
	var emailStr = document.form1.mail.value;
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert(".כתובת המייל איננה תקינה");
		return false;
	}
}

function Riddle()
{
	if (document.form1.name.value=="") {
		alert (".אנא רשום את שמך");
		return false;
	}
	if (document.form1.answer.value=="") {
		alert (".אנא רשום את תשובתך");
		return false;
	}
	var emailStr = document.form1.mail.value;
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert(".כתובת המייל איננה תקינה");
		return false;
	}
	form1.submit();
}

function ajaxObject(theFunction, string, theElementID)
{
	if (window.XMLHttpRequest)
		xmlHttp=new XMLHttpRequest()
	else if (window.ActiveXObject)
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
	if (xmlHttp==null)		//בדיקה האם הדפדפן תומך ב-AJAX
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	url="AjaxFunctions.asp?func="+theFunction+"&id="+string
	url=url+"&sid="+Math.random()	//כדי לטעון מחדש את המידע בכל פעם
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			document.getElementById(theElementID).innerHTML=xmlHttp.responseText
	}
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
}

function ajaxObjectCharacter(theFunction, theElementID, season, main, survivor)
{
	if (window.XMLHttpRequest)
		xmlHttp=new XMLHttpRequest()
	else if (window.ActiveXObject)
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
	if (xmlHttp==null)		//בדיקה האם הדפדפן תומך ב-AJAX
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	url="AjaxFunctions.asp?func="+theFunction+"&season="+season+"&main="+main+"&survivor="+survivor
	url=url+"&sid="+Math.random()	//כדי לטעון מחדש את המידע בכל פעם
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			document.getElementById(theElementID).innerHTML=xmlHttp.responseText
	}
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
}
