﻿//url rewriting postback correction!
// Sys.Application.add_load(function()
//{
//var str= window.location.href.toLowerCase();

//if (str.search(/sppmembers/i)==-1)
//{
//    var form = Sys.WebForms.PageRequestManager.getInstance()._form;
//    form._initialAction = form.action = window.location.href;
//    }
//});
//url rewriting postback correction! 
//function tuneFormAction()
//{
          //           $('#aspnetForm').attr('action', window.location.href );

//}
//  $(document).ready(function () {
// tuneFormAction();
 //                   });

var postback_cause;
var old_pb_label;
var old_pb_val;


 //if (Sys!=undefined &&   Sys!=null && Sys.WebForms!=null && Sys.WebForms.PageRequestManager!=null && Sys.WebForms.PageRequestManager.getInstance() !=null)
// {
//alert('sssssssssssssssssssssssssssss');
//  var prm = Sys.WebForms.PageRequestManager.getInstance();
//  prm.add_initializeRequest(InitializeRequest);
//  prm.add_endRequest(EndRequest);
//}


 Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(function(sender, args) {
       
         if (args._postBackElement!=null)
           {
           postback_cause=$get(args._postBackElement.id);
            if ($('#'+args._postBackElement.id).is("a")) 
              {
               old_pb_label= $('#'+args._postBackElement.id).text();
               $('#'+args._postBackElement.id).text('Please Wait...');
              }
              
             
            if ($('#'+args._postBackElement.id).is("input")) 
              {
              old_pb_val=$('#'+args._postBackElement.id).val();
              $('#'+args._postBackElement.id).val('Please Wait...');   
              }
           
         
           if ((postback_cause.type=="button") || (postback_cause.type=="submit"))
            $('#'+args._postBackElement.id).attr('disabled', 'disabled');
            
            }
 
        
    });


  
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(sender, args) {
        if (args.get_error() == undefined) {
        if (postback_cause!=null)
             {
              if ($('#'+postback_cause.id).is("a") && $('#'+postback_cause.id).text().indexOf("ERROR")==-1  )  $('#'+postback_cause.id).text(old_pb_label);
              if ($('#'+postback_cause.id).is("input") && $('#'+postback_cause.id).val().indexOf("ERROR")==-1)  $('#'+postback_cause.id).val(old_pb_val);
            if ((postback_cause.type=="button") || (postback_cause.type=="submit"))
             $('#'+postback_cause.id).removeAttr('disabled');

             }
        }
    });


      
function CancelAsyncPostBack() {
            if ( Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
               Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
            }
}
        

        
function ProcessStatus()
{
if (window.status) window.status='';
}

        
var maxL = 256;

function txtLimit(txtObj)
{
	if (txtObj.value.length == maxL) return false;
	return true;
}

function txtCount(txtObj,Cnt)
{ 
	objCnt = createObject(Cnt);
	objVal = txtObj.value;
	if (objVal.length > maxL) objVal = objVal.substring(0, maxL);
	if (objCnt) objCnt.innerHTML = maxL - objVal.length;
	return true;
}
function createObject(objId)
{
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}
        
 function SelectThis(v) {
                                // firefox
                                if(document.createRange) {
                                        rangeToSelect = document.createRange();
                                        
rangeToSelect.selectNode(v.firstChild);
                                        curSelect = window.getSelection();
                                        curSelect.addRange(rangeToSelect);
                                        //console.log(this.firstChild);
                                        return false;
                                }
                                // ie
                                if(document.body && 
document.body.createTextRange) {
                                        range = document.body.createTextRange();
                                        range.moveToElementText(v);
                                        range.select();
                                        return false;
                                }
                        }
   		if(document.getElementById) { // IE 5 and up, NS 6 and up
			var upLevel = true;
			}
		else if(document.layers) { // Netscape 4
			var ns4 = true;
			}
		else if(document.all) { // IE 4
			var ie4 = true;
			}

		if(upLevel) {
			var splash = document.getElementById("splashScreen");
			}
		else if(ns4) {
			var splash = document.splashScreen;
			}
		else if(ie4) {
			var splash = document.all.splashScreen;
			}

		function showObject(obj) {
			if (ns4) {
				obj.visibility = "show";
				}
			else if (ie4 || upLevel) {
				obj.style.visibility = "visible";
				}
			}
		function hideObject(obj) {
			if (ns4) {
				obj.visibility = "hide";
				}
			if (ie4 || upLevel) {
				obj.style.visibility = "hidden";
				}
			}
