function showDiv(div_id){document.getElementById(div_id).style.visibility='visible';}
function hideDiv(div_id){document.getElementById(div_id).style.visibility='hidden';}
function selectTerminology(selected){document.getElementById("k").value=selected;}
function changeBGColor(id,bgcolor,textcolor){document.getElementById(id).style.backgroundColor=bgcolor;document.getElementById(id).style.color=textcolor;}
function getTerminologies(){var Terminology=document.getElementById("k").value;var url='/inc/get_terminologies.php?key='+Terminology;var httpRequest;if(Terminology.length>2){if(window.XMLHttpRequest){httpRequest=new XMLHttpRequest();if(httpRequest.overrideMimeType){httpRequest.overrideMimeType('text/xml');}}
else if(window.ActiveXObject){try{httpRequest=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{httpRequest=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){}}}
if(!httpRequest){alert('Giving up :( Cannot create an XMLHTTP instance');return false;}
httpRequest.onreadystatechange=function(){showterminologies(httpRequest);};httpRequest.open('GET',url,true);httpRequest.send(null);}}
function showterminologies(httpRequest){if(httpRequest.readyState==4){if(httpRequest.status==200){if(httpRequest.responseText==""){document.getElementById('terminologies_tip').innerHTML='<div class="tip">ابحث بالعربي أو بلإنجليزي</div>';}else{document.getElementById('terminologies_tip').innerHTML=httpRequest.responseText;}
showDiv('terminologies_tip');}}}
function hideOnClick(id1,id2){if(document.main_search.k.value=='ابحث هنا'){document.main_search.k.value='';}
if(document.addEventListener){document.addEventListener('click',function(){hideOnCall(id1,id2);},false);}else if(document.attachEvent){document.attachEvent('onclick',function(){hideOnCall(id1,id2);});}}
var clickedElements='';function hideOnCall(id1,id2){elements=document.getElementsByTagName('*');for(i=0;i<elements.length;i++)
{if(!elements[i].onclick){elements[i].onclick=function(){clickedElements+='_'+this.id;}}}
if(clickedElements.indexOf(id1)==-1){hideDiv(id2);}
clickedElements='';}
function checkForm()
{question=document.questionForm.question_question.value;if(question==""){alert("الرجاء إدخال السؤال");document.questionForm.question_question.focus();return false;}
for(var j=0;j<question.length;j++){if((question.charAt(j)=='<')||(question.charAt(j)=='>'))
{alert("يرجى عدم استخدام العلامات التالية: '>', '<'");document.questionForm.question_question.focus();return false;}}
if(question.length>4000)
{alert('السؤال الذي أدخلته تجاوز الحد المسموح به وهو ٨٠٠ كلمة');document.questionForm.question_question.focus();return false;}
document.questionForm.submit();}
function submitUserAnswer()
{answer=document.answerForm.answer_answer.value;if(answer==""){alert("الرجاء إدخال الإجابة");document.answerForm.answer_answer.focus();return false;}
for(var j=0;j<answer.length;j++){if((answer.charAt(j)=='<')||(answer.charAt(j)=='>'))
{alert("يرجى عدم استخدام العلامات التالية: '>', '<'");document.answerForm.answer_answer.focus();return false;}}
if(answer.length>4000)
{alert('الإجابة التي ادخلتها تجاوزت الحد المسموح به وهو ٨٠٠ كلمة');document.answerForm.answer_answer.focus();return false;}
document.answerForm.submit();}
function textCounter(field,maxlimit){if(field.value.length>maxlimit)
field.value=field.value.substring(0,maxlimit);}
function showMenu(category_id){var category_id=category_id;$(".menucat_1").addClass("menu_hidden");$(".menucat_2").addClass("menu_hidden");$(".menucat_3").addClass("menu_hidden");$(".menucat_4").addClass("menu_hidden");$(".menucat_5").addClass("menu_hidden");$(".menucat_6").addClass("menu_hidden");$(".menucat_"+category_id).removeClass("menu_hidden");}
function switchMenu(category_id){var category_id=category_id;if($(".menucat_"+category_id).hasClass("menu_hidden")==true){$(".menucat_"+category_id).removeClass("menu_hidden");$("#main_menu_"+category_id).removeClass("menu_main");$("#main_menu_"+category_id).addClass("menu_main_off");}else{$(".menucat_"+category_id).addClass("menu_hidden");$("#main_menu_"+category_id).removeClass("menu_main_off");$("#main_menu_"+category_id).addClass("menu_main");}}
function hideMenu(category_id){var category_id=category_id;$(".menucat_"+category_id).addClass("menu_hidden");$(".menucat_"+category_id).addClass("menu_hidden");}
$(document).ready(function(){$('#tabs').tabs();$('#dialog_link, ul#icons li').hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');});});$(document).ready(function(){$('#tabs2').tabs();$('#dialog_link, ul#icons li').hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');});});$(document).ready(function(){$('#tabs3').tabs();$('#dialog_link, ul#icons li').hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');});});var popupStatus=0;function loadPopup(){if(popupStatus==0){$("#backgroundPopup").css({"opacity":"0.9"});$("#backgroundPopup").fadeIn("slow");$("#popupContact").fadeIn("slow");popupStatus=1;}}
function disablePopup(){if(popupStatus==1){$("#backgroundPopup").fadeOut("slow");$("#popupContact").fadeOut("slow");popupStatus=0;}}
function centerPopup(){var windowWidth=document.documentElement.clientWidth;var windowHeight=document.documentElement.clientHeight;var popupHeight=$("#popupContact").height();var popupWidth=$("#popupContact").width();$("#popupContact").css({"position":"absolute","top":windowHeight/2-popupHeight/2,"left":windowWidth/2-popupWidth/2});$("#backgroundPopup").css({"height":windowHeight});}
$(document).ready(function(){$("#button").click(function(){centerPopup();loadPopup();});$("#popupContactClose").click(function(){disablePopup();});$("#backgroundPopup").click(function(){disablePopup();});$(document).keypress(function(e){if(e.keyCode==27&&popupStatus==1){disablePopup();}});});
