


var var_Select_A_Model=   'اختر النوع                ';
var var_Select_A_Manufacturer='اختر الشركة               ';
var var_complet_all_selections= 'فضلا أكمل جميع الاختيارات';
var are_you_sure_to_delete='are you sure you want to DELETE';
//arabic var

var error='تأكد من ادخال كلا من اسم المستخدم و كلمة المرور';
var js_p_user_name='اسم المستخدم';

//var error='make sure to enter the user name and password';
//var js_p_user_name='user name';


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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert(error+" \n");
  document.MM_returnValue = (errors == '');
}

function changemyColor_mover(mycolor,elmIDrow,elmCheck) {


		var newColor = mycolor;

		if((document.getElementById)&& (document.getElementById(elmIDrow)!=null)) 
		{

	  		// Get a reference to the element

			var myElement = document.getElementById(elmIDrow);

			//document.getElementById('tag').style.backgroundColor = newColor;
			if(!document.getElementById(elmCheck).checked)
				myElement.style.backgroundColor = newColor;

			// Check the element's style object and background property are available


  		}else
  		{	
				// This CSS property is not assigned or is not supported
				return;
  	 	}

}
function changemyColor_mout(mycolor,elmIDrow,elmCheck) {


		var newColor = mycolor;

		if((document.getElementById)&& (document.getElementById(elmIDrow)!=null)) 
		{

	  		// Get a reference to the element

			var myElement = document.getElementById(elmIDrow);
			
			if(!document.getElementById(elmCheck).checked)
				myElement.style.backgroundColor = newColor;

			// Check the element's style object and background property are available


  		}else
  		{	
				// This CSS property is not assigned or is not supported
				return;
  	 	}

}

function changemyColor_clickAndSetID(id,defultcolor,mycolor,elmIDrow,elmCheck) {


		var newColor = mycolor;
		if((document.getElementById)&& (document.getElementById(elmIDrow)!=null)) 
		{

	  		// Get a reference to the element
			
			var myElement = document.getElementById(elmIDrow);

			if(!document.getElementById(elmCheck).checked)
			{			
				
				document.getElementById(elmIDrow).style.backgroundColor = newColor;
				document.getElementById(elmCheck).checked =true;
				//document.getElementById(elmCheck).value =id;
			}
			else
			{
				document.getElementById(elmIDrow).style.backgroundColor = defultcolor;
				//document.f1.C1.checked=fasle;
				document.getElementById(elmCheck).checked =false;
				
			}
			// Check the element's style object and background property are available


  		}else
  		{	
				// This CSS property is not assigned or is not supported
				return;
  	 	}

}
function changemyColor_click(defultcolor,mycolor,elmIDrow,elmCheck) {


		var newColor = mycolor;
		if((document.getElementById)&& (document.getElementById(elmIDrow)!=null)) 
		{

	  		// Get a reference to the element
			
			var myElement = document.getElementById(elmIDrow);

			if(!document.getElementById(elmCheck).checked)
			{			
				
				document.getElementById(elmIDrow).style.backgroundColor = newColor;
				document.getElementById(elmCheck).checked =true;
				//document.f1.C1.click;

			}
			else
			{
				document.getElementById(elmIDrow).style.backgroundColor = defultcolor;
				document.getElementById(elmCheck).checked =false;
				
			}
			// Check the element's style object and background property are available


  		}else
  		{	
				// This CSS property is not assigned or is not supported
				return;
  	 	}

}

function setCheckboxes(the_form, do_check, basename,total,clr1,clr2,clr3)
{
    for (var i = 0; i < total; i++) {
    
		if (typeof(document.forms[the_form].elements[basename + i]) != 'undefined') {

				if(do_check==true){
					document.getElementById('r'+i).style.backgroundColor = clr2;
					document.getElementById(basename + i).checked =true;
				}
				if(do_check==false){
				
					if((i%2)!=0)// to return the alternation of color in rows
						document.getElementById('r'+i).style.backgroundColor = clr1;//make the row white
					else
						document.getElementById('r'+i).style.backgroundColor = clr3;//make the row gray
						
					document.getElementById(basename + i).checked =false;
				}
				//else
				

		}
	}
    //return true;
}
function clear_textbox(elem)
{	
	var t = document.getElementById(elem);
	//var un=js_p_user_name;
	if (t.value ==js_p_user_name || t.value == "11111111" )
	t.value = "";
} 
// to clear the content of text field
function update_mnfcr(row_id)
{
	//to hold the id of each cell in the table to be updated
	var mnfctr_name_cell=document.getElementById('maunfacturer_Name_'+row_id);
	var mnfctr_wbs_cell=document.getElementById('manufacturer_website_'+row_id);
	var agnt_name_cell=document.getElementById('agent_SA_'+row_id);
	var agnt_wbs_cell=document.getElementById('agent_website_'+row_id);
	var link_cell=document.getElementById('update_'+row_id);
	var butt_cell=document.getElementById('butt_'+row_id);
	
	//to hold the old contents
	var mnfctr_name=mnfctr_name_cell.innerHTML;
	var mnfctr_wbs=mnfctr_wbs_cell.innerHTML;
	var agnt_name=agnt_name_cell.innerHTML;
	var agnt_wbs=agnt_wbs_cell.innerHTML;
	
	
	//for the db since the old name is the index to that row in db
	var old_mnfctr_name_cont="<input type='hidden' name='old_mnfctr_name'   value='" + mnfctr_name + "'>";
	
	// to rebuild the new cells which will contain the text fields
	//var myform="<form name='update_mnfcr' method='post' action='update_mnfcr.php'>";
	var mnfctr_name_cont="<input type='text' name='mnfctr_name'   value='" + mnfctr_name + "'>";
	
	var mnfctr_wbs_cont="<input type='text' name='mnfctr_wbs'  value='" + mnfctr_wbs + "'>";
	var agnt_name_cont="<input type='text' name='agnt_name' value='" + agnt_name + "'>";
	var agnt_wbs_cont="<input type='text'  name='agnt_wbs' value='" + agnt_wbs + "'>";
	
	var sumbmitted_form='update_mnfcr_'+row_id;
	var butt_cell_cont="<a href='javascript:document." + sumbmitted_form + ".submit()'>OK</a>"
	//var butt_cell_cont="<input type='button'  onclick='javascript:document.sumbmitted_form.submit()'  value='OK'>";
	
	link_cell.style.visibility = "hidden";
	butt_cell.innerHTML = butt_cell_cont;
	

	// to disable the link that makes update
	
	
	
	//link_cell.innerHTML="<a >hello</a>";
	// to display new contents in the cells
	mnfctr_name_cell.innerHTML=mnfctr_name_cont+old_mnfctr_name_cont;
	mnfctr_wbs_cell.innerHTML=mnfctr_wbs_cont;
	agnt_name_cell.innerHTML=agnt_name_cont;
	agnt_wbs_cell.innerHTML=agnt_wbs_cont;
	//var b1=document.getElementById('b1');
	//b1.visible=false
	//b1.style.visibility = "hidden"
	//var t = cell.innerHTML;
	//var t = document.all.c1.innerText;
	
}
function alert_delete_mnfctr(r)
{
	if (confirm(are_you_sure_to_delete)) {
	var row ='delete_mnfcr_'+r;
		document.getElementById(row).submit();
	} else {
		return;
	}
}
function alert_test()
{
	
		alert('hello');
	
}
function alert_delete_showroom(r)
{
	if (confirm(are_you_sure_to_delete)) {
	var row ='delete_showroom_'+r;
		document.getElementById(row).submit();
	} else {
		return;
	}
}
function alert_block_showroom_e3lan(r)
{
	if (confirm(are_you_sure_to_delete)) {
	var row ='delete_showroom_e3lan'+r;
		document.getElementById(row).submit();
	} else {
		return;
	}
}


function alert_block_member_e3lan(r)
{
	if (confirm(are_you_sure_to_delete)) {
	var row ='delete_member_e3lan'+r;
	var fun ='function'+r;
		//document.write('before getElement');
		//document.write('<br>this is the row:'+row);
		document.getElementById(fun).value='block';
		document.getElementById(row).submit();
		
		
		//document.write('after getElement');
	} else {
		return;
	}
}

function alert_delete_showroom_e3lan(r)
{
	if (confirm(are_you_sure_to_delete)) {
	var row ='delete_showroom_e3lan'+r;
		document.getElementById(row).submit();
	} else {
		return;
	}
}
function update_showrooms_e3lan(row_id,sh_name)
{
	//to hold the id of each cell in the table to be updated
	var id_cell=document.getElementById('id'+row_id);
	var car_type_cell=document.getElementById('car_type'+row_id);
	var model_cell=document.getElementById('model'+row_id);
	var gear_type_cell=document.getElementById('gear_type'+row_id);
	var color_cell=document.getElementById('color'+row_id);
	var milage_cell=document.getElementById('milage'+row_id);
	var price_cell=document.getElementById('price'+row_id);
	var others_cell=document.getElementById('others'+row_id);
	var link_cell=document.getElementById('update_'+row_id);
	var butt_cell=document.getElementById('butt_'+row_id);

	
	
	//to hold the old contents
	var id=id_cell.innerHTML;
	var car_type=car_type_cell.innerHTML;
	var model=model_cell.innerHTML;
	var gear_type=gear_type_cell.innerHTML;
	var color=color_cell.innerHTML;
	var milage=milage_cell.innerHTML;
	var price=price_cell.innerHTML;
	var others=others_cell.innerHTML;
	

	
	
	//for the db since the old name is the index to that row in db
	//var old_sh_name_cont="<input type='hidden' name='old_sh_name'   value='" +sh_name+ "'>";
	
	// to rebuild the new cells which will contain the text fields
	//var myform="<form name='update_mnfcr' method='post' action='update_mnfcr.php'>";+ "<input type='hidden' name='sh_name'   value='" + sh_name + "'>"
	var id_cont ="<input type='text'  name='id'   value='" + id + "'>" ;
	id_cont =id_cont+ "<input type='hidden'  name='sh_name'   value='" + sh_name + "'>" ;
	var car_type_cont="<input type='text' name='car_type'   value='" + car_type + "'>";
	
	var model_cont="<input type='text' name='model'  value='" + model + "'>";
	var gear_type_cont="<input type='text'  name='gear_type' value='" + gear_type + "'>";
	var color_cont="<input type='text'  name='color' value='" + color + "'>";
	var milage_cont="<input type='text'  name='milage' value='" + milage + "'>";
	var price_cont="<input type='text'  name='price' value='" + price + "'>";
	var others_cont="<input type='text'  name='others' value='" + others + "'>";
	var sumbmitted_form='update_showroom_e3lan'+row_id;
	var butt_cell_cont="<a href='javascript:document." + sumbmitted_form + ".submit()'>OK</a>"
	
	
	// to disable the link that makes update
	link_cell.style.visibility = "hidden";
	butt_cell.innerHTML = butt_cell_cont;
	
	//========================================
	
	//sh_name_cell.innerHTML=sh_name_cont+old_sh_name_cont;//the old to add the hiddebn form field
	id_cell.innerHTML = id_cont;
	car_type_cell.innerHTML=car_type_cont;
	model_cell.innerHTML=model_cont;
	gear_type_cell.innerHTML=gear_type_cont;
	color_cell.innerHTML=color_cont;
	milage_cell.innerHTML=milage_cont;
	price_cell.innerHTML=price_cont;
	others_cell.innerHTML=others_cont;
	
	//init_gear_type(sumbmitted_form,'gear_type');
	

	
}
///---------------------------------------------------------------------------------------------------------------------
function update_showrooms(row_id)
{
	//to hold the id of each cell in the table to be updated
	var sh_name_cell=document.getElementById('showroom_name_'+row_id);
	var address_cell=document.getElementById('address_'+row_id);
	var phone_cell=document.getElementById('phone_'+row_id);
	var mobile_cell=document.getElementById('mobile_'+row_id);
	var email_cell=document.getElementById('email_'+row_id);
	var status_cell=document.getElementById('status_'+row_id);
	var link_cell=document.getElementById('update_'+row_id);
	var butt_cell=document.getElementById('butt_'+row_id);
	
	//to hold the old contents
	var sh_name=sh_name_cell.innerHTML;
	var address=address_cell.innerHTML;
	var phone=phone_cell.innerHTML;
	var mobile=mobile_cell.innerHTML;
	var email=email_cell.innerHTML;
	var status=status_cell.innerHTML;

	
	
	//for the db since the old name is the index to that row in db
	var old_sh_name_cont="<input type='hidden' name='old_sh_name'   value='" +sh_name+ "'>";
	
	// to rebuild the new cells which will contain the text fields
	//var myform="<form name='update_mnfcr' method='post' action='update_mnfcr.php'>";
	var sh_name_cont="<input type='text' name='sh_name'   value='" + sh_name + "'>";
	
	var address_cont="<input type='text' name='address'  value='" + address + "'>";
	var phone_cont="<input type='text' name='phone' value='" + phone + "'>";
	var mobile_cont="<input type='text'  name='mobile' value='" + mobile + "'>";
	var email_cont="<input type='text'  name='email' value='" + email + "'>";
	var status_cont="<input type='text'  name='status' value='" + status + "'>";
	var sumbmitted_form='update_showrooms_'+row_id;
	var butt_cell_cont="<a href='javascript:document." + sumbmitted_form + ".submit()'>OK</a>"
	
	
	// to disable the link that makes update
	link_cell.style.visibility = "hidden";
	butt_cell.innerHTML = butt_cell_cont;
	
	//========================================
	
	sh_name_cell.innerHTML=sh_name_cont+old_sh_name_cont;//the old to add the hiddebn form field
	address_cell.innerHTML=address_cont;
	phone_cell.innerHTML=phone_cont;
	mobile_cell.innerHTML=mobile_cont;
	email_cell.innerHTML=email_cont;
	status_cell.innerHTML=status_cont;

	
}
function show_no_added_e3lans(row_id){

	var add_e3lans_cell=document.getElementById('add_e3lans_'+row_id);
	var add_e3lans_cont="<input name='no_e3lans' type='text' size='1'>";
	
	var sh_name_cell=document.getElementById('showroom_name_'+row_id);
	var sh_name=sh_name_cell.innerHTML;
	var sh_name_cont="<input name='showroom_nm' type='hidden' value='" + sh_name + "'>";
	
	var sumbmitted_form='add_e3lans_2_showroom_'+row_id;
	var butt_cell_cont="<a href='javascript:document." + sumbmitted_form + ".submit()'> OK </a>";

	add_e3lans_cell.innerHTML=add_e3lans_cont+butt_cell_cont+sh_name_cont;
}
function myisNumber(inputStr) {

	for (var i = 0; i < inputStr.length; i++) {
	
		var oneChar = inputStr.substring(i, i + 1);
		if (oneChar < "0" || oneChar > "9") {
			return false;
			
		}
	}
	return true;
}

function isEmpty(text)
{	
	var x=document.getElementById(text).value;
	
	if (!myisNumber(x) || x=='')
	{
			alert("pleas enter a number");
			return true;
	}
	else
		return true;
}
function check_serchfield(mnfcrs,car_types,mnfc_yearfrom,mnfc_yearto)
{	
	var x=document.getElementById(mnfcrs).value;
	var y=document.getElementById(car_types).value;
	var z=document.getElementById(mnfc_yearfrom).value;
	var e=document.getElementById(mnfc_yearto).value;
	
	
	//document.write(x=='');
	//document.write(y);
	//document.write(z);
	//document.write(e);
	//return false;
	

	if ( x=='' || y=='' || z=='' || e=='')
	{
		//document.write('Did you call me');
			window.alert(var_complet_all_selections);
			return false;
	}
	else
		return true;
}
function check_add_new_e3lan_field(mnfcrs,car_types,mnfc_year)
{	
	var x=document.getElementById(mnfcrs).value;
	var y=document.getElementById(car_types).value;
	var z=document.getElementById(mnfc_year).value;

	if ( x=='' || y=='' || z=='')
	{
			alert(var_complet_all_selections);
			return false;
	}
	else
		return true;
}
//--------------------------------------------------------------------------------------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//================================================================================================================================

/**
*this method is used when we want to sort the mnfctrs array based on the arabic names as mnfctrs.sort(compare);
*In english just call mnfctrs.sort(); 
*/
function compare(a,b) {
	if (a[1] < b[1]) {return -1}
	if (a[1] > b[1]) {return 1}
	return 0
}
var colors=new Array();
colors[0]=new Array('white','أبيض');
colors[1]=new Array('red','أحمر');
colors[2]=new Array('green','أخضر');
colors[3]=new Array('blue','أزرق');
colors[4]=new Array('yellow','أصفر');
colors[5]=new Array('black','أسود');
colors[6]=new Array('orange','برتقالي');
colors[7]=new Array('magneta','بنفسجي');
colors[8]=new Array('gray','رمادي');
colors[9]=new Array('bink','زهري');
colors[10]=new Array('selever','فضي');
colors[11]=new Array('gold','ذهبي');
colors[13]=new Array('sea','بحري');
colors[14]=new Array('led','رصاصي');
colors[12]=new Array('others','أخرى');

/**/
//--------------------------------------------
function get_Mnfctr_Name_Engl(ar_name) {
	for (i=0;i<mnfctrs.length;i++){
		if (mnfctrs[i][1]== ar_name)
			return  mnfctrs[i][0];
	}
}
	
	
//--------------------------------------------
function init_Mnfctrs(formName, Mnfctrs_Select,Type_select) {
mnfctrs.sort(compare);
var Mnfctrs_list = document.forms[formName].elements[Mnfctrs_Select];
var	Type_list = document.forms[formName].elements[Type_select];

Mnfctrs_list.length=0;
Type_list.length=0;

Type_list.options[0]=new Option(var_Select_A_Model);
Type_list.options[0].value='';
Mnfctrs_list.options[0]=new Option(var_Select_A_Manufacturer);
Mnfctrs_list.options[0].value='';
	for (i=0;i<mnfctrs.length;i++){
	Mnfctrs_list.options[i+1]=new Option(mnfctrs[i][1],mnfctrs[i][1]);
	}
}

//---------------------------------------------
function changed_mnfctr(formName, Mnfctrs_Select, Type_select, selModel){
var Mnfctrs_list = document.forms[formName].elements[Mnfctrs_Select];
var	Type_list = document.forms[formName].elements[Type_select];
var	selected_Mnfctr_index = Mnfctrs_list.selectedIndex;
var  Mnfctrs_Value_ar = Mnfctrs_list.options[selected_Mnfctr_index].value;
var Mnfctrs_Value = get_Mnfctr_Name_Engl(Mnfctrs_Value_ar);
if(car_types[Mnfctrs_Value]!=null)
	car_types[Mnfctrs_Value].sort(compare);
//document.write('in:'+car_types[Mnfctrs_Value]);
//document.write('in:'+car_types[Mnfctrs_Value]);
	Type_list.length=0;
	

	if (Mnfctrs_Value != "") 
	{
		Type_list.options[0]=new Option(var_Select_A_Model);
		Type_list.options[0].value='';
		if(selected_Mnfctr_index>0)
		{
			var j=1;//options index
			for (i=0;i<car_types[Mnfctrs_Value].length;i++)
			{
			
				Type_list.options[j]=new Option(car_types[Mnfctrs_Value][i][1],car_types[Mnfctrs_Value][i][1]);
				j++;
				//document.write('in:'+car_types[Mnfctrs_Value][i]);
			}
		}
	} 
	else 
	{
		Type_list.options[0]=new Option(var_Select_A_Model);
	}
	Type_list.selectedIndex=selModel;
}
//---------------------------------------------

function init_model_No(formName, select_name) {

	var model_No_list = document.forms[formName].elements[select_name];
	model_No_list.length=0;
	
	model_No_list.options[0]=new Option('اختر موديلا');
	model_No_list.options[0].value='';
	//model_No_list.options[1]=new Option('أي موديل','');
	//model_No_list.options[1].value='';
//--------------------------------------------------------->>>>>>>>>>>>>>>Arabic
	//model_No_list.options[1]=new Option('Any','-');

	var x=1;
	var currYear =new Date();
	//document.write(currYear.getFullYear());
		for (i=currYear.getFullYear()+1;i>1980;i--){
		model_No_list.options[x]=new Option(i,i);
		x++;
		}
}
function init_price(formName, select_name) {

	var model_No_list = document.forms[formName].elements[select_name];
	model_No_list.length=0;
	
	//model_No_list.options[0]=new Option('select price');
	var x=0;
		for (i=1;i<500;i++){
		model_No_list.options[x]=new Option(i,i);
		x++;
		}
}
function init_milage(formName, select_name) {

	var model_No_list = document.forms[formName].elements[select_name];
	model_No_list.length=0;
	
	//model_No_list.options[0]=new Option('select milage');
	var x=0;
		for (i=0;i<500;i++){
		model_No_list.options[x]=new Option(i,i);
		x++;
		}
}
function init_colors(formName, select_name) {

	var model_No_list = document.forms[formName].elements[select_name];
	model_No_list.length=0;
	colors.sort(compare);
		for (i=0;i<colors.length;i++){
		model_No_list.options[i]=new Option(colors[i][1],colors[i][1]);
		
		}
}
function init_status(formName, select_name) {

	var model_No_list = document.forms[formName].elements[select_name];
	model_No_list.length=0;
	
	model_No_list.options[0]=new Option('unsold','unsold');
	model_No_list.options[1]=new Option('sold','sold');

}
function init_gear_type(formName, select_name) {

	var model_No_list = document.forms[formName].elements[select_name];
	model_No_list.length=0;
	
	model_No_list.options[0]=new Option('عادي','عادي');
	model_No_list.options[1]=new Option('أوتوماتيك','أوتوماتيك');

}

function jumpNext(evt,formName,fromFld, toFld) {
evt = (evt) ? evt : event
var charCode = (evt.which) ? evt.which : evt.keyCode
if (charCode == 13) {
document.forms[formName].elements[toFld].focus();
document.forms[formName].elements[toFld].select();


	
		var mnfc_id = document.getElementById(fromFld);
		var  mnfc_val_ar = mnfc_id.value;
		var  mnfc_val_en = get_Mnfctr_Name_Engl(mnfc_val_ar);
		//document.write(mnfc_val_ar);
		//var obj = actb(document.getElementById(toFld),car_types[mnfc_val_en] );

}

}
function getmnfctlist(mnfcFld){

		var obj = actb(document.getElementById(mnfcFld),mnfctrs );
}

function getCarType(mnfcFld,typefld) {


	
		var mnfc_id = document.getElementById(mnfcFld);
		var  mnfc_val_ar = mnfc_id.value;
		var  mnfc_val_en = get_Mnfctr_Name_Engl(mnfc_val_ar);
		//document.write(mnfc_val_ar);
		var obj = actb(document.getElementById(typefld),car_types[mnfc_val_en] );

}
function Clickheretoprint()
{ 
  var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=800, height=600, left=100, top=25, resizable=false"; 
  var content_obj = document.getElementById("print_content");
  content_obj.style.fontSize = '12pt';
  var content_vlue = content_obj.innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html dir="rtl"><head><title>www.Al-M3ard.Com</title>'); 
   docprint.document.write('<style type="text/css">');
   docprint.document.write('.printablePage { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }');
   docprint.document.write('</style></head><body><div class="printablePage"><center>');          
   docprint.document.write(content_vlue);         
   docprint.document.write('<a href="javascript:self.print()"><img src="images/print.gif"></a><br>جميع الحقوق محفوظة © لـ هورايزن كار  2005</center></div></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}

function isEmail(email)
{ 	
	var emailLeng=email.length;
	var atLocation=email.indexOf('@');
	
	if(atLocation>0){
		var beforeAt = email.substring(0,atLocation);
		var afterAt = email.substring(atLocation+1,emailLeng);
		var afterAtLeng = afterAt.length;
		var dotLocation=afterAt.indexOf('.');
		
		if( dotLocation <= 0 || (afterAtLeng-1)==dotLocation){
		//document.write("<br>"+atLocation);
		//document.write("<br>"+dotLocation);
			return false ;
		}
		else
		{
			return true ;
		}

	}
	else
	{
		return false;
	}
	
	
}
function initSelect(formName,selectName,tobeSelectedOptionValue)
{
	//var option = document.getElementById("country").elements["country"];
	var selectObject =document.forms[formName].elements[selectName];
	var index=0;
	for (var i = 0;i<selectObject.length;i++){
		
		if(selectObject.options[i].value==tobeSelectedOptionValue){
			index=i;
			selectObject.selectedIndex=index;
			break
		}
	}
}
function initRadio(formName,radioName,tobeSelectedRadioValue)
{
	var radioObject =document.forms[formName].elements[radioName];
	var index=0;
	for (var i = 0;i<radioObject.length;i++){
		
		if(radioObject[i].value==tobeSelectedRadioValue){
			
			radioObject[i].checked=true;
			break
		}
	}
}
//this function ensures that only on recored is submitted by deslecting the rows that may be selected by the user.
function update_e3lansSingle(theform,selected_cb,cbIntials,total,elem,status,dropAlertMsg){
	
	
		document.getElementById(elem).value=status;
		
		
		if(status=='drop')
		{
			if (confirm(dropAlertMsg)) {
				
				deSelect(selected_cb,cbIntials,total);
				document.getElementById(theform).submit();
			} else {
				return;
			}
		}
		else
		{
			deSelect(selected_cb,cbIntials,total)
			document.getElementById(theform).submit();
		}
}
function deSelect(selected_cb,cbIntials,total){
	
	for(i=0;i<total;i++){
		checkBox = document.getElementById(cbIntials+i);
		if(selected_cb!=cbIntials+i)
		checkBox.checked=false;
	}
	document.getElementById(selected_cb).checked=true;
}

function update_e3lans(theform,cb,total,elem,status,selectSomthing,dropAlertMsg){
	
	var isSomthingSelected=false;
	for(i=0;i<total;i++)
	{
		if(document.getElementById(cb+i).checked){
			isSomthingSelected = true;
			break;
		}
	}
	if(!isSomthingSelected){
		alert(selectSomthing);
	}
	else{
		
			document.getElementById(elem).value=status;
			if(status=='drop')
			{
				if (confirm(dropAlertMsg)) {
					document.getElementById(theform).submit();
				} else {
					return;
				}
			}
			else
			{
				document.getElementById(theform).submit();
			}
	}
}

function update_Group(theform,cb,total,elem,status,selectSomthing,AlertMsg){
	
	var isSomthingSelected=false;
	for(i=0;i<total;i++)
	{
		if(document.getElementById(cb+i).checked){
			isSomthingSelected = true;
			break;
		}
	}
	if(!isSomthingSelected){
		alert(selectSomthing);
	}
	else{
		
			document.getElementById(elem).value=status;
			if(status=='drop')
			{
				if (confirm(AlertMsg)) {
					document.getElementById(theform).submit();
				} else {
					return;
				}
			}
					
			if(status=='block')
			{
				if (confirm(AlertMsg)) {
					
					document.getElementById(theform).submit();
				} else {
					return;
				}
			}
			else
			{
				document.getElementById(theform).submit();
			}
	}
}
//this function ensures that only on recored is submitted by deslecting the rows that may be selected by the user.
function update_Single(theform,selected_cb,cbIntials,total,elem,status,AlertMsg){
	
	
		document.getElementById(elem).value=status;
		
		
		if(status=='drop')
		{
			if (confirm(AlertMsg)) {
				
				deSelect(selected_cb,cbIntials,total);
				document.getElementById(theform).submit();
			} else {
				return;
			}
		}
		
		if(status=='block')
		{
			if (confirm(AlertMsg)) {
				
				deSelect(selected_cb,cbIntials,total);
				document.getElementById(theform).submit();
			} else {
				return;
			}
		}
		else
		{
			deSelect(selected_cb,cbIntials,total)
			document.getElementById(theform).submit();
		}
}