﻿

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}


function validateFeedBack(){
if(document.getElementById('name').value==""){
alert("Please Fill Your Name !");
document.getElementById('name').focus();
return false;
}
else if(document.getElementById('email').value==""){
alert("Please Fill Your Email !");
document.getElementById('email').focus();
return false;
}
else if(document.getElementById('subject').value==""){
alert("Please Fill Your Subject Field!");
document.getElementById('subject').focus();
return false;
}
else if(document.getElementById('comments').value==""){
alert("Please Enter Your Comments !");
document.getElementById('comments').focus();
return false;
}


else{
/*var selval=document.getElementById('thebrands').value;
alert(selval);*/
return checkemail();


//alert("Thank You For Your Suggession !");
//return true;
}
 
}

function goback(){
window.location.href='index.php?menu=about&page=vacancies';	
}
function applyForJob(jobid){
window.location.href='index.php?menu=about&page=jobapply&jobid='+ jobid ;	
}

function validateApply(){

if(document.getElementById('txt_from').value==""){
alert("Please Fill Your Email !");
document.getElementById('txt_from').focus();
return false;
}
else if(document.getElementById('txt_name').value==""){
alert("Please Fill Your Name !");
document.getElementById('txt_name').focus();
return false;
}
else if(document.getElementById('txt_age').value==""){
alert("Please Fill Your Age !");
document.getElementById('txt_age').focus();
return false;
}
else if(document.getElementById('txt_nationality').value==""){
alert("Please Enter Your Nationality !");
document.getElementById('txt_nationality').focus();
return false;
}
else if(document.getElementById('file_cv').value==""){
alert("Please Browse for Your CV !");
document.getElementById('file_cv').focus();
return false;
}
else {
//alert("Your Request has been Sent !");
//window.location.href='index.php?menu=about&page=vacancies';	
return true;
}

}
function mailingListValidate(){

/*if(document.getElementById('txt_name').value==""){
alert("Please Fill Your Name!");
document.getElementById('txt_name').focus();
return false;
}
else */
if(document.getElementById('txt_email').value==""){
alert("Please Fill Your Emails !");
document.getElementById('txt_email').focus();
return false;
}
else {
//var name=document.getElementById('txt_name').value;
var emailadd=document.getElementById('txt_email').value;

//alert(document.getElementById('radiobutton').value);

for (var i=0; i < document.suber.subscriber.length; i++)
   {
   if (document.suber.subscriber[i].checked)
      {
      var rad_val = document.suber.subscriber[i].value;
	  
      }
   }




window.location.href='mailing.php?name='+name+'&emailadd='+emailadd+'&value='+rad_val;	
	alert("Your Request has been Sent !");
return true;
}
}
function search_amf(){
var searchVal=document.getElementById('search_filed').value;
if(searchVal==""){
  alert("Please Enter Some Keywords !");
  document.getElementById('search_filed').focus();
  return false;
  }

window.location.href='index.php?page=search&query='+ searchVal;	
//alert("ok");
}
function search_advamf(){

var theTable=document.getElementById('titleonly').value;

var searchVal=document.getElementById('query').value;
if(searchVal==""){
  alert("Please Enter Some Keywords !");
  document.getElementById('query').focus();
  return false;
  }
//alert(searchVal);
window.location.href='index.php?page=advsearch&query='+ searchVal + '&the_table=' +theTable;	
//alert("ok");
}

function search_amf_ar(){
var searchVal=document.getElementById('search_filed').value;
convertToEntities();

//alert("ok");
}

 function convertToEntities() {
  var tstr = document.getElementById('search_filed').value;
  if(tstr==""){
  alert("الرجاء إدخال بعض الكلمات الرئيسية");
  return false;
  }
  var bstr = '';
  for(i=0; i<tstr.length; i++)
  {
    if(tstr.charCodeAt(i)>127)
    {
      bstr += '&#' + tstr.charCodeAt(i) + ';';
    }
    else
    {
      bstr += tstr.charAt(i);
    }
  }
  
  
  document.getElementById('textfield2').value=bstr;
  return true;
  
// alert(bstr);
// window.location.href='ar_index.php?page=search&query='+ bstr;	
//  document.form.entity.value = bstr;
}

function ar_search_advamf(){

var theTable=document.getElementById('titleonly').value;

var searchVal=document.getElementById('query').value;
if(searchVal==""){
  alert("الرجاء إدخال بعض الكلمات الرئيسية");
  document.getElementById('query').focus();
  return false;
  }
//alert(searchVal);
window.location.href='ar_index.php?page=advsearch&query='+ searchVal + '&the_table=' +theTable;	
//alert("ok");
}

function convertToEntities_adv_ar() {
  var tstr = document.getElementById('query').value;
  if(tstr==""){
  alert("الرجاء إدخال بعض الكلمات الرئيسية");
  document.getElementById('query').focus();
  return false;
  }
  var bstr = '';
  for(i=0; i<tstr.length; i++)
  {
    if(tstr.charCodeAt(i)>127)
    {
      bstr += '&#' + tstr.charCodeAt(i) + ';';
    }
    else
    {
      bstr += tstr.charAt(i);
    }
  }
  
  
  document.getElementById('textfield2').value=bstr;
  return true;
  
	// alert(bstr);
	// window.location.href='ar_index.php?page=search&query='+ bstr;	
	//  document.form.entity.value = bstr;
}

function showProdDiv(theprod){
	
var prdname="prods"+ theprod;

var arrow="thearrow"+theprod;
//alert(prdname);
//	alert(theprod);
 
  
if(document.getElementById(prdname).style.display=="inline") 
{
	
document.getElementById(prdname).style.display = 'none';
document.getElementById(arrow).src='blankarrow.jpg';

}

else{
document.getElementById(prdname).style.display = 'inline';
document.getElementById(arrow).src='filleddown.jpg';
}


}
function showProdDiv_ar(theprod){
	
var prdname="prods"+ theprod;

var arrow="thearrow"+theprod;
//alert(prdname);
//	alert(theprod);
 
  
if(document.getElementById(prdname).style.display=="inline") 
{
	
document.getElementById(prdname).style.display = 'none';
document.getElementById(arrow).src='blankarrow_ar.jpg';

}

else{
document.getElementById(prdname).style.display = 'inline';
document.getElementById(arrow).src='filleddown_ar.jpg';
}


}

function showEventsDiv(theprod){
	
var prdname="events"+ theprod;

var arrow="thearrow"+theprod;
//alert(prdname);
//	alert(theprod);
 
  
if(document.getElementById(prdname).style.display=="inline") 
{
	
document.getElementById(prdname).style.display = 'none';
document.getElementById(arrow).src='blankarrow.jpg';

}

else{
document.getElementById(prdname).style.display = 'inline';
document.getElementById(arrow).src='filleddown.jpg';
}


}
function showEventsDiv_ar(theprod){
	
var prdname="events"+ theprod;

var arrow="thearrow"+theprod;
//alert(prdname);
//	alert(theprod);
 
  
if(document.getElementById(prdname).style.display=="inline") 
{
	
document.getElementById(prdname).style.display = 'none';
document.getElementById(arrow).src='blankarrow_ar.jpg';

}

else{
document.getElementById(prdname).style.display = 'inline';
document.getElementById(arrow).src='filleddown_ar.jpg';
}


}

function checkemail(){
var invalidaddress=new Array()
/*invalidaddress[0]="hotmail"
invalidaddress[2]="yahoo"
*/
var testresults
var invalidcheck=0;
var str=  document.getElementById('email').value;
var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str)){
var tempstring=str.split("@")
tempstring=tempstring[1].split(".")
for (i=0;i<invalidaddress.length;i++){
if (tempstring[0]==invalidaddress[i])
invalidcheck=1
}
if (invalidcheck!=1)
testresults=true
else{
alert("Please input a more official email address!")
testresults=false
}
}
else{
alert("Please input a valid email address!")
testresults=false
document.getElementById('email').focus();
}
return (testresults)
}