var whitespace = " \t\n\r";

function isWhitespace (s)
	{
	  var i;
	   for (i = 0; i < s.length; i++)
	   {

	       var c = s.charAt(i);

	       if (whitespace.indexOf(c) == -1) return false;
	   }


	    return true;
	}

function isEmail(s)
	   {
		if (isWhitespace(s)) return false;
	   var i = 1;
	   var sLength = s.length;


	   while ((i < sLength) && (s.charAt(i) != "@"))
	   { i++
	   }
	   if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	   else i += 2;


	   while ((i < sLength) && (s.charAt(i) != "."))
	   { i++
	   }


	   if ((i >= sLength - 1) || (s.charAt(i) != "."))
		return false;

		else
		 return true;

}

function ValidateForm()
{

      if(document.form1.Name.value == "")
      {
	 alert("من فضلك ادخل اسمك");
	 document.form1.Name.focus();
	 return(false);
      }

if(! isEmail(document.form1.Email.value))
	{
	 alert("رجاء إدخال بريد إلكتروني صحيح");
	 document.form1.Email.focus();
	 return false;
	 }

      if(document.form1.Link.value == "")
      {
	 alert("من فضلك ادخل العنوان الذي ترغب في اضافته");
	 document.form1.Link.focus();
	 return(false);
      }
      return(true);
   }


function Google(URL,WindowName)
{

  document.form1.action =  URL
  document.form1.method = "get"
  document.form1.target = WindowName
}

function OpenFile(file,win)
{
    File=open(file,win,'height=400,width=600,location,menubar,titlebar,resizable,scrollbars,status,toolbar');
}

function showHideSubTree(tr)
{
    if(tr.cells(1).innerHTML == "")return;
    if(tr.style.display=='')
    {
        event.srcElement.src = event.srcElement.src.replace("minus","plus");
        tr.style.display='none';
    }
    else
    {
        event.srcElement.src = event.srcElement.src.replace("plus","minus");
        tr.style.display='';
    }
}

function sr(wd,st,tx){si="";for(var t=1;t<=wd.length;t++){if(wd.substring(t-1,t)==" ")si+="+";else{if(wd.substring(t-1,t)=="+")si+="%2B";else si+=wd.substring(t-1,t);}}st+=si;win(st,tx);}
function win(nm){dt=new Date();st="location=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes,scrollbars=yes,left=0,top=0,width=790,height=";if(parseInt(navigator.appVersion)>=4){t=window.open(nm,dt.getTime(),st+(screen.height-133));}else{t=window.open(nm,dt.getTime(),st+"height=600");}}

dc=document;
function s_web(){wd=dc.web.query.value;id=dc.web.service.selectedIndex;st=dc.web.service.options[id].value;tx=dc.web.service.options[id].text;sr(wd,st,tx);}
function s_mp3(){wd=dc.mp3.query.value;id=dc.mp3.service.selectedIndex;st=dc.mp3.service.options[id].value;tx=dc.mp3.service.options[id].text;sr(wd,st,tx);}
function s_ftp(){wd=dc.ftp.query.value;id=dc.ftp.service.selectedIndex;st=dc.ftp.service.options[id].value;tx=dc.ftp.service.options[id].text;sr(wd,st,tx);}

function select_game(form){var index=form.game_dropdown.selectedIndex;location=form.game_dropdown.options[index].value;}
function select_hw(form){var index=form.hw_dropdown.selectedIndex;location=form.hw_dropdown.options[index].value;}
function select_cd(form){var index=form.cd_dropdown.selectedIndex;location=form.cd_dropdown.options[index].value;}
function select_mp3(form){var index=form.mp3_dropdown.selectedIndex;location=form.mp3_dropdown.options[index].value;}
function select_misc(form){var index=form.misc_dropdown.selectedIndex;location=form.misc_dropdown.options[index].value;}


var whitespace = " \t\n\r";

function isWhitespace (s)
	{
	  var i;
	   for (i = 0; i < s.length; i++)
	   {

	       var c = s.charAt(i);

	       if (whitespace.indexOf(c) == -1) return false;
	   }


	    return true;
	}

function isEmail(s)
	   {
		if (isWhitespace(s)) return false;
	   var i = 1;
	   var sLength = s.length;


	   while ((i < sLength) && (s.charAt(i) != "@"))
	   { i++
	   }
	   if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	   else i += 2;


	   while ((i < sLength) && (s.charAt(i) != "."))
	   { i++
	   }


	   if ((i >= sLength - 1) || (s.charAt(i) != "."))
		return false;

		else
		 return true;

}

function ValidateForm()
{

      if(document.form2.Name.value == "")
      {
	 alert("من فضلك ادخل اسمك");
	 document.form2.Name.focus();
	 return(false);
      }

if(! isEmail(document.form2.Email.value))
	{
	 alert("رجاء إدخال بريد إلكتروني صحيح");
	 document.form2.Email.focus();
	 return false;
	 }

      if(document.form2.Link.value == "")
      {
	 alert("من فضلك ادخل العنوان الذي ترغب في اضافته");
	 document.form2.Link.focus();
	 return(false);
      }
      return(true);
   }

