﻿function CheckValidateDate(day, month, year) {
    var value;
    var str;
    str = month + "/" + day + "/" + year;
    value = new Date(str);
    if (value.getDate() != day)
        return (false);
    if (value.getMonth() != (month - 1))
        return (false);
    if (value.getFullYear() != year)
        return (false);
    return (true);
}

function textCounter(elmID,spanID,maxlimit){
            elmID = document.getElementById(elmID);
            spanID = document.getElementById(spanID);
            if (elmID.value.length > maxlimit) // if too long...trim it!

                        elmID.value = elmID.value.substring(0, maxlimit);

                        // otherwise, update 'characters left' counter

            else

                        spanID.innerHTML = maxlimit - elmID.value.length;

}
function ValidateInput(sender,args)
{
        var str=args.Value;
		var cntr;
		var isAllCap;
		for(cntr=0;cntr<str.length;cntr=cntr+1)
		{
			var character=str.charAt(cntr);
			if((character.charCodeAt(0)>64) && (character.charCodeAt(0)<91)||(character.charCodeAt(0)==32))
			{
					isAllCap=true;
			}
			else
			{
					isAllCap=false;
					break;
			}
		}
		if(isAllCap==true)
		{
			args.IsValid=false;
			return;
		}
		else
		{
			args.IsValid=true;
		}
}

function OpenPopup(tbl)
		{
		        document.getElementById("span_Title").innerHTML="Add "+ tbl;
		        document.getElementById("span_heading").innerHTML=tbl;
		        document.getElementById("ctl00_ContentPlaceHolder1_hdn_Add").value=tbl;
		        document.getElementById("ctl00_ContentPlaceHolder1_txt_Add").value='';
		        		        
					var obj =document.getElementById("AddNew_Popup");
    				var outerObj=document.getElementById("AddNew_Popup_Outer");
					obj.style.left=(screen.availWidth/2)-(500/2)+"px";
    				obj.style.top=(screen.availHeight/2)-(250/2)+"px";
    				obj.style.display="block";
    				
    				outerObj.style.width=document.body.scrollWidth+"px";
    				outerObj.style.height=document.body.scrollHeight+"px";
    				outerObj.style.display="block";
				
		}
		function ClosePopup()
		{
					var obj =document.getElementById("AddNew_Popup");
    				var outerObj=document.getElementById("AddNew_Popup_Outer");
    				outerObj.style.display="none";
    				obj.style.display="none";
		}
		
function noPostBack(sNewFormAction)
{
    document.forms[0].action = sNewFormAction;
    document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
}
function printPartOfPage(elementId)
{
 var printContent = document.getElementById(elementId);
 var windowUrl = 'about:blank';
 var uniqueName = new Date();
 var windowName = 'Print' + uniqueName.getTime();
 var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0,resizable=yes,scrollbars=yes');
 printWindow.document.write("<link rel='stylesheet' type='text/css' href='/css/styles_print.css'/>" );
 
 printWindow.document.write(printContent.innerHTML);
 printWindow.document.close();
 printWindow.focus();
 printWindow.print();
 printWindow.close();
}

function OpenLoginPopup()
		{
					var obj =document.getElementById("Login_Popup");
    				var outerObj=document.getElementById("Login_Popup_Outer");
					obj.style.left=(screen.availWidth/2)-(500/2)+"px";
    				obj.style.top=(screen.availHeight/2)-(50/2)+"px";
    				obj.style.display="block";
    				
    				outerObj.style.width=document.body.scrollWidth+"px";
    				outerObj.style.height=document.body.scrollHeight+"px";
    				outerObj.style.display="block";
				
		}
		function CloseLoginPopup()
		{
					var obj =document.getElementById("Login_Popup");
    				var outerObj=document.getElementById("Login_Popup_Outer");
    				outerObj.style.display="none";
    				obj.style.display="none";
		}
