function objText(d)
{
	var s = new Array();
	s.push('{<br>');
	for ( var i in d )
		s.push("&nbsp;&nbsp;&nbsp;" + i + ": " + d[i] + "<br>");
	s.push('}');
	return s.join('');
}

function checkmobile (mobile,textboxname){
   
var testPattern = /9665\d{9}/;
if (!testPattern.test(mobile)){
document.getElementById(textboxname).value="";
alert( 'لابد أن يكون رقم الجوال على الصيغة: 9665XXXXXXXX' ); 
}
}
function checkform (tagelements){
    var str = '';
    var lastresult=1;
    var elem = document.getElementById(tagelements).elements;
for(var i = 0; i < elem.length; i++)
{
    if (elem[i].value==""){
    elem[i].style.border="1px solid red";
    lastresult=2;
    }
    else
    elem[i].style.border="1px solid #333";
} 
if (lastresult==2)
return false;
else if (lastresult==1)
return true;
   
}

var trv_order_divname; 
function DTWindow(title, dContent,divname)
{
	trv_order_divname=divname
	// save arguments
	this.title = title;
	this.dContent = dContent;
 
	// create table for window with title-bar and content
	this.dTable = document.createElement("table");
	this.dTable.border = 0;
	this.dTable.width = "100%";
	//this.dTable.style.border='1px black solid';
 
	// set the position of the window
	this.dTable.style.position = "relative";
	this.dTable.style.backgroundColor = "white";
 
	// link from the table to the DTWindow object
	this.dTable.DTWindow = this;
 
	// append to document body
	document.getElementById(divname).appendChild(this.dTable);
 
	// add row for title bar
	var dTR = this.dTable.insertRow(0);
	dTR.className = "DTWindowTitleStyle";


	
	// title	
	var dTD = dTR.insertCell(0);
	dTD.innerHTML = this.title;
	dTD.width="98%";
	dTD.DTWindow = this;
	
	

	
	
	// minimize
	this.dMinTD = dTR.insertCell(1);
	this.dMinTD.width="1%";
	this.dMinTD.align="left";
	this.dMinTD.style.cursor="pointer"
	this.dMinTD.innerHTML = "<img src='images/maxminsize.jpg'/>";
	this.dMinTD.onmousedown = DTWindow.prototype.onMinimize;
	this.dMinTD.DTWindow = this;

 		// close
	this.dTD = dTR.insertCell(2);
	this.dTD.style.cursor="pointer"
	this.dTD.align="left";
	this.dTD.width="1%";
	this.dTD.innerHTML = "<img src='images/delete.png'/>";
	this.dTD.DTWindow = this;	
	this.dTD.onmousedown = DTWindow.prototype.onClose;

	
 
	

	// add row for window content
	// a single cell the same width as the title bar row
	dTR = this.dTable.insertRow(1);
	dTD = dTR.insertCell(0);
	dTD.colSpan = 3;
	dTD.appendChild(dContent);
		
		
 
}
 
 
 
 
 
DTWindow.prototype.RemoveRow = function()
{	
	
	// remove from browser document
		this.dContent.parentNode.removeChild(this.dContent);
				this.dContent.parentNode.removeChild(this.deleteRow);
	
	//this.dTable.parentNode.removeChild(this.dTable.);
  }
	
  DTWindow.prototype.onRemoveRow = function()
  {
	this.DTWindow.RemoveRow();
}
 
DTWindow.prototype.onAddRow = function()
{
	this.DTWindow.AddRow();
}

DTWindow.prototype.onMinimize = function()
{
	this.DTWindow.minimize();
}
DTWindow.prototype.minimize = function()
{
	// hide the content
	this.dContent.style.visibility = "hidden";
	//this.dContent.style.position = "relative";
	document.getElementById(trv_order_divname).appendChild(this.dContent);
	
	//this.dTable.deleteRow(1);
	this.dMinTD.style.cursor="pointer";
	this.dMinTD.align="left";
	this.dMinTD.width="1%";
	this.dMinTD.innerHTML = "<img src='images/maxminsize.jpg'/>";
	this.dMinTD.onmousedown = DTWindow.prototype.onMaximize;
}
 
DTWindow.prototype.onMaximize = function()
{
  this.DTWindow.maximize();
}
  DTWindow.prototype.maximize = function()
  {
	// add the content again.
	dTR = this.dTable.insertRow(1);
	dTD = dTR.insertCell(0);
	dTD.colSpan = 3;
	
	dTD.appendChild(this.dContent);
	this.dContent.style.visibility = "visible";
	this.dMinTD.align="left";
	this.dMinTD.width="1%";
	this.dMinTD.innerHTML = "<img src='images/maxminsize.jpg'/>";
	this.dMinTD.onmousedown = DTWindow.prototype.onMinimize;
  }
  DTWindow.prototype.onMaximize = function()
  {
	this.DTWindow.maximize();
}
	
  //Toggle Row hide/show	(RowMin
  DTWindow.prototype.onRowMin = function()
  {
  	this.DTWindow.RowMin();
  }
  DTWindow.prototype.RowMin = function()
  {
  	// hide the content
  	this.dContent.style.visibility = "hidden";
	 // this.dContent.style.position = "relative";
	  document.getElementById(divname).appendChild(this.dContent);
  	this.dTogTD.innerHTML = "<img src='images/maxminsize.jpg'/>";
  	this.dTogTD.align="left";
  	this.dTogTD.width="1%";
  	this.dTogTD.onmousedown = DTWindow.prototype.onRowMax;
  }
 
  //Toggle Row hide/show	(RowMax)
 
	DTWindow.prototype.onRowMax  = function()
  {
  this.DTWindow.RowMax();
  }
  DTWindow.prototype.RowMax = function()
  {
	// add the content again.
	
  }
  DTWindow.prototype.onRowMax  = function()
  {
	this.DTWindow.RowMax();
}
	
	
DTWindow.prototype.close = function()
{	
	// remove content from browser document
	this.dContent.parentNode.removeChild(this.dContent);
	
	// remove from browser document
	this.dTable.parentNode.removeChild(this.dTable);
  }
  DTWindow.prototype.onClose = function()
  {
	this.DTWindow.close();
}



 function ret(id){ return document.getElementById(id); }
 function changeCat(){if(!ret("OS_Country"))return; var selectedCat = ret("OS_Country").value; ret("subCat_"+curCombo).style.display = "none"; ret("subCat_"+selectedCat).style.display = "inline"; curCombo = selectedCat;}
 function PopUpHotel(){props=window.open('sel_hotel.php', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=750, height=400, left = 250, top = 200');}
 function popUpFlyGo(){props=window.open('sel_city.php?mode=Go', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=250, left = 250, top = 200');}
 function popUpacc(line,type){props=window.open('sel_acc.php?mode=Go&l='+line+'&t='+type, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=1, menubars=0, resizable=0, width=650, height=650, left = 250, top = 200');}
 function popUpprint(tienum){props=window.open('print_tie.php?tie='+tienum, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpprintbank(tienum,type,lang){props=window.open('print_bank.php?tie='+tienum+'&type='+type+'&lang='+lang, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpprintsalpro(tienum){props=window.open('print_salpro.php?tie='+tienum, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
  function popUpprintvacation(vac_id,emp_id){props=window.open('print_vac.php?id='+vac_id+'&emp='+emp_id, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUppayment(tienum,cost){props=window.open('payment.php?id='+tienum+'&cost='+cost, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpprintacc(accnum,acctree,datefrom,dateto){props=window.open('print_acc_stmt.php?acc='+accnum+'&tree='+acctree+'&datefrom='+datefrom+'&dateto='+dateto+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpprintaccchk(accnum,acctree,datefrom,dateto,type){props=window.open('print_chk_acc_stmt.php?acc='+accnum+'&tree='+acctree+'&datefrom='+datefrom+'&dateto='+dateto+'&type='+type+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpsendacc(accnum,acctree,datefrom,dateto){props=window.open('send_acc_stmt.php?acc='+accnum+'&tree='+acctree+'&datefrom='+datefrom+'&dateto='+dateto+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpsendaccchk(accnum,acctree,datefrom,dateto){props=window.open('send_chk_acc_stmt.php?acc='+accnum+'&tree='+acctree+'&datefrom='+datefrom+'&dateto='+dateto+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 function popUpFlyBack(){props=window.open('sel_city.php?mode=Back', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=250, left = 250, top = 200');}
 
 
function ajaxcombo(url,value,subname){
	Ajax.submenu=subname;
	Ajax.Request(url,value, Ajax.Response);
}
 
 function popUpbyURL(url){props=window.open(url, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}
 
 

 
 function funHS(varObjID){ if( document.getElementById(varObjID).style.display=="none" ){ document.getElementById(varObjID).style.display="block"; }else{ document.getElementById(varObjID).style.display="none"; } }
 function funShowAll(){ for(i=1; i <= 10; i++){ document.getElementById(i).style.display="block"; funSImg(i); } }
 function funHideAll(){ for(i=1; i <= 10; i++){ document.getElementById(i).style.display="none"; } } arrImgID = new Array(); arrImgN = new Array();
function linksendaccsirct(acc,tree,email,bossemail)
{
	var controlfrom='Acc_str_date_stmt_'+acc;
	var controlto='Acc_end_date_stmt_'+acc;	
	var from=document.getElementById(controlfrom).value;
	var to=document.getElementById(controlto).value;
	props=window.open('send_acc_stmt.php?acc='+acc+'&tree='+tree+'&datefrom='+from+'&dateto='+to+'&to='+email+'&cc='+bossemail+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');
// javascript code
}

function linkprintaccsirct(accnum,acctree){
	var controlfrom='Acc_str_date_stmt_'+accnum;
	var controlto='Acc_end_date_stmt_'+accnum;	
	var from=document.getElementById(controlfrom).value;
	var to=document.getElementById(controlto).value;
	
	props=window.open('print_acc_stmt.php?acc='+accnum+'&tree='+acctree+'&datefrom='+from+'&dateto='+to+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');}

function linksendaccsirctchk(acc,email,bossemail)
{
	var controlfrom='Acc_str_date_stmt_chk_'+acc;
	var controlto='Acc_end_date_stmt_chk_'+acc;	
	var from=document.getElementById(controlfrom).value;
	var to=document.getElementById(controlto).value;
	props=window.open('send_chk_acc_stmt.php?acc='+acc+'&tree=0&datefrom='+from+'&dateto='+to+'&to='+email+'&cc='+bossemail+'&view=1', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=750, left = 10, top = 10');
// javascript code
}
  function CallPrint(strid) {
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('', '', 'letf=0,top=0,width=750,height=600,toolbar=0,scrollbars=2,status=0');
            WinPrint.document.write("<html  dir='rtl'><head><LINK TYPE='text/css' REL='stylesheet' HREF='images/main.css'><LINK TYPE='text/css' REL='stylesheet' HREF='css/style.css'></head><body><center><img src='http://s15r.showlag.com/images/logos/1101.jpg' /></center>"+prtContent.innerHTML+"</body></html>");
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            WinPrint.close();
        }
         function CallPrintwithtree(strid,tree) {
         	var y = document.getElementById('txt_pagecounter').value;	
         	for (var i=1;i<=y;i++){
         	document.getElementById('headpage'+i).style.display = ''	
         	}
			 
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('', '', 'letf=0,top=0,width=750,height=600,toolbar=0,scrollbars=2,status=0');
            WinPrint.document.write("<html dir='rtl'><head><LINK TYPE='text/css' REL='stylesheet' HREF='css/main.css'> <style>@media print{input {display:none}}</style></head><body><center><img src='http://s15r.showlag.com/images/logos/"+tree+".jpg' /></center>"+prtContent.innerHTML+"</body></html>");
                  		
         	for (var i=1;i<=y;i++){
         	document.getElementById('headpage'+i).style.display = 'none'	
         	}
			WinPrint.document.close();
			WinPrint.focus();
            WinPrint.print();
            //WinPrint.close();
        }