function over(id){
	id.style.cursor='hand';
}
function winopen(url,w,h){
	window.open(url,"",'width='+ w +',height='+ h +',resizable=yes, scrollbars=no ,status=0 ,toolbar=no ,menubar=no');
}

/*****************************************Swap Images***********************************************/
function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

/*****************************************Swap Images***********************************************/

invalidaddress = new Array();
function addOption(theSel, theText, theValue)
{
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{	
	var selLength = theSel.length;
	if(selLength>0)
	{
		theSel.options[theIndex] = null;
	}
}

function moveOptions(theSelFrom, theSelTo)
{
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;
	var i;
	
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=selLength-1; i>=0; i--)
	{
		if(theSelFrom.options[i].selected)
		{
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}	
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selectedCount-1; i>=0; i--)
	{
		addOption(theSelTo, selectedText[i], selectedValues[i]);
	}	
}

function checkemail(str){
     var invalidcheck=0;
     var filter=/^.+@.+\..{2,3}$/
     if (filter.test(str)){
        var tempstring=str.split("@")
        tempstring=tempstring[1].split(".php ")
        for (i=0;i<invalidaddress.length;i++){
           if (tempstring[0]==invalidaddress[i])
               invalidcheck=1
         }
        if (invalidcheck!=1)
          testresults=true
        else{
                 testresults=false
             }
      }
    else{
      testresults=0
     }
	return (testresults)
}


function validateFields(arr){
	bol=true;
	for (i=0;i<arr.length;i++)    
	if (!arr[i]){ 
		alert("(*) يرجى ادخال جميع الحقول المشار اليها بـ   ") ;
		bol=false;
		break;
	}
	return bol;
}
/*function validateFields(arr){
  invalidfields=""; bol=true;
  for (i=0;i<arr.length;i++) 
   {   
	   if (arr[i] != null) 
  	     {invalidfields = invalidfields + "  " +arr[i];}
   }
  if( invalidfields != "")
	 {
	  bol=false;
	  alert(" <?=_Required?>::"+invalidfields);
	 }
	 return bol;
  }
 */ 
function validateNum(arr,arr_val){
	bol=true;
	invalidfields='';
	for (i=0;i<arr.length;i++){    
		if ( isNaN(arr[i]) ) {
			invalidfields = invalidfields + "  " +arr_val[i];     
		}
	}
	if( invalidfields != "") {
		  bol=false;
		  alert( "  <?=_Valid_num?> :  " +invalidfields );
	 }
	 return bol; 
	
}
  
function trimString (str) {
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}   

