﻿//******************************** GENERAL SEARCH ******************************//
function ShowHideLatestNews() 
{
var OldStyle = tblLatestNews.style.display;

if (OldStyle == "") 
{
tblLatestNews.style.display = "none";
document.getElementById('imgLatestNews').src = "/Channel/images/icons/fromnews-expand.gif";
}
else
{
tblLatestNews.style.display = "";
document.getElementById('imgLatestNews').src = "/Channel/images/icons/fromnews-collapse.gif";
}
return false;
}
//Muayad Salameh -- 17-4-2007
function CheckServicesTR()
{
if ((document.all.voteTbl) || (document.all.DGTbl))
{
document.all.servicesImgTR.style.display = "";
}
else
{
document.all.servicesImgTR.style.display = "none";
}
}
function ShowHideParticipation() 
{
var OldStyle = document.getElementById('servicesTbl').style.display;

if (OldStyle == "") 
{
document.getElementById('servicesTbl').style.display = "none";
document.getElementById('imgParticipation').src = "/news/Images/News/participations-header-expand.gif";
}
else
{
document.getElementById('servicesTbl').style.display = "";
document.getElementById('imgParticipation').src = "/news/Images/News/participations-header-collapse.gif";
}
return false;
}
function SwitchMenuSiteIndex(strImageID)
{
if(document.getElementById)
{
var oImage = document.getElementById(strImageID);
var oTable = document.getElementById(strImageID+"_Table");
if(oTable.style.display != "block")
{
oImage.src = "/GateWay/Images/SiteMap/min-index.gif";
oTable.style.display = "block";
}
else
{
oImage.src = "/GateWay/Images/SiteMap/plus-index.gif";
oTable.style.display = "none";
}
}
}
function RegExpTest(strInput)
{
var regExpPattern = /\S{10}/g;    //Create regular expression pattern to check for long words
var matchesArray;
var strReturn = "";
var firstIndex = 0;

//var ver = Number(ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion())
while ((matchesArray = regExpPattern.exec(strInput)) != null)
{
//alert(arr.index + "-" + arr.lastIndex + "-\s-" + arr + "<br>");
strReturn += strInput.substring(firstIndex,matchesArray.lastIndex) + "&#32;";
firstIndex = matchesArray.lastIndex;
}
strReturn += strInput.substring(firstIndex,strInput.length);
regExpPattern = /</g;  //Create regular expression pattern to check for <
strReturn = strReturn.replace(regExpPattern, "&lt;");    //Replace < character with "&lt;".

regExpPattern = />/g;  //Create regular expression pattern to check for <
strReturn = strReturn.replace(regExpPattern, "&gt;");    //Replace > character with "&gt;"

regExpPattern = /\r\n/g;  //Create regular expression pattern to check for a new line character
strReturn = strReturn.replace(regExpPattern, "<br>");    //Replace new line character with "<br>".
return strReturn ;
}
function RegExpEmailTest(strInput)
{
var regExpPattern = /(\w+|\W+)([-+.](\w+|\W+))*@(\w+|\W+)([-.](\w+|\W+))*\.(\w+|\W+)([-.](\w+|\W+))*/;    //Create regular expression pattern to check email expression
if (regExpPattern.test(strInput))
return true;
else
return false;

}
function CheckJS(strInput)
{
var found= true;
while (found) 
{
strInput = strInput.replace("<","&lt;");
strInput = strInput.replace(">","&gt;");
if ((strInput.search("<") > -1) || (str.search(">") > -1))
found=true;
else
found=false;
}
return strInput; 
}
function openLogin(url,urlParam)
{
var Link	
Link = url + escape(urlParam) ;	
//alert(Link)
window.open(Link ,"","height=450,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}
//******************************** العضوية ************************************//
function FormValidation(txtUserName,txtEmail,txtPW,txtConPW,txtEmail)
{
if( window.document.all.item(txtUserName).value == "" )
{
alert("الرجاء إدخال إسم المستخدم");
window.document.all.item(txtUserName).focus(); 
return false;
}
if( window.document.all.item(txtEmail).value == "" )
{
alert("الرجاء إدخال بريدك الإلكتروني");
window.document.all.item(txtEmail).focus(); 
return false;
}
if( window.document.all.item(txtPW).value == "" )
{
alert("الرجاء إدخال كلمة المرور");
window.document.all.item(txtPW).focus(); 
return false;
}
if( window.document.all.item(txtConPW).value == "" )
{
alert("الرجاء إدخال تأكيد كلمة المرور");
window.document.all.item(txtConPW).focus(); 
return false;
}
if( window.document.all.item(txtConPW).value != window.document.all.item(txtPW).value )
{
alert("الرجاء إدخال التأكد من كلمة المرور وتأكيدها");
window.document.all.item(txtPW).focus(); 
return false;
}
if( !(RegExpEmailTest(window.document.all.item(txtEmail).value)) )
{
alert("الرجاء إدخال البريد الإلكتروني بالشكل الصحيح");
return false;
}

return true;
}
function CheckEmail(checkValue)
{
var allValid = true;
if (checkValue.indexOf("@")<=0 || checkValue.indexOf("@") == checkValue.length-1 || checkValue.indexOf(".") == checkValue.length-1)
allValid = false;
return allValid; 
}
function drawNewsletterWind(virtualPath)
{
var strURL = virtualPath + "/SupportPages/Registeration/unSubscribe.aspx?type=3";
var strProperties = 'width=590,height=450,scrollbars=yes';
window.open(strURL, '', strProperties, false);
}
//******************************** End العضوية *******************************//
//******************************** FeedBack ****************************//
function checkBodyTextSize(TxtLetterBody)
{
var textSize = 1000;
if( window.document.all.item(TxtLetterBody).innerText.length > textSize )
{
alert("المساحة المتاحة في حدود 200 كلمة فقط");
var str = window.document.all.item(TxtLetterBody).innerText;
window.document.all.item(TxtLetterBody).innerText = str.substr(0,textSize);
return false;
}
return true;
}
function checkFBValidations(TxtFirstName,TxtEmail,TxtLetterBody)
{
if(window.document.getElementById(TxtFirstName).value == "")
{
alert("الرجاء إدخال إسم المستخدم");
return false;
}
if( window.document.getElementById(TxtEmail).value != "" )
{
if( !(RegExpEmailTest(window.document.getElementById(TxtEmail).value)) )
{
alert("الرجاء إدخال البريد الإلكتروني بالشكل الصحيح");
return false;
}
}
if( window.document.getElementById(TxtLetterBody).value == "")
{
alert("الرجاء إدخال نص الرسالة");
return false;
}
return true;
}

//******************************** End FeedBack ****************************//

//******************************** Site Map ****************************//
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function getCurrentYear()
{
var myDate = new Date();
return myDate.getYear();
}
function SwitchMenu(obj, strImageID)
{
if(document.getElementById)
{
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(el.style.display != "block")
{ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";

var oImage = document.getElementById (strImageID)
oImage.src = "/Portal/Images/SiteMap/mins.gif"
}
else
{
var oImage = document.getElementById (strImageID)
oImage.src = "/Portal/Images/SiteMap/plus.gif"
el.style.display = "none";
}
}
}
//******************************** End Site Map ****************************//
function openServices(strType, EncodedURL) 
{ 
switch (strType) 
{ 

// Print Article
case 'print' : 
var intWinW = 680; 
var intWinH = 420; 
var strURL = '/Portal/aspx/print.htm'; 
var strProperties = 'menubar=yes, resizable=yes,  '; 
break; 

// Send Article
case 'sendArticle' : 
var intWinW = 500; 
var intWinH = 375; 
var strProperties = 'resizable=no, ';  
var strURL = "/Portal/aspx/sendArticle.aspx?EML=" + EncodedURL ;
break; 
} 
if (strURL != null) 
{ 
var intScreenW = parseInt(screen.width, 10); 
var intScreenH = parseInt(screen.Height, 10); 
var intWinT = (intScreenH - intWinH)/2; 
var intWinL = (intScreenW - intWinW)/2; 
strProperties += 'height=' + intWinH + ', width=' + intWinW + ', top=' + intWinT + ', left=' + intWinL + ', scrollbars=yes,toolbar=yes'; 
var winObject = window.open(strURL, 'PageServices', strProperties, false); 
winObject.focus(); 
} 
} 