﻿function FullScreenWindow()
{alert("helll");

alert("now in it ");
// evaluate screen size and generate panorama tag

// start with 600x400, in case all else fails...

	var sizeX = 600;
	var sizeY = 400;

// this one is MS-compatible

if (document.body.offsetWidth)
{
	sizeX = document.body.offsetWidth - 40 ;
	sizeY = document.body.offsetHeight - 40 ;
}

// this one is Mozilla-Style

if (window.innerWidth)
{
	sizeX = window.innerWidth - 40;
	sizeY = window.innerHeight - 40;
}
//    window.moveTo (0, 0);
//    if (document.layers) // navigator 4+
//    { var deltaX = screen.availWidth - window.outerWidth;
//    var deltaY = screen.availHeight - window.outerHeight;
//    window.resizeBy (deltaX, deltaY);
//    } else if (document.all) // exploder 4+
//    { resizeTo(screen.availWidth,screen.availHeight); }

}

//this function to handle enter action to the  textBox it take the textboxid and button ID needed
//to set the default button for the text box 
//في حاله لو عندي تكست وعايز أحدد زر عليه عند الضغط علي مفتاح الإنتر
function clickButton(e, buttonid){
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){
          if (evt.keyCode == 13){
                bt.click();
                return false;
          }

      }

}
//##################################################################################################################
//###########CODE for TABS##########################################################################################
//set the number of menu
 var cnt=5;
 var tt;
function Show(Click_Menu_Name)
{
    var Click_Menu = document.getElementById(Click_Menu_Name);
    tt=Click_Menu.id;
    for(i=1;i<=cnt;i++)
    {
        var tmp="display"+i;
        if(tmp==tt)
        {
           if(Click_Menu.style.display=="none")
           {
              Click_Menu.style.display="";
           }  
        }
        else
        {
            document.getElementById(tmp).style.display ="none";
        }
    }
}
function change_color(iid)
{
   if(iid=="img1" )
   {
      document.getElementById(iid).style.background="#324897";
      document.getElementById("img2").style.background="#86a0ff";   
     document.getElementById("img3").style.background="#86a0ff"; 
     document.getElementById("img4").style.background="#86a0ff"; 
     document.getElementById("img5").style.background="#86a0ff"; 
     
     document.getElementById("img1txt").style.color="white"; 
     
     
      document.getElementById("img2txt").style.color="#094079"; 
      document.getElementById("img3txt").style.color="#094079"; 
      document.getElementById("img4txt").style.color="#094079"; 
      document.getElementById("img5txt").style.color="#094079"; 
      
       
   }
   else if(iid=="img2")
   {
     document.getElementById(iid).style.background="#324897";
     document.getElementById("img3").style.background="#86a0ff";   
     document.getElementById("img1").style.background="#86a0ff"; 
     document.getElementById("img4").style.background="#86a0ff"; 
     document.getElementById("img5").style.background="#86a0ff"; 
     
     document.getElementById("img2txt").style.color="white"; 
     
     
      document.getElementById("img3txt").style.color="#094079"; 
      document.getElementById("img4txt").style.color="#094079"; 
      document.getElementById("img5txt").style.color="#094079"; 
      document.getElementById("img1txt").style.color="#094079"; 

    }
    else if(iid=="img3")
    {
      document.getElementById(iid).style.background="#324897";
      document.getElementById("img1").style.background="#86a0ff";   
      document.getElementById("img2").style.background="#86a0ff";
      document.getElementById("img4").style.background="#86a0ff";  
      document.getElementById("img5").style.background="#86a0ff";  
      
      document.getElementById("img3txt").style.color="white"; 
      
      document.getElementById("img2txt").style.color="#094079"; 
      document.getElementById("img1txt").style.color="#094079"; 
      document.getElementById("img4txt").style.color="#094079"; 
      document.getElementById("img5txt").style.color="#094079"; 
 
    }else if(iid=="img4")
    {
      document.getElementById(iid).style.background="#324897";
      document.getElementById("img1").style.background="#86a0ff";   
      document.getElementById("img2").style.background="#86a0ff"; 
      document.getElementById("img3").style.background="#86a0ff"; 
      document.getElementById("img5").style.background="#86a0ff"; 
      
      document.getElementById("img5txt").style.color="#094079"; 
      document.getElementById("img4txt").style.color="white"; 
      document.getElementById("img3txt").style.color="#094079"; 
      document.getElementById("img2txt").style.color="#094079"; 
      document.getElementById("img1txt").style.color="#094079";
      document.getElementById("txtUser").focus(); 

    }else if(iid=="img5")
    {
      document.getElementById(iid).style.background="#324897";
      document.getElementById("img1").style.background="#86a0ff";   
      document.getElementById("img2").style.background="#86a0ff"; 
      document.getElementById("img3").style.background="#86a0ff"; 
      document.getElementById("img4").style.background="#86a0ff"; 
      
      document.getElementById("img5txt").style.color="white"; 
      document.getElementById("img4txt").style.color="#094079";
      document.getElementById("img3txt").style.color="#094079"; 
      document.getElementById("img2txt").style.color="#094079"; 
      document.getElementById("img1txt").style.color="#094079";
      
    }
}


function ctck()
{
    var sds = document.getElementById("dum");
    if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
    var sdss = document.getElementById("dumdiv");
    if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}

//###########################################################################################################


//###########################################################################################################
//#####Global Variables for Tree######################################################################################################

var TREE_ITEMS = [
				[':: خدمات العملاء ::', null,
						['استعلام عن معاملة', null ],
						['تعديل رقم اشترك كهرباء', null ],
						['طلب أدوات ترشيد',null ],
						['اشتراك بخدمة الصرف',null],
						['تعديل بيانات اشتراك',null],
						['إضافة وحدات',null],
						['إيقاف مؤقت للخدمة',null],
						
				]
			];
var TREE_ITEMS_Customer_Bills = [
                                
                                [':: فواتير ::', null ,
							        ['تسديد فاتورة',null],
							        ['تفاصيل السداد',null],
							        ['عرض آخر فاتورة',null],
							        ['تفاصيل الفواتير',null],
							        ['طلب مراجعة فاتورة',null],
							        ['متابعة بلاغ فاتورة',null]							        
						        ]

                                ];
var TREE_ITEMS_Customer_Notes =  [
                                    [':: بلاغات ::', null ,
							            ['إبلاغ عن أعطال مياه','Addnotification.aspx'],
							            ['استعلام عن بلاغات','Querynotification.aspx'],
						            ]
                                 ];
                                 


var TREE_ITEMS_GOV_MWE = [
				            [':: وزارة المياه والكهرباء ::', null,
						        ['الأنظمة الداخلية', null ,
						            ['نظام مصادر المياه',null],
						            ['نظام مصادر المياه خادم إضافي',null],	
						            ['نظام الحركة',null],	
						            ['نظام متابعة المشاريع',null],	
						            ['نظام الترشيد',null,       ['نسخة البرنامج الجديد',null],['نسخة مخصصة للتدريب',null]  ],	
						            ['close',null]
						        ],
						        ['موقع الوزارة',null],
				            ]
			             ];


var TREE_ITEMS_GOV_AMANA =  [
				[':: أمانة المدينة المنورة ::', null,
						['نظام خطابات الأمانة', null ],
						['المخطط الاقليمي', null ],
						['المرصد الحضري', null ],
						['نظام تصاريح السفر', null]
						
				]
			];
var TREE_ITEMS_Comp = [
				        [':: خدمات الشركات ::', null,
				            ['تسجيل مقاول جديد','http://213.230.26.244/MOCnts/Browser/newContract.aspx?lang=1'],
				            ['تحديث بيانات','http://213.230.26.244/MOCnts/Browser/chkContracts.aspx?lang=1'],
				            ['الأسئلة الشائعة','http://213.230.26.244/MOCnts/Browser/'],
				            ['طريقة التسجيل','http://213.230.26.244/MOCnts/Browser/'],
				            ['طريقة التحديث','http://213.230.26.244/MOCnts/Browser/']
				            						
				]
			];
var TREE_ITEMS_emp1 = [
				[':: خدمات الموظفين ::', null,
					['خدمات الاجازات',null],
					['الاستعلام عن العهد',null],
					['الاستحقاقات المالية',null],
					['حسميات التأخير والغياب',null],
					['حسميات الاجازات',null],
					['الدورات',null],
				]
			];
var TREE_ITEMS_emp2 = [
				[':: خدمات الموظفين ::', null,
				    ['المؤهلات العلمية',null],
				    ['الحضور والانصراف',null],
				    ['التقييم السنوي',null],
				    ['تفاصيل الراتب',null],
				    ['تحديث البيانات الشخصية',null],
				]
			];


/*
	Feel free to use your custom ../images for the tree. Make sure they are all of the same size.
	User ../images collections are welcome, we'll publish them giving all regards.
*/
 
var TREE_TPL = {
	'target'  : '_self',	// name of the frame links will be opened in
							// other possible values are: _blank, _parent, _search, _self and _top
 
	'icon_e'  : 'images/empty.gif', // empty image
	'icon_l'  : 'images/line.gif',  // vertical line
 
        'icon_32' : 'images/SquareDarkBlue.gif',   // root leaf icon normal
        'icon_36' : 'images/SquareDarkBlue.gif',   // root leaf icon selected
	
	'icon_48' : 'images/SquareDarkBlue.gif',   // root icon normal
	'icon_52' : 'images/SquareDarkBlue.gif',   // root icon selected
	'icon_56' : 'images/SquareDarkBlue.gif',   // root icon opened
	'icon_60' : 'images/SquareDarkBlue.gif',   // root icon selected
	
	'icon_16' : 'images/SquareOrange.gif', // node icon normal
	'icon_20' : 'images/SquareOrangeOpen.gif', // node icon selected
	'icon_24' : 'images/SquareOrangeOpen.gif', // node icon opened
	'icon_28' : 'images/SquareOrangeOpen.gif', // node icon selected opened
 
	'icon_0'  : 'images/SquareGray.gif', // leaf icon normal
	'icon_4'  : 'images/SquareGray.gif', // leaf icon selected
	
	'icon_2'  : 'images/joinbottom.gif', // junction for leaf
	'icon_3'  : 'images/join.gif',       // junction for last leaf
	'icon_18' : 'images/plusbottom.gif', // junction for closed node
	'icon_19' : 'images/plus.gif',       // junctioin for last closed node
	'icon_26' : 'images/minusbottom.gif',// junction for opened node
	'icon_27' : 'images/minus.gif'       // junctioin for last opended node
};
 

//####################################################################################

 

 
function tree (a_items, a_template) {
 
	this.a_tpl      = a_template;
	this.a_config   = a_items;
	this.o_root     = this;
	this.a_index    = [];
	this.o_selected = null;
	this.n_depth    = -1;
	
	var o_icone = new Image(),
		o_iconl = new Image();
	o_icone.src = a_template['icon_e'];
	o_iconl.src = a_template['icon_l'];
	a_template['im_e'] = o_icone;
	a_template['im_l'] = o_iconl;
	for (var i = 0; i < 64; i++)
		if (a_template['icon_' + i]) {
			var o_icon = new Image();
			a_template['im_' + i] = o_icon;
			o_icon.src = a_template['icon_' + i];
		}
	
	this.toggle = function (n_id) {	var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
	this.select = function (n_id) { var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened); return this.a_index[n_id].select(); };
	this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
	this.mover  = function (n_id) { this.a_index[n_id].upstatus() };
 
	this.a_children = [];
	for (var i = 0; i < a_items.length; i++)
		new tree_item(this, i);
 
	this.n_id = trees.length;
	trees[this.n_id] = this;
	
	for (var i = 0; i < this.a_children.length; i++) {
		document.write(this.a_children[i].init());
		this.a_children[i].open();
	}
}
function tree_item (o_parent, n_order) {
 
	this.n_depth  = o_parent.n_depth + 1;
	this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
	if (!this.a_config) return;
 
	this.o_root    = o_parent.o_root;
	this.o_parent  = o_parent;
	this.n_order   = n_order;
	this.b_opened  = !this.n_depth;
 
	this.n_id = this.o_root.a_index.length;
	this.o_root.a_index[this.n_id] = this;
	o_parent.a_children[n_order] = this;
 
	this.a_children = [];
	for (var i = 0; i < this.a_config.length - 2; i++)
		new tree_item(this, i);
 
	this.get_icon = item_get_icon;
	this.open     = item_open;
	this.select   = item_select;
	this.init     = item_init;
	this.upstatus = item_upstatus;
	this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
}
 
function item_open (b_close) {
	var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id);
	if (!o_idiv) return;
	
	if (!o_idiv.innerHTML) {
		var a_children = [];
		for (var i = 0; i < this.a_children.length; i++)
			a_children[i]= this.a_children[i].init();
		o_idiv.innerHTML = a_children.join('');
	}
	o_idiv.style.display = (b_close ? 'none' : 'block');
	
	this.b_opened = !b_close;
	var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id],
		o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_jicon) o_jicon.src = this.get_icon(true);
	if (o_iicon) o_iicon.src = this.get_icon();
	this.upstatus();
}
 
function item_select (b_deselect) {
	if (!b_deselect) {
		var o_olditem = this.o_root.o_selected;
		this.o_root.o_selected = this;
		if (o_olditem) o_olditem.select(true);
	}
	var o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_iicon) o_iicon.src = this.get_icon();
	get_element('i_txt' + this.o_root.n_id + '_' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold';
	
	this.upstatus();
	return Boolean(this.a_config[1]);
}
 
function item_upstatus (b_clear) {
	window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10);
}
 
function item_init () {
	var a_offset = [],
		o_current_item = this.o_parent;
	for (var i = this.n_depth; i > 1; i--) {
		a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">';
		o_current_item = o_current_item.o_parent;
	}
	return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>' + (this.n_depth ? a_offset.join('') + (this.a_children.length
		? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')"><img src="' + this.get_icon(true) + '" border="0" align="absbottom" name="j_img' + this.o_root.n_id + '_' + this.n_id + '"></a>'
		: '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') 
		+ '<a  href="' + this.a_config[1] + '" target="' + this.o_root.a_tpl['target'] + '" onclick="return trees[' + this.o_root.n_id + '].select(' + this.n_id + ')" ondblclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')" class="Treemenu" id="i_txt' + this.o_root.n_id + '_' + this.n_id + '"><img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.o_root.n_id + '_' + this.n_id + '" class="t' + this.o_root.n_id + 'im">' + this.a_config[0] + '</a></td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : '');
}
 
function item_get_icon (b_junction) {
	return this.o_root.a_tpl['icon_' + ((this.n_depth ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0))];
}
 
var trees = [];
get_element = document.all ?
	function (s_id) { return document.all[s_id] } :
	function (s_id) { return document.getElementById(s_id) };
	
 
//########################################################################################################

//***********QueryStringFunction**************************************************************************
function getQueryStrings() {
    var argList = new Object();

    if(window.location != null && window.location.search.length > 1) {
        var urlParms = window.location.search.substring(1);
        var argPairs = urlParms.split('&');

        for(var i = 0; i < argPairs.length; i++) {
            var pos = argPairs[i].indexOf('=')

            if(pos == -1)
                continue;
            else {
                var argName = argPairs[i].substring(0, pos);
                var argVal = argPairs[i].substring(pos + 1);

                if(argVal.indexOf('+') != -1)
                    argVal = argVal.replace(/\+/g, ' ');

                argList[argName] = unescape(argVal);
            }
        }
    }
    
    return argList;
}

//************************************************************************************************
function callServicePage(ACCno){
    var regEX = /^\d{12}$/;
    var obj = document.getElementById(ACCno);
    
    if (obj.value == ''){
        alert('الرجاء إدخال رقم الحساب');
        obj.focus();
        return;
    }
    if (obj.value.search(regEX)!=0 && obj.value != null){
        alert('الرجاء ادخال رقم مكون من 12 خانة');
        obj.focus();
        obj.select();
    }
    else{
        var hidText = document.getElementById('hidSelected');
        var pageName = ''
        switch(hidText.value)
        {
        case '1':
            pageName = 'SadadDetails.aspx';
            break;
        case '2':
            pageName = 'BillQuery.aspx';
            break;
        case '3':
            pageName = 'AccountDetails.aspx';
            break;
        case '4':
            pageName = 'billPrint.aspx';
            break;
        case '5' :
            pageName = 'DemandTarsheed.aspx';
            break;
             case '6' :
            pageName = 'ConsumingReport.aspx';
            break;
        default:
            break;
        }
        
        window.location.href = 'eServicesForAccountNumber/' + pageName + '?Accountno=' + obj.value;
    }
    
}
