﻿var szCntrlTd="";
var vLang = "",vFlag="";

function init(vpath)
{	
    service.useService(""+vpath+"/Common/WebService/Akrebeia.asmx?WSDL","svcSendMail");				
    service.useService(""+vpath+"/Common/WebService/Akrebeia.asmx?WSDL","svcDelete");
    service.useService(""+vpath+"/Common/WebService/Akrebeia.asmx?WSDL","svcTemplate");
}

function BuilDDListTemplate(szMainControl,szControlID,szControlColumn,gszLang,szFlag)
{  	
    vFlag=szFlag;
	var szDefaultText="";
	var szDefaultValue="";
	var szSelectedIndex="";
	if(document.getElementById(szControlID)!=null)
	    szSelectedIndex=document.getElementById(szControlID).value;
	var szConnectionString="CONNECTIONSTRING";
	szCntrlTd=szControlColumn;
	var szSQL="SELECT_L_TEMPLATE_REL";	
	var szSqlSubstitute1=document.getElementById("ctl00_cphWorkspace_"+szMainControl+"").value;
	var szcssClass="";
	iCallID = service.svcTemplate.callService(DisplayDDList,"BuilDDList",szControlID,szDefaultText,szDefaultValue, szSelectedIndex,szSQL,szSqlSubstitute1, szcssClass,gszLang,"",1);
		
}
function DisplayDDList(result)
{
	if (iCallID != result.id)	
		return;
	if(result.error)
	{
	    // Pull the error information from the event.result.errorDetail properties
        var faultCode   = result.errorDetail.code;
		var faultString = result.errorDetail.string;		
		alert("ERROR: Code = " + faultCode + ", Fault String=" + faultString);		
     }
     else
     {        
     //alert('test');
		var cntrl = eval("ctl00_cphWorkspace_"+szCntrlTd+"");
		cntrl.innerHTML = result.value;	
		if(vFlag=="1")
		    fnSetTemplateUrl();			
	}			
}

function check_form() 
{      		
    var inputs = document.getElementsByTagName('input');	
	for (var i = 0; i < inputs.length; i++) 
	{	
		if (inputs[i].type == 'submit') 
		{				
			inputs[i].style.display = 'none';								
		}
	}		                     
    return true;       
}
function check_formImage() 
{ 
    var inputs = document.getElementsByTagName('input');	
	for (var i = 0; i < inputs.length; i++) 
	{				
		if (inputs[i].type == 'image') 
		{				
			inputs[i].style.display = 'none';							
		}
	}	
	   		                     
    return true;       
}
function CheckAllowedCharacter(oSrc, args)
{
    var szValue = args.Value;        
    if(szValue.indexOf('>')>-1 || szValue.indexOf('<')>-1 || szValue.indexOf('&lt;')>-1 || szValue.indexOf('&gt;')>-1)
        args.IsValid = false;
    else
       args.IsValid = true;
}
function fnGoListing(strPath)
{
    while(strPath.indexOf("%AND%")>-1)
    {
        strPath=strPath.replace("%AND%","&");		
    }
    window.location.href = strPath;
}
function fnApp_changed()
{

    var vAppId=document.getElementById("ctl00_cphWorkspace_txtAppID").value;    
    var vOdlAppId = document.getElementById("ctl00_cphWorkspace_txtOldAppID").value;
    
    if(vOdlAppId=='' || vOdlAppId==null)
    {
        document.getElementById("ctl00_cphWorkspace_txtOldAppID").value= vAppId;
    }
    else
    {
        if(vOdlAppId !=vAppId)
        {
            document.getElementById("ctl00_cphWorkspace_txtParentIndexID").value ='';
            document.getElementById("ctl00_cphWorkspace_txtParentIndexName").value ='';
        }
    
    }
}
function start()
{
    if (document.all) 
        return;
    if (document.getElementById)
    {
        document.getElementById("slider").style.visibility="show";
        ns6marquee(document.getElementById('slider'));
    }
    else if(document.layers)
    {
        document.slider1.visibility="show";
        ns4marquee(document.slider1.document.slider2);
    }
}
function fnSetTemplateUrl()
{
    var vTemplateIDAll=document.getElementById("ctl00_cphWorkspace_txtTEMPLATE_ID").value;
    var vTemplateUrlAll=document.getElementById("ctl00_cphWorkspace_txtTEMPLATE_URL").value;
    var vTemplateID,vTemplateUrl,vURL;
//	alert(document.getElementById("DDLFETemplate").value);
	vTemplateID=vTemplateIDAll.split(",");
	vTemplateUrl=vTemplateUrlAll.split(",");
	for(var i=0; i<vTemplateID.length; i++)
	{						
		if(vTemplateID[i]==document.getElementById("DDLFETemplate").value)
		{
		    vURL=vTemplateUrl[i];
		    break;
		}
	}
	document.getElementById("ctl00_cphWorkspace_txtUrlLink").value = vURL;
/*	if(vURL!="" && vURL!=null)
	{
	    vURL = vURL + "?aID=023&fID=A104&cID=1&No=102";
	                "aNo=1&aID=023&fID=A108&cID=1&No=106";
	                "&Mode=0&aNo=" + szCurrentRecNo + "&aID=" + szAPP_ID + "&fID=" + szFORM_ID + "&cID=" + szCONTROL_ID + "&No=" + szCurrentIndex;
	}*/
}
function fnNavigateToPage(szButton)
{
	var vButton = String(szButton);
	var vPageNo = 1;
	var strPageNo;
	strPageNo = String( strPageNo);
	if( szButton == 'RESET' ) 
	{
		strPageNo = document.getElementById(vName).value;			
		vPageNo = 1;
	}	
	//Previous button pressed
	else if (szButton == 'PREVPAGE' ) 
	{		
		strPageNo = document.getElementById("ctl00_cphWorkspace_GoTo").value;
		if ( strPageNo.length > 0  )
			vPageNo = parseInt(document.getElementById("ctl00_cphWorkspace_GoTo").value) - 1;
		else
			vPageNo = 0;
	}
	//Next button pressed
	else if (szButton == 'NEXTPAGE' ) 
	{	
		strPageNo = document.getElementById("ctl00_cphWorkspace_GoTo").value;
		if ( strPageNo.length > 0  )
			vPageNo = parseInt(strPageNo) + 1;
		else
			vPageNo = 1;
	}
	
	//Increment/Decrement the page count
	strPageNo = String(vPageNo);	
	document.getElementById("ctl00_txtPageCount").value = strPageNo;//.toString();		
	var theForm = document.forms['aspnetForm'];	
	theForm.submit();
}
function fnChangePage()
{	
	document.getElementById("ctl00_txtPageCount").value = document.getElementById("ctl00_cphWorkspace_GoTo").value;
	var theForm = document.forms['aspnetForm'];	
	theForm.submit();
}
function fnDeleteAttachment( vAppID, vFormID, vAttachmentID, vFileID,vFileName,vLang,vMode) 
{ 
    var vUrl = 'FileAttach.aspx?&l='+vLang+'&d=1&ap='+vAppID+'&fr='+vFormID+'&at='+vAttachmentID+'&fi='+vFileID+'&fn='+vFileName+'&Mode='+vMode ;
    window.navigate( vUrl );
}
function fnDelete(szLang,strAppID,strFormID,szID,szID2,strControlID)
{  		
    Lang=szLang;
    if(szLang=="AR" || szLang=="ar")
         var bMsg = window.confirm("هل انت متأكد من الالغاء؟");
    else
        var bMsg = window.confirm("Are you sure you want to delete");
        
	if (bMsg)
	{	
	    iCallID = service.svcDelete.callService(DisplayRes,"fnDelete",szLang,strAppID,strFormID,szID,szID2,strControlID);
	}
}
function DisplayRes(result)
{
	if (iCallID != result.id)	
		return;	
	if(result.error)
	{
	    // Pull the error information from the event.result.errorDetail properties
        var faultCode   = result.errorDetail.code;
		var faultString = result.errorDetail.string;		
		alert("ERROR: Code = " + faultCode + ", Fault String=" + faultString);		
     }
     else
     {       
		var vRec = result.value;
		
		if(vRec!="" && vRec!=null)
		    vRec = parseInt(vRec);				
		
		if( vRec ==0 || vRec =='-1')	
		{
		    if(Lang=="AR" || Lang=="ar")
		        alert('لا يمكن الالغاء لارتباط السجل بحقل آخر');
		    else     
                alert('Cannot Delete Record since it is related to another field');
        }
        else	
        {
           var theForm = document.forms['aspnetForm'];	
	       theForm.submit();
	     }			
	}			
}
function fnValidateMonth(szMonth)
{
    var szMonthValue;
	szMonthValue = document.getElementById(szMonth).value;
	 var szLang = document.getElementById('ctl00_cphWorkspace_txtLang').value;
   if(szMonthValue!="")
   {
         if(szLang== "EN")
			 {
			      if(isNaN(szMonthValue ))
		                 {
		                      alert('Please type a valid Month');
		                      document.getElementById(szMonth).value="";
		                      document.getElementById(szMonth).focus();
		                      return false;
		                  }
                
	            if(szMonthValue < 1 || szMonthValue > 12)
		             {
		                document.getElementById(szMonth).focus();
		                alert('Please type a valid Month');
		                document.getElementById(szMonth).value="";
		                document.getElementById(szMonth).focus();
		                return false;
	                 }
	         } 
	          if(szLang== "AR")
			 {
			      if(isNaN(szMonthValue ))
		                 {
		                      alert('أدخل شهرا صحيحا');
		                      document.getElementById(szMonth).value="";
		                      document.getElementById(szMonth).focus();
		                      return false;
		                  }
			       if(szMonthValue < 1 || szMonthValue > 12)
		             {
		                document.getElementById(szMonth).focus();
		                alert('أدخل شهرا صحيحا');
		                document.getElementById(szMonth).value="";
		               document.getElementById(szMonth).focus();
		                return false;
	                 }
	         } 
	 } 
}
function fnValidateYear(szYear)
{
    var szYearValue;
	szYearValue = document.getElementById(szYear).value;
	 var szLang = document.getElementById('ctl00_cphWorkspace_txtLang').value;
   if(szYearValue!="")
   {
           if(szLang== "EN")
			 {
			     if(isNaN(szYearValue ))
		           {
                          alert('Please type a valid Year');
                          document.getElementById(szYear).value="";
                          document.getElementById(szYear).focus();
                          return false;
		           }
                
		          if(szYearValue < 1900 || szYearValue > 2100)
		            {
		                    document.getElementById(szYear).focus();
		                    alert('Please type a valid Year');
		                    document.getElementById(szYear).value="";
		                    document.getElementById(szYear).focus();
		                    return false;
	                }
	           }
	          if(szLang== "AR")
			 {
			      if(isNaN(szYearValue ))
		               {
                          alert('أدخل سنة صحيحة');
                          document.getElementById(szYear).value="";
                          document.getElementById(szYear).focus();
                          return false;
		               }
                
		          if(szYearValue < 1300 || szYearValue > 1523)
		            {
		                document.getElementById(szYear).focus();
		                alert('أدخل سنة صحيحة');
		                document.getElementById(szYear).value="";
		                document.getElementById(szYear).focus();
		                return false;
	                }
	           }
	 }      
}

	
function fnValidateNumber(szNumber)
{
    var szValue;
	szValue = document.getElementById(szNumber).value;
	 var szLang = document.getElementById('ctl00_cphWorkspace_txtLang').value;
   if(szValue!="")
   {
         if(szLang== "EN")
			 {
			      if(isNaN(szValue ))
		                 {
		                      alert('Please type a Number');
		                      document.getElementById(szNumber).value="";
		                      document.getElementById(szNumber).focus();
		                      return false;
		                  }
	            
	         } 
	          if(szLang== "AR")
			 {
			      if(isNaN(szValue ))
		                 {
		                      alert('أدخل رقما صحيحا');
		                      document.getElementById(szNumber).value="";
		                      document.getElementById(szNumber).focus();
		                      return false;
		                  }
	         } 
	 } 
}
function fnSearch(szSearch,szLogin)
{
   if(szLogin=="1")
   {
        szValue = document.getElementById('ctl02_txtSearch').value;
        if(szValue!= "" && szValue!=null)    
            szValue  = szValue.toUpperCase();
            
        if(szSearch!="" && szSearch!=null)
            szSearch = szSearch.toUpperCase();
        if(szValue==szSearch)
            document.getElementById('ctl02_txtSearch').value ="";
        else if(szValue=="" || szValue==null)
            document.getElementById('ctl02_txtSearch').value =szSearch;
    }
   
    else
    {
        szValue = document.getElementById('ctl00_cphHeader_ctl00_txtSearch').value;
        if(szValue!= "" && szValue!=null)    
            szValue  = szValue.toUpperCase();
            
        if(szSearch!="" && szSearch!=null)
            szSearch = szSearch.toUpperCase();
        if(szValue==szSearch)
            document.getElementById('ctl00_cphHeader_ctl00_txtSearch').value ="";
        else if(szValue=="" || szValue==null)
            document.getElementById('ctl00_cphHeader_ctl00_txtSearch').value =szSearch;
    }
}
function ValidationHijriDate(szDate)
{
	var szYear;
	var szMonth;
	var szDay;
	var szDate;
	
	szDateValue = document.getElementById(szDate).value;
	 var filter=/^(\d{1,2}\/\d{1,2}\/\d{4})$/i;
	 if(szDateValue!='')
    {
	    if(szDateValue.indexOf("&nbsp;") > -1 || szDateValue.indexOf(" ")>-1)
	    {
	        alert('يرجى التحقق من صيغة التاريخ');
	        document.getElementById(szDate).value="";
	    }
	   else if (!filter.test(szDateValue))
        {
           alert('يرجى التحقق من صيغة التاريخ');
           document.getElementById(szDate).value="";
        }
        else
        {
	        var format  = szDateValue.split( "/" );
	        for ( var i = 0; i < format.length; i++ )
	        {
		        if(i==0)
			        szDay=format[0];
		        else if(i==1)
			        szMonth=format[1];
		        else if(i==2)
			        szYear=format[2];				
	        }
	        if(szYear < 1300 || szYear > 1523)
	        {		
		         document.getElementById(szDate).focus();
		         alert('يرجى التحقق من صيغة التاريخ');
		         document.getElementById(szDate).value="";
		         document.getElementById(szDate).focus();
		        return false;
	        }
	        if(szMonth < 1 || szMonth > 12)
	        {
		         document.getElementById(szDate).focus();
		        alert('يرجى التحقق من صيغة التاريخ');
		        document.getElementById(szDate).value="";
		        document.getElementById(szDate).focus();
		        return false;
	        }

	        var vYear = ((11 * parseInt(szYear) + 14) % 30);
	        if( vYear < 11)
	        {
		        if(szMonth=='1' || szMonth=='01' || szMonth=='3' || szMonth=='03' || szMonth=='5' || szMonth=='05' || szMonth=='7' || szMonth=='07' || szMonth=='9' || szMonth=='09' || szMonth=='11' || szMonth=='12')
		        {
			        if (szDay > 30)
			        {
				         document.getElementById(szDate).focus();
				        alert('يرجى التحقق من صيغة التاريخ');
				        document.getElementById(szDate).value="";
				        document.getElementById(szDate).focus();
				        return false;
			        }
		        }
		        if(szMonth=='2' || szMonth=='02' || szMonth=='4' || szMonth=='04' || szMonth=='6' || szMonth=='06' || szMonth=='8' || szMonth=='08' || szMonth=='10')
		        {
			        if (szDay > 29)
			        {
				         document.getElementById(szDate).focus();
				        alert('يرجى التحقق من صيغة التاريخ');
				        document.getElementById(szDate).value="";
				        document.getElementById(szDate).focus();
				        return false;
			        }
		        }
	        }
	        else
	        {
		        if(szMonth=='1' || szMonth=='01' || szMonth=='3' || szMonth=='03' || szMonth=='5' || szMonth=='05' || szMonth=='7' || szMonth=='07' || szMonth=='9' || szMonth=='09' || szMonth=='11')
		        {
			        if (szDay > 30)
			        {
				         document.getElementById(szDate).focus();
				        alert('يرجى التحقق من صيغة التاريخ');
				        document.getElementById(szDate).value="";
				        document.getElementById(szDate).focus();
				        return false;
			        }
		        }
		        if(szMonth=='2' || szMonth=='02' || szMonth=='4' || szMonth=='04' || szMonth=='6' || szMonth=='06' || szMonth=='8' || szMonth=='08' || szMonth=='10' || szMonth=='12')
		        {
			        if (szDay > 29)
			        {
				         document.getElementById(szDate).focus();
				        alert('يرجى التحقق من صيغة التاريخ');
				        document.getElementById(szDate).value="";
				        document.getElementById(szDate).focus();
				        return false;
			        }
		        }
	        }
	    }
	  }
 return true;   
 }

function ValidationGregDate2(szDate)
{	
	var szDate1;
	var szDate2;
	szDate1=  document.getElementById(szDate).value;
		
	if(szDate1.indexOf("&nbsp;") > -1 ||szDate1.indexOf(" ")>-1)
	{
	    alert('Please type a valid date');
	     document.getElementById(szDate).value="";
	     document.getElementById(szDate).value="";
	}	
}


function fnValidateGregDate(szDate)
{
	var szYear;
	var szMonth;
	var szDay;
	var szDate;
	
	szDateValue = document.getElementById(szDate).value;
	var filter=/^(\d{1,2}\/\d{1,2}\/\d{4})$/i;
    if(szDateValue!='')
    {   
	    if(szDateValue.indexOf("&nbsp;") > -1 || szDateValue.indexOf(" ")>-1)
        {
            alert('Please type a valid date');
            document.getElementById(szDate).value="";
        }
        
        else if (!filter.test(szDateValue))
        {
            alert('Please type a valid date');
            document.getElementById(szDate).value="";
        }
         else
         {
            var format  = szDateValue.split( "/" );
            for ( var i = 0; i < format.length; i++ )
            {
                if(i==0)
                    szDay=format[0];
                else if(i==1)
                    szMonth=format[1];
                else if(i==2)
                    szYear=format[2];				
            }
            if(szYear < 1900 || szYear > 2100)
            {
    			
                 document.getElementById(szDate).focus();
                 alert('Please type a valid date');
                 document.getElementById(szDate).value="";
                 document.getElementById(szDate).focus();
                return false;
            }
            if(szMonth < 1 || szMonth > 12)
            {
                 document.getElementById(szDate).focus();
                alert('Please type a valid date');
                document.getElementById(szDate).value="";
                document.getElementById(szDate).focus();
                return false;
            }

            var vYear = ( parseInt(szYear) % 4);
    			
            if( vYear == 0)
            {
                if(szMonth=='2' || szMonth=='02')
                {
                    if (szDay > 29)
                    {
                        document.getElementById(szDate).focus();
                        alert('Please type a valid date');
                        return false;
                    }
                }
                else if(szMonth=='4' || szMonth=='04' || szMonth=='6' || szMonth=='06' || szMonth=='9' || szMonth=='09' || szMonth=='11')
                {
                    if (szDay > 30)
                    {
                        document.getElementById(szDate).focus();
                        alert('Please type a valid date');
                        return false;
                    }
                }
                else
                {
                    if (szDay > 31)
                    {
                        document.getElementById(szDate).focus();
                        alert('Please type a valid date');
                        return false;
                    }
                }
            }
            else
            {
                if(szMonth=='2' || szMonth=='02')
                {
                    if (szDay > 28)
                    {
                        document.getElementById(szDate).focus();
                        alert('Please type a valid date');
                        return false;
                    }
                }
                else if(szMonth=='4' || szMonth=='04' || szMonth=='6' || szMonth=='06' || szMonth=='9' || szMonth=='09' || szMonth=='11')
                {
                    if (szDay > 30)
                    {
                        document.getElementById(szDate).focus();
                        alert('Please type a valid date');
                        return false;
                    }
                }
                else
                {
                    if (szDay > 31)
                    {
                        document.getElementById(szDate).focus();
                        alert('Please type a valid date');
                        return false;
                    }
                }
            }
        } 
    }
    return true;   
}
function fLaunchFormDownload(szVirtualDirectory,szPath)
{
	szFormPath = szVirtualDirectory+"/Common/Forms/Download.aspx?p="+szPath+"";
	window.location.href = szFormPath;
//    window.open(szFormPath,'_blank','width=20,height=20,scrollbars=yes,status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,top=300,left=300');
}
function fnCheckPhone(szSec) 
{
    var test='';
     // Check for correct phone number
    var strPhone=document.getElementById('Phone_'+szSec+'').value;
    var filter=/^(\d*\s*[()-.]*\d*)*$/i;
    if (filter.test(strPhone))
          test='1';
    else
    {   
        alert('You must enter a valid phone number');
        document.getElementById('Phone_'+szSec+'').value='';
    }   
}
function fnCheckEmail(szEmail)
{
    var str=szEmail;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    if (filter.test(str))
        testresults=1;
    else
    {   
        testresults=0;
    }
    return (testresults)
}
function TextField_Length_Validator(vName,vMaxLength)
{   
	var vLength;
	var vValue = document.getElementById(vName).value;
	vLength=vValue.length;
	
	
	if (vLength >= vMaxLength)	
	{			
		document.getElementById(vName).value = vValue.substring(0,vMaxLength);		
	}
}
function fnOtherBusSector()
{
    if(document.getElementById('ctl00_cphWorkspace_lbBusSector').value=="17")
    {
        document.getElementById('ctl00_cphWorkspace_txtBusSector').style.visibility="visible";
        document.getElementById('ctl00_cphWorkspace_txtBusSector').focus();
    }
    else
    {
        document.getElementById('ctl00_cphWorkspace_txtBusSector').style.visibility="hidden";
        document.getElementById('ctl00_cphWorkspace_txtBusSector').value="";
    }
}
function fnListBoxOther(szListBoxID,szTextBoxID,szSelectedValue)
{
    if(document.getElementById(szListBoxID).value==szSelectedValue)
    {
        document.getElementById(szTextBoxID).style.visibility="visible";
        document.getElementById(szTextBoxID).style.display="inline";
        document.getElementById(szTextBoxID).focus();
    }
    else
    {
        document.getElementById(szTextBoxID).style.visibility="hidden";
        document.getElementById(szTextBoxID).style.display="none";
        document.getElementById(szTextBoxID).value="";
    }
}
function fnReset()
{
    document.getElementById('ctl00_cphWorkspace_txtFirstName').value="";
    document.getElementById('ctl00_cphWorkspace_txtLastName').value="";
    document.getElementById('ctl00_cphWorkspace_txtEmail').value="";
    document.getElementById('ctl00_cphWorkspace_txtComments').value="";
    document.getElementById('ctl00_cphWorkspace_txtBusSector').value="";
    document.getElementById('ctl00_cphWorkspace_txtBusSector').readOnly=true;
    document.getElementById('ctl00_cphWorkspace_lbBusSector').value="1";
    document.getElementById('ctl00_cphWorkspace_ddlCountry').value="4";
    return false;
}
function fnCollapseURL(vTitleID,vSectionID)
{ 
	var strValue; 
	var szID = String(vTitleID);
	var szSectionID = String(vSectionID);
	strValue = window.document.all.item( szID.toString()).value;
	
	if ( strValue != '1' )
		{ 	
			window.document.all.item(szSectionID.toString()).style.display = 'none';	
			window.document.all.item(szID.toString()).value = '1';	
		}
	else 
		{ 	
			window.document.all.item(szSectionID.toString()).style.display = '';
			window.document.all.item(szID.toString()).value = '0';	
		} 
}
function ChangeClass(szitem,szstyle)
{
	document.all.item(szitem).className = szstyle;
}
function fnCalendar(vDirectory,vLang,vForm,vdt,vcdt,vt,vFocus)
{    
        
    if(vLang=='EN')
	    window.open(''+vDirectory+'/Common/Forms/Calendar.aspx?frm='+vForm+'&dt='+vdt+'&cdt='+vcdt+'&szFocus='+vFocus+'','_blank',"height=180,width=230,status=yes,toolbar=no,menubar=no,location=no,top=250,left=400");
	else
	    window.open(''+vDirectory+'/Common/Forms/CalendarAr.aspx?frm='+vForm+'&dt='+vdt+'&cdt='+vcdt+'&szFocus='+vFocus+'','_blank',"height=180,width=230,status=yes,toolbar=no,menubar=no,location=no,top=250,left=400"); 
	  
}
//File Attach
function fnCheckFileExist(vMode)
{
    var vArrFile="";
    var vExist=0;
    document.getElementById("txtStatus").value="";
    var vAllFile=document.getElementById("txtFileNameAll").value;
    var vCurrentFile=document.getElementById("filMyFile").value;
    var vCurrentFileName=vCurrentFile.substring(vCurrentFile.lastIndexOf("\\")+1,vCurrentFile.length);
    while(true)
    {
        if(vCurrentFileName.indexOf(" ")!=-1)
            vCurrentFileName = vCurrentFileName.replace(" ","_");
        else
            break;    
    }
                           
    if(vAllFile!="")
    {
        vArrFile=vAllFile.split(",");
        for(var i=0; i<vArrFile.length; i++)
        {
            if(vArrFile[i]==vCurrentFileName)
            {
                vExist=1;
                break;
            }
        }
 //       if(vExist==0 && vMode=="0")        
 //           vAllFile += "," + vCurrentFileName;                   
    }
 //   else if(vMode=="0")
 //   {
 //       vAllFile = vCurrentFileName;
 //   }
    document.getElementById("txtFileNameAll").value=vAllFile;
    
    if(vExist==1)
    {
        var vConfirm = window.confirm("File name already exists. Do you want to replace it?");
	    if (vConfirm)
	    {
	        document.getElementById("txtStatus").value="UPDATE";
		    return true;
		}
	    else
		    return false;
	}
    else
        return true;
}
function fnShowHideStateProv()
{
    var strValue = window.document.all.item("ctl00_cphWorkspace_ddlCountry").value;
    var szUSA = window.document.all.item("ctl00_cphWorkspace_txtUSA_COUNTRY_ID").value;
    var szCanada = window.document.all.item("ctl00_cphWorkspace_txtCANADA_COUNTRY_ID").value;
    if(strValue==szUSA)
    {
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVUSA").style.visibility="visible";
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVUSA").style.display="inline";
        
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVCANADA").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVCANADA").style.display="none";
        
        document.getElementById("ctl00_cphWorkspace_TR_STATEREG").style.visibility="visible";
        document.getElementById("ctl00_cphWorkspace_TR_STATEREG").style.display="inline";
        
        document.getElementById("ctl00_cphWorkspace_TR_ISSUINGSTATE").style.visibility="visible";
        document.getElementById("ctl00_cphWorkspace_TR_ISSUINGSTATE").style.display="inline";
    }
    else if(strValue==szCanada)
    {
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVCANADA").style.visibility="visible";
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVCANADA").style.display="inline";
        
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVUSA").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVUSA").style.display="none";
        
        document.getElementById("ctl00_cphWorkspace_TR_STATEREG").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_STATEREG").style.display="none";
        
        document.getElementById("ctl00_cphWorkspace_TR_ISSUINGSTATE").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_ISSUINGSTATE").style.display="none";
    }
    else
    {
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVUSA").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVUSA").style.display="none";
        
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVCANADA").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_STATEPROVCANADA").style.display="none";
        
        document.getElementById("ctl00_cphWorkspace_TR_STATEREG").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_STATEREG").style.display="none";
        
        document.getElementById("ctl00_cphWorkspace_TR_ISSUINGSTATE").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_ISSUINGSTATE").style.display="none";
    }
}
function ShowRequiredMessage()
{
    if(!Page_ClientValidate())
    {
        document.getElementById("ctl00_cphWorkspace_TR_MESSAGE").style.visibility="visible";
        document.getElementById("ctl00_cphWorkspace_TR_MESSAGE").style.display="inline";
        scroll(0,0);
    }
    else
    {
        document.getElementById("ctl00_cphWorkspace_TR_MESSAGE").style.visibility="hidden";
        document.getElementById("ctl00_cphWorkspace_TR_MESSAGE").style.display="none";
    }
}