function validateEmail(emailAddress) {
   var match = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/.test(emailAddress);
   return match;
}



function CheckRegisterForm(RegisterForm)
    {
        if (RegisterForm.c_username.value == "" ) { alert( "Please choose a username!" );
        RegisterForm.c_username.focus();
        return false; }
        
        if (RegisterForm.c_password.value == "" ) { alert( "Please choose a password!" );
        RegisterForm.c_password.focus();
        return false; }
        
        if (RegisterForm.c_emailaddress.value == "" ) { alert( "Please enter your email address." );
        RegisterForm.c_emailaddress.focus();
        return false; }

        checkEmail = RegisterForm.c_emailaddress.value
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
	{alert("Your emails address is invalid!.");
	RegisterForm.c_emailaddress.focus();
	return false; }


   // return true;
}

function CheckUploadForm(UploadForm)
    {
        if (UploadForm.filetype.value == "No" ) { alert( "Please choose a filetype!" );
        UploadForm.filetype.focus();
        return false; }
        
        if (UploadForm.filedescr_short.value == "" ) { alert( "Please give a short file description!" );
        UploadForm.filedescr_short.focus();
        return false; }
        
        if (UploadForm.filedescr_long.value == "" ) { alert( "Please give a long file description." );
        UploadForm.filedescr_long.focus();
        return false; }

// return true;
}

function CheckTellForm(tellform)
    {
        if (tellform.name.value == "" ) { alert( "الرجاء أدخل الإسم بالكامل" );
        tellform.name.focus();
        return false; }

        if (tellform.email.value == "" ) { alert( "أدخل البريد الإلكتروني" );
        tellform.email.focus();
        return false; }

        checkEmail = tellform.email.value
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
	{alert("البريد  الإلكتروني  خطأ!.");
	tellform.email.focus();
	return false; }


        if (tellform.fname.value == "" ) { alert( "أدخل إسم صديقك" );
        tellform.fname.focus();
        return false; }



         if (tellform.femail.value == "" ) { alert( "أدخل البريد الالكتروني الخاص بصديقك" );
        tellform.femail.focus();
        return false; }

        checkEmail = tellform.femail.value
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
	{alert("البريد  الإلكتروني  خطأ!.");
	tellform.femail.focus();
	return false; }



   // return true;
}


var newwindow;
function pop(url)
{
        newwindow=window.open(url,'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=1, menubars=0, resizable=0, width=500, height=400');
        if (window.focus) {newwindow.focus()}
}

     function popimg(url)
    {
        newwindow=window.open(url,'name','height=500,width=650,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
	if (window.focus) {newwindow.focus()}
    }



<!-- ; 
var newwindow; 
var wheight = 0, wwidth = 0; 
function viewimg(url, title, iwidth, iheight, colour) { 
var pwidth, pheight; 

if ( !newwindow || newwindow.closed ) { 
pwidth=iwidth+30; 
pheight=iheight+30; 
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10'); 
wheight=iheight; 
wwidth=iwidth; 
} 

if (wheight!=iheight || wwidth!=iwidth ) { 
pwidth=iwidth+30; 
pheight=iheight+60; 
newwindow.resizeTo(pwidth, pheight); 
wheight=iheight; 
wwidth=iwidth; 
} 

newwindow.document.clear(); 
newwindow.focus(); 
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>'); 
newwindow.document.writeln('<a titl="إضغط الصورة للإغلاق" href="javascript:window.close();"><img src=' + url + ' border=0></a>'); 
newwindow.document.writeln('<\/center> <\/body> <\/html>'); 
newwindow.document.close(); 
newwindow.focus(); 
} 

// Routines to tidy up popup windows when page is left 
// Call with an onUnload="tidy5()" in body tag 

function tidy5() { 
if (newwindow && !newwindow.closed) { newwindow.close(); } 
} 


function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete?")) {
    document.location = delUrl;
  }
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//AJAX

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}