
 function CheckupObj() 
 { 
    if (isEmpty(document.getElementById('" + txtUsername.ClientID + "')))
    {
       alert('Enter Username!'); 
       return false; 
    }
    if (isEmpty(document.getElementById('" + txtPassword.ClientID + "')))
    {
        alert('Enter Password!'); 
        return false; 
    } 
    if (isEmpty(document.getElementById('" + txtPasswordConfirm.ClientID + "')))
    { 
       alert('Enter Confirm Password!'); 
       return false; 
    } 
    if (document.getElementById('" + txtPassword.ClientID + "').value != document.getElementById('" + txtPasswordConfirm.ClientID + "').value)
    { 
        alert('Confirm Password does not match to Password!'); return false; 
    } 
    return true; 
    } 

 function Homepage()
 {
    <!--
    // in real bits, urls get returned to our script like this:
    // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm

            //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"
            DocURL = document.URL;

            //this is where the http or https will be, as found by searching for :// but skipping the res://
            protocolIndex=DocURL.indexOf("://",4);

            //this finds the ending slash for the domain server
            serverIndex=DocURL.indexOf("/",protocolIndex + 3);

                    //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining
            //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
            //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
            BeginURL=DocURL.indexOf("#",1) + 1;

            urlresult=DocURL.substring(BeginURL,serverIndex);

            //for display, we need to skip after http://, and go to the next slash
            displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);

            InsertElementAnchor(urlresult, displayresult);
 }

    function HtmlEncode(text)
    {
        return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    }

    function TagAttrib(name, value)
    {
        return ' '+name+'="'+HtmlEncode(value)+'"';
    }

    function PrintTag(tagName, needCloseTag, attrib, inner){
        document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
        if (needCloseTag) document.write( '</' + tagName +'>' );
    }

    function URI(href)
    {
        IEVer = window.navigator.appVersion;
        IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

        return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
            encodeURI(href) :
            escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
    }

    function InsertElementAnchor(href, text)
    {
        PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
    }

function AddFormAction(strLink)
{
    var aspnetForm = document.getElementById('aspnetForm');

    if (aspnetForm != null)
    {
        aspnetForm.action = strLink;
    }
}

function CheckupEmail(txtValue, message)
{
    var reg = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");

    if (!txtValue.match(reg))
    {
        alert('Enter correct "' + message + '"!');
        return false;
    }

    return true;
}
function IsCorrectEmail(emailValue)
{
  /*  var reg = new RegExp('^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9].[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$');

    if (!emailValue.match(reg))
    {
        return false;
    }

        return true;*/
    
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(emailValue)) 
	{
	    return true;
	}
	else
	{
	    return false;
	}
  }

        function IsValueInDDLOk(obj) 
		{	
			for(var i = 0; i < obj.length; i++) 
			{
				if(obj[i].selected) 
				{
					if(obj[i].value == "-1") 
					{ 
						obj.selectedIndex = 0;
						return false; 
					}
				} 
			} 
	
			return true; 
		}
		
function isEmpty(obj)
         {
                if (obj.value != '')
                {
                        return false;
                }

                return true;
     }

function isCheck(obj)
         {
                if (obj.checked)
                {
                        return true;
                }

                return false;
     }

function getChar(e)
        {
                if(e.which || e.keyCode)
                {
                        if ((e.which == 13) || (e.keyCode == 13))
                        {
                                return true;
                        }
                }

                return false;
        }

function setFocus(id, e)
        {
                if (getChar(e))
                {
                        document.getElementById(id).focus();
                        return true;
                }

                return false;
        }


var newWin;

function NewWindow(mypage, myname, w, h, tool, status, scroll)
{
    if (!newWin || newWin.closed)
    {
        var winl = (screen.width - w) / 2;
        var wint = (screen.height - h) / 2;
        
        winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',toolbar=' + tool + ',scrollbars=' + scroll + ',status=' + status;
        newWin = window.open(mypage, myname, winprops);
    }
    else
    {
        newWin.focus();
    }
}

        //global request
var req;

function sendPostRequest(url)
        {
                if (window.XMLHttpRequest)
                {
                        try
                        {
                                req = new XMLHttpRequest();
                        }
                        catch (e)
                        {
                                req = false;
                        }
                }
                else if (window.ActiveXObject)
                {
                        try
                        {
                                req = new ActiveXObject("Msxml2.XMLHTTP");
                        }
                        catch (e)
                        {
                                try
                                {
                                        req = new ActiveXObject("Microsoft.XMLHTTP");
                                }
                                catch (e)
                                {
                                        req = false;
                                }
                        }
                }

                if(req)
                {
                        req.onreadystatechange = processReqChange;

                        try
                        {
                                req.open("GET", url, true);
                        }
                        catch (e)
                        {
                                alert(e);
                        }

                        //req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                        req.send(null);
                }
        }

function processReqChange()
        {
                if (req.readyState == 4)
                {
                        if (req.status == 200)
                        {
                                alert(req.responseText);
                        }
                        else
                        {
                                alert("There was a problem retrieving the XML data:\n" + req.statusText);
                                return false;
                        }
                }
        }
        
//     function CheckAll(aspCheckBoxID, objID)
//        {
//            
//            var st = false;
//            

//            var rall = new RegExp(objID);
//			
//			for(i = 0; i < document.all.length; i++) 
//			{
//				elm = document.all[i];
//				
//				if (elm.type == 'checkbox') 
//				{ 
//					if (rall.test(elm.name)) 
//					{ 
//						st = elm.checked;
//					}
//				}
//				
//            }            

//			var re = new RegExp(aspCheckBoxID)  //generated control name starts

//			for(i = 0; i < document.all.length; i++) 
//			{
//				elm = document.all[i];

//				if (elm.type == 'checkbox') 
//				{ 
//					if (re.test(elm.name)) 
//					{ 
//						elm.checked = st;
//					}
//				}
//			}
//			
//			return true;
//        }  
        
function CheckAll(prefix, id)
{
    var chkMain = document.getElementById(id);
    
    for (var i = 0; i < document.forms[0].elements.length; i++)
    {
        var doc = document.forms[0].elements[i];

        if ( doc.name.search( prefix ) > 0)
        { alert(doc);
            if (chkMain.checked)
            {
                doc.checked = true;
            }
            else
            {
                doc.checked = false;            
            }
        }
    }
} 

function JumpToPage(objName) 
{
    var link = $("select#" + objName).val();
    
    if (link != "")
    {    
        window.location.href = link;
    }
}