﻿    function ReloadTabs()
    {
        //GetRadWindow().BrowserWindow.location.reload();
        __doPostBack('ctl00$mpContentHolder$RadTabLeft','ctl00$mpContentHolder$RadTabLeft$Tab1');
        
        // Highlight the section yellow (YFT)
        window.setTimeout('ShowMessage("The credit has been transferred to the clinic.")', 2000);

        // clear quick transfer form
        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_ddlQuickCredit_Clinic_Input').value = '';
        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_ddlQuickCredit_ClinicUser_Input').value = '';
        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_txtCreditXFER_Amount_text').value = '';
        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_txtCreditXFER_Reason_text').value = '';
    }
    
//    function FadeYellow()
//    {
//        
//        // Reset fields
//        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_ddlQuickCredit_Clinic_Input').SetValue('');
//        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_ddlQuickCredit_ClinicUser_Input').SetValue('');
//        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_txtCreditXFER_Amount_text').SetValue('');
//        document.getElementById('ctl00_mpContentHolder_QuickCreditTransfer1_txtCreditXFER_Reason_text').SetValue('');
//    
//        // Highlight the section yellow (YFT)
////        var div1 = document.getElementById('ctl00_mpContentHolder_page_credits');
////        new Effect.Highlight(div1, {startcolor: '#ffff00', restorecolor: 'true'});
//        
////        var div2 = document.getElementById('ctl00_mpContentHolder_page_clinics');
////        new Effect.Highlight(div2, {startcolor: '#ffff00', restorecolor: 'true'});       
////        
////        var div3 = document.getElementById('ctl00_mpContentHolder_RadGridClinic');
////        new Effect.Highlight(div3, {startcolor: '#ffff00', restorecolor: 'true'});        
////                
////        var div4 = document.getElementById('ctl00_mpContentHolder_RadTabLeft_Tab1');
////        new Effect.Highlight(div4, {startcolor: '#ffff00', restorecolor: 'true'}); 
//            
//        ShowMessage('Client')
//        
//    }
    
    function ShowMessage(MessageText)
    {
	    var YScroll;
	    if (navigator.appName == "Microsoft Internet Explorer")
    	    YScroll = document.body.scrollTop;
        else 
		    YScroll = window.pageYOffset;    
    
        var imgSearchImage = document.getElementById('imgSearchImage')
        var divMessage = document.getElementById('divShowMessageWrapper')
        var w = document.body.clientWidth;
        
        divMessage.style.display = 'none';
        divMessage.style.height = '40px';   
        divMessage.style.width = '200px';
        
        if (YScroll > 83)
        {
            divMessage.style.top = 83 + (YScroll - 83);
        }
        else
        {
            divMessage.style.top = 83;
        }
        divMessage.style.left = w - 225;
        document.getElementById('divShowMessage').innerHTML = '<div>' + MessageText + '</div>';
        
       divMessage.style.display = 'block';
       //alert(divMessage.innerHTML);
       //var obj = new Fx.Slide('divShowMessage', {mode: 'vertical'});
       //alert(obj);
       //obj.show();
        /*new Effect.Appear(divMessage)
        new Effect.SlideDown(divMessage)
       */ 
        window.setTimeout('HideMessage()', 3000);
        
    }  
    
    function HideMessage()
    {
        //var divMessage = document.getElementById('divShowMessage')
        /*new Effect.Fade(divMessage)
        new Effect.SlideUp(divMessage)           */
        document.getElementById('divShowMessageWrapper').style.display = 'none';
       // var obj = new Fx.Slide('divShowMessage', {mode: 'vertical'});
        // obj.slideOut();
    }
    
    function ShowSearchBox()
    {
        var divSearchBox = document.getElementById('divSearchBox')
        divSearchBox.style.display='block';
        //new Effect.Appear(divSearchBox)
    }




/*************************************************************************************
  FOLLOWING ROUTINES ARE HELPER ROUTINES - THEY SHOULD BE INITIATED VIA "checkForm()"
*************************************************************************************/       
//------------------------------------------------------------------------------------
//isEmpty(): Validate that the form element is not null and not zero length string
//------------------------------------------------------------------------------------
function isEmpty(elemObj)
{            
    var sData = jsTrim(new String(elemObj.value));
    return (sData.length == 0);   
} 

//------------------------------------------------------------------------------------
//jsTrim(): Perform a trim on the passed string, so that empty/null chars are removed
//------------------------------------------------------------------------------------        
function jsTrim(stringVal)
{
    var reLeft  = /\s*((\S+\s*)*)/;
    var reRight = /((\s*\S+)*)\s*/;
    
    stringVal = stringVal.replace(reLeft, "$1");  //Trim leading blanks      
    stringVal = stringVal.replace(reRight, "$1"); //Trim trailing blanks
    
    return stringVal;
}

//------------------------------------------------------------------------------------
//isEmail(): Validate that Email is formatted correctly, at least two chars before @,
//           and 2 chars after the period (allowing for .fr, .pe, .jp.... domains)
//------------------------------------------------------------------------------------
function isEmail(stringVal)
{            
    return ((stringVal.indexOf(".") > 2) && (stringVal.indexOf("@") > 1));   
} 


//------------------------------------------------------------------------------------
//Validate numeric value
//------------------------------------------------------------------------------------
function CheckNumeric(event)
{
    if((!(event.keyCode>=48 && event.keyCode<=57))  && (event.keyCode != 13) )
    {    
        event.keyCode=0;     return false;
    }else{
        return true;
    }
}

//------------------------------------------------------------------------------------
//For home page/front facing page mouseover
//------------------------------------------------------------------------------------
function MM_preloadImages() 
{ //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() 
{ //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//------------------------------------------------------------------------------------
// Yellow fade technique
//------------------------------------------------------------------------------------
var yft = {
    _shade: {1:'ff', 2:'ee', 3:'dd', 4:'cc', 5:'bb', 6:'aa', 7:'99'},
    _shadeTxt: {1:'77', 2:'55', 3:'44', 4:'33', 5:'22', 6:'11', 7:'00'},
    fadeIn: function(e,i) 
    {
        if (i >= 1) 
        {
            var elem = $(e)
            if(elem)
            { 
                elem.style.color = '#0000' + this._shadeTxt[i];
                elem.style.backgroundColor = '#ffff' + this._shade[i];
                elem.style.border = "solid 1px #e0e0e0";
            }else{                            
                return;
            }
            if (i > 1) 
            {
                i -= 1;
                setTimeout("yft.fadeIn('"+elem.id+"',"+i+")", 500);
            }else{
                i -= 1;
                setTimeout("yft.fadeIn('"+elem.id+"',"+i+")", 500);
                elem.style.backgroundColor = "transparent";
                elem.style.border = "solid 1px #ffffff";
                setTimeout("$('"+elem.id+"').innerHTML = ''",5);
            }
        }
    }
}

//These return the X & Y position of any object
function getY(obj){
	return (obj.offsetParent ? obj.offsetTop + getY(obj.offsetParent) : obj.y ? obj.y : 0);
}
function getX(obj){
	return obj.offsetLeft + (obj.offsetParent ? getX(obj.offsetParent) : obj.x ? obj.x : 0);
}

function ShowSearchBox(index,objClearButtonName)
{
    var SearchButton = document.getElementById('SearchButton'+index);
    var SearchBox = document.getElementById('SearchBox'+index);
    if(SearchButton !=null && SearchBox !=null)
    {
        if (SearchBox.style.display == '' || SearchBox.style.display == 'block')
        {
            HideSearchBox(index);
            //document.getElementById(objClearButtonName).click();
            __doPostBack(objClearButtonName,'');
            return;
        }
            
        var x = getX(SearchButton);
        var y = getY(SearchButton);
//        SearchBox.style.display='none';
       
        if (navigator.appName == "Microsoft Internet Explorer")
        {
    	    SearchBox.style.left = x - 130;
            SearchBox.style.top= y + 20;  
            //new Effect.Grow(SearchBox,{duration:0.2})  
    	}    
        else 
        {
            SearchBox.style.left = x - 124;
            SearchBox.style.top= y + 19;  
            //new Effect.Grow(SearchBox,{duration:0.2}) 
        }
        SearchBox.style.display='block';
    }
}
    
    
function HideSearchBox(index)
{
    var SearchBox = document.getElementById('SearchBox'+index);
    if(SearchBox !=null)
    {
        //new Effect.Hide(SearchBox,{duration:0.15})  
        SearchBox.style.display = 'none';
    }
}
