﻿
function _APP_UI_Search_Validate(ctrl, scope, comment)
{
	var ret = false;
	var frm = ctrl.form;
	var lang = 'English';
	
	if (-1 == comment.indexOf('k')) 
		lang = 'Arabic';
	if (frm)
	{
		var idx = -1;
		for (var i=0; i < ctrl.form.elements.length; i++)
		{
			if (-1 != ctrl.form.elements[i].name.indexOf(scope))
				idx = i;
		}
		var txt = ctrl.form.elements[idx];
		if (txt)
		{
			ret = (!(_ISD_UI_Form_IsEmptyString(txt.value) || txt.value == comment));
			if (!ret)
			{
				if ('English' == lang)
					alert('check keyword !'); 
				else
					alert('\u062A\u0623\u0643\u062F \u0645\u0646 \u0643\u0644\u0645\u0629 \u0627\u0644\u0628\u062D\u062B !'); 
					
				txt.focus();
			}
			else
			{
				ret = _ISD_UI_Form_ValidateStringRegExp(txt.value);
				if (!ret)	
				{
				  if ('English' == lang)
					  alert('Special characters are not permitted. please check the keyword !');
				  else
					  alert('غير مسموح بإستخدام حروف خاصه (مثل . - *) أثناء البحث. رجاء مراجعة كلمة البحث !');
					  
					txt.focus();
				}
			}
		}	
	}
	return ret;
}

function _APP_UI_QuickSearch_Validate(ctrlSubmit)
{
	var ret = false;
	var lang = 'English';
	
	ctrlSubmit = _ISD_UI_EnsureObject(ctrlSubmit);
	if (null != ctrlSubmit)
	{
		if ('Search' != ctrlSubmit.value)
			lang = 'Arabic';
	
		var index = _ISD_UI_getIndex(ctrlSubmit);
		if (-1 != index) 
		{
			var str = ctrlSubmit.form.elements[index - 1].value;
			ret = (false == _ISD_UI_Form_IsEmptyString(str));
		}
	}
	if (!ret)
	{
		
		if ('English' == lang)
				alert('check keyword !'); 
			else
				alert('\u062A\u0623\u0643\u062F \u0645\u0646 \u0643\u0644\u0645\u0629 \u0627\u0644\u0628\u062D\u062B !'); 
				
		ctrlSubmit.form.elements[index - 1].focus();
	}
	
	return ret;
}
function _APP_UI_QuickSearch_SetWaterMarking(ctrlTxt, raiseEvent, defTxt)
{
	if(ctrlTxt.value.length == 0 && raiseEvent.type == "blur") 
	{
		ctrlTxt.value = defTxt; 
		ctrlTxt.style.color = "#999999"; 
  }
  if(raiseEvent.value == defTxt && raiseEvent.type == "focus") 
  {
		ctrlTxt.value = ""; 
		ctrlTxt.style.color = "#000000"; 
  }   
}
function _RPT_LinkParent(objectID)
{
	var href = 'LinkParent.aspx' + '?' + 'ObjectID' + '=' + objectID;
	_ISD_UI_Window_openPopup(href, 'wndView', 320, 400, true);
}
function _RPT_ViewTransLog(objectID)
{
	var href = 'ViewTransLog.aspx' + '?' + 'ObjectID' + '=' + objectID;
	_ISD_UI_Window_openPopup(href, 'wndView', 350, 250, false);
}
function _RPT_ViewUser(objectID)
{
	var href = 'ViewUser.aspx' + '?' + 'ObjectID' + '=' + objectID;
	_ISD_UI_Window_openPopup(href, 'wndView', 500, 400, false);
}
function _RPT_ViewUserTransLog(objectID)
{
	var href = 'ViewUserTransLog.aspx' + '?' + 'ObjectID' + '=' + objectID;
	_ISD_UI_Window_openPopup(href, 'wndView', 500, 450, true);
}
function _ISD_UI_StandardNavigation_showMenu(ctrl)
{
	try
	{
		var obj = eval('window.' + ctrl);
		if ((null != obj))
		{
			if (obj.style.visibility == 'hidden')
			{
				_ISD_UI_pausecomp(400);
				
				obj = eval('window.aspnetForm.' + ctrl + 'Image');
				if ((null != obj))
				{
					if (-1 == obj.src.indexOf('TitleOver'))
						obj.src = obj.src.replace("Title", "TitleOver");
				}
				
				obj = eval('window.' + ctrl);
				obj.style.visibility = 'visible';
				obj.style.display = 'inline';
				
			}	
		}
	} catch(e){ alert(e.message);}
}

function _ISD_UI_StandardNavigation_hideMenu(ctrl)
{
	try
	{
		var obj = eval("window." + ctrl);
		if ((null != obj))
		{
			obj.style.visibility = 'hidden';
			obj.style.display = 'none';
			
			obj = eval('window.aspnetForm.' + ctrl + 'Image');
			if ((null != obj))
			{
				if (-1 != obj.src.indexOf('TitleOver'))
					obj.src = obj.src.replace("TitleOver", "Title");
			}
		}
	} catch(e){;}
}		
		
function _ISD_UI_pausecomp(millis) 
{
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); } 
	while(curDate-date < millis);
} 

function _ISD_UI_setHomepage(ctrl, url) 
{
	ctrl.style.behavior = 'url(#default#homepage)';
	ctrl.setHomePage(url);
} 
function _ISD_UI_displayRow(recordCount)
{	
	if (0 != recordCount)
	{
		var row = document.getElementById("emailRow");	
		if (row.style.display == '')  
			row.style.display = 'none';	
		else 
			row.style.display = '';
	}
}
function _ISD_UI_printUserReport(recordCount)
{
	if (0 != recordCount)
	{
		var href = 'UserReportPrint.aspx';
		var left = (window.screen.width-900)/2;
		var top = (window.screen.height-500)/2;
		var features = 'menubar=0,toolbar=1,status=1' +	',width=900,height=500,left=' + left + ',top=' + top + ',scrollbars=1,resizable=1';
		_ISD_UI_Window_open(href, 'wndView', features);
	}
}
function _ISD_UI_printFeedbackReport(recordCount)
{
	if (0 != recordCount)
	{
		var href = 'FeedbackReportPrint.aspx';
		var left = (window.screen.width-900)/2;
		var top = (window.screen.height-500)/2;
		var features = 'menubar=0,toolbar=1,status=1' +	',width=900,height=500,left=' + left + ',top=' + top + ',scrollbars=1,resizable=1';
		_ISD_UI_Window_open(href, 'wndView', features);
	}
}
function _ISD_UI_printYDirectorateReport(recordCount)
{
	if (0 != recordCount)
	{
		var href = 'YDirectorateReportPrint.aspx';
		var left = (window.screen.width-900)/2;
		var top = (window.screen.height-500)/2;
		var features = 'menubar=0,toolbar=1,status=1' +	',width=900,height=500,left=' + left + ',top=' + top + ',scrollbars=1,resizable=1';
		_ISD_UI_Window_open(href, 'wndView', features);
	}
}
function _ISD_UI_printYCenterReport(recordCount)
{
	if (0 != recordCount)
	{
		var href = 'YCenterReportPrint.aspx';
		var left = (window.screen.width-900)/2;
		var top = (window.screen.height-500)/2;
		var features = 'menubar=0,toolbar=1,status=1' +	',width=900,height=500,left=' + left + ',top=' + top + ',scrollbars=1,resizable=1';
		_ISD_UI_Window_open(href, 'wndView', features);
	}
}
function _ISD_UI_printYClubReport(recordCount)
{
	if (0 != recordCount)
	{
		var href = 'YClubReportPrint.aspx';
		var left = (window.screen.width-900)/2;
		var top = (window.screen.height-500)/2;
		var features = 'menubar=0,toolbar=1,status=1' +	',width=900,height=500,left=' + left + ',top=' + top + ',scrollbars=1,resizable=1';
		_ISD_UI_Window_open(href, 'wndView', features);
	}
}
