var gblPageStatus = "";


function ChangePageStatus(status)
{
    gblPageStatus = status;
}
 var gblChangeHour = true; 
    function ChangeCursor(cursorType)
    {
        try
        {
            if (cursorType == "HOUR")
            {
                if (gblChangeHour)
                   ShowLoadingPopUp();
            }
            else if (cursorType == "DEFAULT")
            {
                    ChangeCurrentAction("");
                    HideLoadingPopUp();
            }
        }
        catch (e){}
    }
        
    function CheckPageStatus()
    {
        if (gblPageStatus == "CHANGED")
            return "Unsaved Record!";
        
        ChangeCursor("HOUR");
    }

<!--
function printPage(divID) 
{
	if(!divID)
	    divID='mainareadiv'
	var da = (document.all) ? 1 : 0;
	var pr = (window.print) ? 1 : 0;
	if(!pr)
		return;
	var printArea = document.getElementById(divID);
	/*if(printArea == null && da) 
		printArea = document.all.mainareadiv;*/
	if(printArea) 
	{
		var sStart = "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/FIFA/CSS/FIFAMaster.css\">" 
		 /*+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>styles/editor.css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>styles/units.css\">" + */
		 + "</head><body onload=\"javascript:window.print();\">";
		sStop = "</body></html>";
		var w = window.open('','printWin','width=650,height=440,scrollbars=yes');
		wdoc = w.document;
		wdoc.open();
		wdoc.write( sStart + printArea.innerHTML ) ;
		wdoc.writeln( sStop );
		wdoc.close();
		w.close();
	}
}

function PrintNews(MainDiv,width,SiteDiv,csspath)
{
      if(!MainDiv)
          MainDiv='mainareadiv'
      var da = (document.all) ? 1 : 0;
      var pr = (window.print) ? 1 : 0;
      if(!pr)
            return;
      var printMainArea = document.getElementById(MainDiv);
      var DivSite = document.getElementById(SiteDiv);
      if(printMainArea) 
      {
    
            var sStart = "<html><head><link rel='stylesheet' type='text/css' href='"+csspath+"'>" 
            +  "<style>#TopLinkArea{display:none}</style>" 
            +  "<style>#BottomLinkArea{display:none}</style>" 
             + "</head><body onload=\"javascript:window.print();window.close();\" style='background-color: #ffffff;text-align: left; padding: 5px 0 0 5px;'>";
            sStop = "</body></html>";
            var w = window.open('','printWin','width='+ width +',height=440,scrollbars=yes');
            
            wdoc = w.document;
            wdoc.open();
            DivSite.style.display="";
            wdoc.write( sStart + printMainArea.innerHTML) ;
            DivSite.style.display="none";
            wdoc.writeln( sStop );
           wdoc.close();

      }
}


function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"")
}
//function  DropDownListUtil()
//{
    var m_SeparatorChar='|';
    var m_AllowDuplicates=false
    function setAllowDuplicates(myVal)
    {
        m_AllowDuplicates=myVal;
    }
    
    function setSeparatorChar(myVal)
    {
        m_SeparatorChar=myVal;
    }
       
    function addValueToList(sourceControlID,targetListID,hiddenControlID,linkTitleID,LinkType)
    {
        var sourceControl=document.getElementById(sourceControlID);
        var targetList=document.getElementById(targetListID);
        var hiddenControl=document.getElementById(hiddenControlID);
        var linkTitle=document.getElementById(linkTitleID);
        var linkType=document.getElementById(LinkType);
        var linkTypeValue;
        if(linkType.checked)
            linkTypeValue='TRUE';
        else
            linkTypeValue='FALSE';
        
        if (sourceControl && targetList && hiddenControl && linkTitle)
        {
           if(sourceControl.value && (trim(sourceControl.value).length)>0 && linkTitle.value && (trim(linkTitle.value).length)>0)
           {
               if(checkDuplicates(targetList,sourceControl.value,linkTitle.value))
               {
                    if(sourceControl.value == "http://")
                    {
                        alert('Invalid URL');
                    }
                    else
                    {
                        targetList[targetList.options.length]=new Option(linkTitle.value,sourceControl.value+m_SeparatorChar+linkTypeValue,false,true);
                        updateHiddenControlFromList(targetList,hiddenControl);
                        sourceControl.value="http://";
                        linkTitle.value="";
                    }
               }
               else
               {
                    alert('Duplicates not allowed');
               }
           }
           else
           {
                alert('You should fill both Url and Link Title');
           }
        }
        return false;
    }
    function removeAllValuesFromList(sourceListID,hiddenControlID)
    {
        var sourceList=document.getElementById(sourceListID);
        var hiddenControl=document.getElementById(hiddenControlID);
        var numberOfOptions=0;
        
        if (sourceList && hiddenControl)
        {
            if(sourceList.options)
            {
                numberOfOptions=sourceList.options.length;
            }
            if(numberOfOptions>0)
            { 
                for(var i=0;i<numberOfOptions;i++)
                    sourceList.options[0]=null;    
                updateHiddenControlFromList(sourceList,hiddenControl);
            }
        }
        EnableDisableUpDown(false);
        return false;
    }
    function removeValueFromList(sourceListID,hiddenControlID)
    {
        var sourceList=document.getElementById(sourceListID);
        var hiddenControl=document.getElementById(hiddenControlID);
        var targetList = document.createElement('select');
        if (sourceList && hiddenControl && (sourceList.selectedIndex>=0))
        {
            var sourceLength = sourceList.options.length;
            var count = 0;
            
            for (var indx = 0; indx < sourceLength; indx++) 
            { 
                if (!sourceList.options[indx].selected)
                { 
                    targetList.options[count]= new Option(sourceList.options[indx].text,
                    sourceList.options[indx].value);
                    count++;
                } 
            } 
            sourceList.options.length = 0;
            for (var newIndx = 0; newIndx < targetList.options.length; newIndx++)
            {
                sourceList.options[newIndx]= new Option(targetList.options[newIndx].text,
                    targetList.options[newIndx].value);
            }
            updateHiddenControlFromList(sourceList,hiddenControl);
        }
        EnableDisableUpDown(false);
        return false;
    }
    function updateHiddenControlFromList(sourceList,hiddenControl)
    {
        var listValues;
        
        for(var i=0;i<sourceList.options.length;i++)
            (!listValues)?(listValues=(sourceList.options[i].text + m_SeparatorChar + sourceList.options[i].value)): (listValues=listValues+m_SeparatorChar + sourceList.options[i].text + m_SeparatorChar + sourceList.options[i].value);
        if(listValues)
            hiddenControl.value=listValues;
        else
            hiddenControl.value="";
    }
    function callJavaScript(chkBoxStatus,sourceListID)
    {
        var selectedStatus=document.getElementById(chkBoxStatus);
        var sourceList=document.getElementById(sourceListID);
        sourceList=sourceList.options[sourceList.options.selectedIndex].value;
        var listValue;
            {
                listValue=sourceList;
            }
            if (listValue)
            {
                listValues=listValue.split(m_SeparatorChar);
                
                if(listValues[1]=="TRUE")
                    selectedStatus.checked=true;
                else
                    selectedStatus.checked=false;
            }
            
    }
    function fillListFromHiddenControl(targetListID,hiddenControlID)
    {
        var targetList=document.getElementById(targetListID);
        var hiddenControl=document.getElementById(hiddenControlID);
        var listValue;
        if(targetList && hiddenControl)
        {
            if(hiddenControl.value)
            {
                listValue=hiddenControl.value;
            }
            if (listValue)
            {
                var listValues=listValue.split(m_SeparatorChar);
                if(listValues.length>0)
                {
                    for(var i=0;i<listValues.length;i+=3)
                    {
                        var j=(i/3);
                        targetList[j]=new Option(listValues[i],listValues[i+1]+m_SeparatorChar+listValues[i+2],false,true);
                     }
                }
            }
        }
    }
    
    function checkDuplicates(sourceList,newUrl,newTitle)
    {
        if (m_AllowDuplicates==true)
            return true;
        else
        {
           for(var i=0;i<sourceList.options.length;i++)
           {
                if ((sourceList.options[i].text==newTitle )|| (sourceList.options[i].value==newUrl))
                {
                    return false;
                }
            }
            return true;
        }
    }
    
    function MoveBetweenListBoxes(ctrlSource, ctrlTarget,ctrlHidden) 
    {
        var Source = document.getElementById(ctrlSource);
        var Target = document.getElementById(ctrlTarget);
        

        if ((Source != null) && (Target != null)) {
            while ( Source.options.selectedIndex >= 0 ) {
                var newOption = new Option(); // Create a new instance of ListItem
                newOption.text = Source.options[Source.options.selectedIndex].text;
                newOption.value = Source.options[Source.options.selectedIndex].value;
                
                Target.options[Target.length] = newOption; //Append the item in Target
                Source.remove(Source.options.selectedIndex);  //Remove the item from Source
            }
        }
    }

    function CheckPhoneNumber(e)
    {
        var kc
	    var cc
	    if(window.Event)
		{    
		    kc=e.which
		    cc=e.keyCode
		}
	    else
	    {
		    kc=window.event.keyCode
		    cc=window.event.charCode
		}
	    if(((kc>=48)&&(kc<=57)) || kc==8 || kc==43 || kc==13 
	         || cc==116 || cc==9 || cc==39 || cc==37 || cc==46 || cc==35 ||cc==36)
		    return true;
	    else
		    return false;
    }
    
    function ValidatePhoneNumber(phoneNumber)
    {
        var vPhoneNumber=phoneNumber;
	    if (vPhoneNumber.substring(0,1)!= '+')
	        {
	           return false;
	        }
	    var stripped=vPhoneNumber.substring(1);
	    if(stripped.indexOf('+')!=-1)
	       return false;
        return (!isNaN(parseInt(stripped)));
    }
    function ValidatePostalCode(value)
    {
        var isValidValue = false;
        if (value != "")
        {
            var charValue = new String(value);
            isValidValue = true;
            for (var count =0 ; count < charValue.length; count++)
            {
                var charActive = charValue.charCodeAt(count);
                if (!((charActive >= 97 && charActive <= 122)
                    || (charActive >= 65 && charActive <= 90)
                    || (charActive >= 48 && charActive <= 57)
                    || (charActive == 32)))
                    {
                        isValidValue = false;
                        break;
                    }
            }
        }
        return isValidValue;
    }
    function ValidatePOBox(value)
    {
        var isValidValue = false;
        if (value != "")
        {
            var charValue = new String(value);
            isValidValue = true;
            for (var count =0 ; count < charValue.length; count++)
            {
                var charActive = charValue.charCodeAt(count);
                if (!((charActive >= 97 && charActive <= 122)
                    || (charActive >= 65 && charActive <= 90)
                    || (charActive >= 48 && charActive <= 57)
                    || (charActive == 32)))
                    {
                        isValidValue = false;
                        break;
                    }
            }
        }
        return isValidValue;
    }
    function checkBrowserTypes()
    {
     // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    //this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6    = ((this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie    = ((this.major == 4) && (agt.indexOf("msie 6.")!=-1) || (agt.indexOf("msie 7.")!=-1));
    }
    function isIE6()
    {
        if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && 
                (parseInt(navigator.appVersion)==3))
        {
            isIE3Mac = true;
            return false;
        }
        else
        {   
            is = new checkBrowserTypes(); 
            return is.ie6;
        }
    }
    function isIE()
    {
        if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && 
                (parseInt(navigator.appVersion)==3))
        {
            isIE3Mac = true;
            return false;
        }
        else
        {   
            is = new checkBrowserTypes(); 
            return is.ie;
        }
    }

    function clearClipBoardData()
    {
        if(window.clipboardData)
        {
            window.clipboardData.setData('text','');
        }
        else
        {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") 
            var copytext = ''; 
            var str = Components.classes["@mozilla.org/supports-string;1"]. 
                             createInstance(Components.interfaces.nsISupportsString); 
            if (!str) return false; 
            str.data = copytext; 

        }
    }
    
    
// added to check the length of textarea    
function fnCheckKeyLen(objCtl, strLength,lblID)
{
  var intMaxLen, intCharTyped, intAllowChar;
  intMaxLen = parseInt(strLength);
  intCharTyped = parseInt(objCtl.value.length);
  vLabelId=objCtl.id.replace('_' + lblID,'') + '_' + 'lblSnapShotCounter';
  var oLabel=document.getElementById(vLabelId);
  if (event.keyCode == 18)
    event.returnValue = false;
  if (event.keyCode != 8 || event.keyCode != 46)
    intAllowChar = intMaxLen - intCharTyped;
  if (intAllowChar == 0)
  {
    intCharTyped = parseInt(objCtl.value.length);
    intAllowChar = intMaxLen - intCharTyped;
    event.keyCode ==0;
    if (event.keyCode != 8 && event.keyCode != 46)
    {
    
      event.returnValue = false;
       
          //alert(event.keyCode);
       }
    else
    {
      event.returnValue = true;
      intCharTyped = parseInt(objCtl.value.length);
      intAllowChar = intMaxLen - intCharTyped + 1;
    }
    objCtl.focus();
  }
  else
  {
    event.returnValue = true;
    intCharTyped = parseInt(objCtl.value.length);
    if (event.keyCode != 8 && event.keyCode != 46)
      intAllowChar = intMaxLen - intCharTyped;
    else
      intAllowChar = intMaxLen - intCharTyped;
  }
  if (intAllowChar < 0)
    objCtl.value = objCtl.value.substr(0, parseInt(strLength));
    if(oLabel)
        oLabel.innerHTML='<br>' +  '<i> Number of Characters typed : '  + intCharTyped + '</i>';        //
        
}

//Added for Related Articles
function SelectImageLink(myControlId)
{
  debugger
  PropertyUrl_DoPickup(myControlId,130);
  return false;
}
//Added for Related Articles

   
    function getScrollHeight()
    {
        var h = window.pageYOffset ||
        document.body.scrollTop ||
        document.documentElement.scrollTop;
        return h ? h : 0;
    }
    
    function CheckNumber(e)
    {
        var kc
	    var cc
	    if(window.Event)
		{    
		    kc=e.which
		    cc=e.keyCode
		}
	    else
	    {
		    kc=window.event.keyCode
		    cc=window.event.charCode
		}
	    if(((kc>=48)&&(kc<=57)) || kc==8 || kc==13 
	         || cc==116 || cc==9 || cc==39 || cc==37 || cc==46 || cc==35 ||cc==36)
		    return true;
	    else
		    return false;
    }
    //Added for MySettings - Quicklinks CR
 
    function hasOptions(obj) 
    {       
        if (obj!=null && obj.options!=null)
        { 
            return true; 
        }
        return false;
    }

    function swapOptions(obj,i,j) 
    {       
        var o = obj.options;
        var i_selected = o[i].selected;
        var j_selected = o[j].selected;
        var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
        var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
        o[i] = temp2;
        o[j] = temp;
        o[i].selected = j_selected;
        o[j].selected = i_selected;
    }
    
    function moveOptionUp(sourceControlID,hiddenControlID,divErrorMsg,duplicateID,requiredMessageID,moveUpMessageID,moveDownMessageID,btnMoveUpID,TitleMand,URLMand) 
    {   
        var sourceList=document.getElementById(sourceControlID);           
        var hiddenControl=document.getElementById(hiddenControlID);     
        var oDivErrorMsg=document.getElementById(divErrorMsg);
        var oDuplicate=document.getElementById(duplicateID); 
        var oRequiredMessage=document.getElementById(requiredMessageID);
        var oMoveUpMessage=document.getElementById(moveUpMessageID);
        var oMoveDownMessage=document.getElementById(moveDownMessageID);        
        var obtnMoveUpID=document.getElementById(btnMoveUpID);                              
        var ospnTitle = document.getElementById(TitleMand); 
        var ospnURL = document.getElementById(URLMand); 
        
        oRequiredMessage.style.display="none";
        oDuplicate.style.display="none";
        oMoveUpMessage.style.display="none";        
        oMoveDownMessage.style.display="none";
        oDivErrorMsg.style.display="none"; 
        obtnMoveUpID.style.cursor="hand";                   
        ospnTitle.style.display="none";             
        ospnURL.style.display="none";
        
        if (!hasOptions(sourceList)) { return; }        
        if(sourceList.selectedIndex == -1)
        {   
            oMoveUpMessage.style.display="";              
            oDivErrorMsg.style.display="";
        }
        if(sourceList.selectedIndex == 0)
        {
            obtnMoveUpID.style.cursor="default";            
        }
        for (i=0; i<sourceList.options.length; i++) 
        {
           if (sourceList.options[i].selected) 
           {
            if ((i != 0) && (!sourceList.options[i-1].selected)) 
               {
                    swapOptions(sourceList,i,i-1);
                    sourceList.options[i-1].selected = true;
               }
            }
         }
       updateHiddenControlFromList(sourceList,hiddenControl);
       return false;
     }
           
    function moveOptionDown(sourceControlID,hiddenControlID,divErrorMsg,duplicateID,requiredMessageID,moveUpMessageID,moveDownMessageID,btnMoveDownID,TitleMand,URLMand) 
    {   
        var sourceList=document.getElementById(sourceControlID);                                
        var hiddenControl=document.getElementById(hiddenControlID);     
        var oDivErrorMsg=document.getElementById(divErrorMsg);
        var oDuplicate=document.getElementById(duplicateID); 
        var oRequiredMessage=document.getElementById(requiredMessageID);
        var oMoveUpMessage=document.getElementById(moveUpMessageID);
        var oMoveDownMessage=document.getElementById(moveDownMessageID);
        var obtnMoveDownID=document.getElementById(btnMoveDownID);     
        var ospnTitle = document.getElementById(TitleMand); 
        var ospnURL = document.getElementById(URLMand); 


        oRequiredMessage.style.display="none";
        oDuplicate.style.display="none";
        oMoveUpMessage.style.display="none";        
        oMoveDownMessage.style.display="none";
        oDivErrorMsg.style.display="none"; 
        obtnMoveDownID.style.cursor="hand";        
        ospnTitle.style.display="none";                  
        ospnURL.style.display="none";
         
         if (!hasOptions(sourceList)) { return; }
         if(sourceList.selectedIndex == -1)
         {
            oMoveDownMessage.style.display="";              
            oDivErrorMsg.style.display="";
         }
         if(sourceList.selectedIndex == sourceList.options.length-1)
         {
            obtnMoveDownID.style.cursor="default";            
         }
         for (i=sourceList.options.length-1; i>=0; i--) 
         {
           if (sourceList.options[i].selected) 
           {
               if (i != (sourceList.options.length-1) && ! sourceList.options[i+1].selected) 
               {
                   swapOptions(sourceList,i,i+1);
                   sourceList.options[i+1].selected = true;
               }
           }
         }
         updateHiddenControlFromList(sourceList,hiddenControl);
         return false;
    }
    
//Will return true if the value has a-z, A-Z
function CheckForAlphaChar(value)
{
    var isValidValue = false;
    if (value != "")
    {
        var charValue = new String(value);
        isValidValue = true;
        for (var count =0 ; count < charValue.length; count++)
        {
            var charActive = charValue.charCodeAt(count);
            if (!((charActive >= 97 && charActive <= 122)
                || (charActive >= 65 && charActive <= 90)))
                {
                    isValidValue = false;
                    break;
                }
        }
    }
    return isValidValue;
}

//Will return Alpha Character(a-z, A-Z) Count
function CheckForAlphaCharCount(value)
{
    var AlphaCharCount=0;
    if (value != "")
    {
        var charValue = new String(value);
        for (var count =0 ; count < charValue.length; count++)
        {
            var charActive = charValue.charAt(count);
            if (CheckForAlphaChar(charActive)==true)
                AlphaCharCount++;
        }
    }
    return AlphaCharCount;
}
    //Validate function for strong password
    function ValidatePassword(pwd)
    {
        var strPwd = new String(pwd);
        if (strPwd.length < 8)
            return false;
        
        var pwdCount;
        var lower = false;
        var upper = false;
        var num = false;
        var spl = false;
        var validChar = 0;
        var invalidCount = 0;
        for (pwdCount = 0; pwdCount < strPwd.length; pwdCount++)
        {
            var charPwd = strPwd.charCodeAt(pwdCount);
            if (charPwd >= 97 && charPwd <=122)
            {
                if (!lower)
                {
                    lower = true;
                    validChar++;
                }
            }
            else if (charPwd >= 65 && charPwd <=90)
            {
                if (!upper)
                {
                    upper = true;
                    validChar++;
                }
            }
            else if (charPwd >= 48 && charPwd <= 57)
            {
                if (!num)
                {
                    num = true;
                    validChar++;
                }
            }
            else if (charPwd == 33 || charPwd == 64 || charPwd == 36 // ! @ $
                     || charPwd == 95 || charPwd == 94 || charPwd == 38) // _ ^ &
           {
                if (!spl)
                {
                    spl = true;
                    validChar++;
                }
            }
            else
                invalidCount++;
        }
        if (invalidCount != 0)
            return false;
        else if ((upper && lower) && (num || spl))
            return true;
        else
            return false;
    }
    function ValidateEmailChar(emailID)
   {
      var vEmailid=new  String(emailID);
      vEmailid=vEmailid.toUpperCase();
      var count= vEmailid.length;
      var cc=0
      for (var i=0; i<count;i++)
      {  
         cc=vEmailid.charCodeAt(i);
       
         if(((cc<64)||(cc>90)))
         {   
          if(((cc<48)||(cc>57)))
          {
          if(cc!=183 && cc!=45 && cc!=95 && cc!=46 )
          {     
           return false;
          }
          }
         }
	  }
	     
        return true;     
   }
   
    //Setting focus to an element
    function ScrollToElement(theElement)
    {
        try
        {
            var selectedPosX = 0;
            var selectedPosY = 0;             
            while(theElement != null)
            {
                selectedPosX += theElement.offsetLeft;
                selectedPosY += theElement.offsetTop;
                theElement = theElement.offsetParent
            }
            window.scrollTo(selectedPosX,selectedPosY);
        }
        catch (e)
        {}
    }