﻿ // JScript File
//string function
/*31-1-08 govind include this function to validate the emailid and password*/


function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE)
{
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function


function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function resizeIframe(strIframeName)
{     
        var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
        var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
        var currURL = self.parent.location.href;
        var sh = 0;
        if (currURL.indexOf("default.aspx") >= 0 ||currURL.indexOf(".aspx") == -1)
            var obj = self.parent.document.getElementById(strIframeName);
        else
            var obj  = document.getElementById(strIframeName);
        
	    var h = obj.style.height;
	    h = h.substr(0,h.length-2);
	    if(navigator.userAgent.indexOf("Firefox") != -1)
	    {
    	    if (obj.contentDocument || obj.contentDocument.body.offsetHeight) //ns6 syntax
    	    //if (obj.contentDocument && h)
	        { 
		        var sh = obj.contentDocument.body.offsetHeight+FFextraHeight; 
		        //var sh = parseInt(h)+FFextraHeight; 
		    }
		}
	    if (obj.Document && obj.Document.body.scrollHeight) //ie5+ syntax
	    {
		    if (currURL.indexOf("default.aspx") >= 0 ||currURL.indexOf(".aspx") == -1)
		         sh = self.parent.document.getElementById(strIframeName).Document.body.scrollHeight;
		    else
		         sh = document.getElementById(strIframeName).Document.body.scrollHeight;
		}
        if(obj.id=="ContentFrame" || obj.id == "IframeFriend") 
	    {
	        if(sh<296)  //increase the size of iframe to display the content;
              sh=394;
        }
	    //if(sh > h)
	    //{
	    if(sh == 0)
		  sh = 894;
		    var newh = parseInt(sh) - parseInt(h);				
		    newh = newh + parseInt(h);
		    obj.style.height = newh + 'px';
	    //}			
}

function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1)             
            IsNumber = false;
    }        
    return IsNumber;
}

var numb = '0123456789-';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var space = ' ';    
function isValid(parm,val)
{
  if (parm == "") return true;
  for (i=0; i<parm.length; i++) {
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}
function isNum(parm)
{
    return isValid(parm,numb);
}
function isLower(parm) 
{
    return isValid(parm,lwr+space);
}
function isUpper(parm) 
{
    return isValid(parm,upr+space);
}
function isAlpha(parm) 
{
   return isValid(parm,lwr+upr+space);
}
function isAlphanum(parm) 
{
    return isValid(parm,lwr+upr+numb+space);
}
function isAlphaName(parm)
{
    return isValid(parm,lwr+upr+numb+'.'+'_');
}
function isDecimal(parm) 
{
    return isValid(parm,numb+'.');
}
function isURLName(parm)
{
    return isValid(parm,lwr+upr+numb+'_');
}

// JScript File
/* Function to validate an Valid Email address or not */
    function emailCheck (emailStr) 
    {	
		/* The following variable tells the rest of the function whether or not		
		to verify that the address ends in a two-letter country or well-known		
		TLD.  1 means check it, 0 means don't. */
		var checkTLD=1;
		/* The following is the list of known TLDs that an e-mail address must end with. */
         var knownDomsPat=/^(COM|com|NET|net|ORG|org|EDU|edu|INT|int|MIL|mil|GOV|gov|ARPA|arpa|BIZ|biz|AERO|aero|NAME|name|COOP|coop|INFO|info|PRO|pro|MUSEUM|museum)$/;
//    		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */
		var emailPat=/^(.+)@(.+)$/;
		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ] */
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed.*/
		var validChars="\[^\\s" + specialChars + "\]";
		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")";
		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		/* The following string represents an atom (basically a series of non-special characters.) */
		var atom=validChars + '+';
		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")";
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		/* Finally, let's start trying to figure out if the supplied address is valid. */
		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null)
		{
		    /* Too many/few @'s or something; basically, this address doesn't
		    even fit the general mould of a valid e-mail address. */
		   // self.parent.showPopWin('', 400, 100,false,null,"Email address seems incorrect","ctl00_cphMain_txtEmail",1);		   
		    //self.parent.showPopWin('', 400, 100,false,null,"Email address seems incorrect (check @ and .'s)");
		    
		    return "Email address seems incorrect";
		   
        }
        
        var user=matchArray[1];
        var domain=matchArray[2];
        // Start by checking that only basic ASCII characters are in the strings (0-127).
	        for (i=0; i<user.length; i++) 
	        {
		        if (user.charCodeAt(i)>127) 
		        {
			      //  self.parent.showPopWin('', 400, 100,false,null,"Email address seems incorrect","ctl00_cphMain_txtEmail",1);		   			       
			        return "Email address seems incorrect"
		        }
	        }
	        for (i=0; i<domain.length; i++) 
	        {
		        if (domain.charCodeAt(i)>127)
		        {
			        //self.parent.showPopWin('', 400, 100,false,null,"Ths domain name contains invalid characters.","ctl00_cphMain_txtEmail",1);		   			        
			        return "Ths domain name contains invalid characters."
	           }
	         }
            // See if "user" is valid 

	            if (user.match(userPat)==null) 
	            {
	            // user is not valid	
		         //   self.parent.showPopWin('', 400, 100,false,null,"The username doesn't seem to be valid.","ctl00_cphMain_txtUserName",1);		   		            	
		            return "The username doesn't seem to be valid."
	            }
	            /* if the e-mail address is at an IP address (as opposed to a symbolic	
	            host name) make sure the IP address is valid. */
	            var IPArray=domain.match(ipDomainPat);
	            if (IPArray!=null)
	             {
		            // this is an IP address
		            for (var i=1;i<=4;i++) 
		            {
			            if (IPArray[i]>255) 
			            {
				            self.parent.showPopWin('', 400,100,false,null,"Destination IP address is invalid!");
				            return false;
			             }
		             }
                        return true;

            }
            
            // Domain is symbolic name.  Check if it's valid.
            var atomPat=new RegExp("^" + atom + "$");
            var domArr=domain.split(".");
            var len=domArr.length;
            for (i=0;i<len;i++) 
            {
            if (domArr[i].search(atomPat)==-1) 
            {
	           // self.parent.showPopWin('', 400,100,false,null,"The domain name does not seem to be valid.","ctl00_cphMain_txtEmail",1);
	            return "The domain name does not seem to be valid.";
               }

            }
        /* domain name seems valid, but now make sure that it ends in a

        known top-level domain (like com, edu, gov) or a two-letter word,

        representing country (uk, nl), and that there's a hostname preceding 

        the domain or country. */

        if (checkTLD && domArr[domArr.length-1].length!=2 &&  domArr[domArr.length-1].search(knownDomsPat)==-1) 
        {
         //   self.parent.showPopWin('', 400,100,false,null,"The address must end in a well-known domain or two letter country","ctl00_cphMain_txtEmail",1);
            return "The address must end in a well-known domain or two letter country";
        }
        
        // Make sure there's a host name preceding the domain.
        if (len<2) 
        {
          //  self.parent.showPopWin('', 400,100,false,null,"This address is missing a hostname!","ctl00_cphMain_txtEmail",1);
            return "This address is missing a hostname!";
        }
        
        // If we've gotten this far, everything's valid!
        return true;

}

//  End -->

// MaxLength for Multiline textArea control STARTS HERE
// JScript File for TextArea
// Keep user from entering more than maxLength characters
function doKeypress(control)
{
    maxLength = control.attributes["maxLength"].value;    
    value = control.value;
     if(maxLength && value.length > maxLength-1)
     {
        if(window.event) //IE
          event.returnValue = false;
        else
          return false;     
          maxLength = parseInt(maxLength);
     }     
}
// Cancel default behavior
function doBeforePaste(control)
{
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
        if(window.event) //IE    
          event.returnValue = false;
        else //firefox
          return false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control)
{
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          if(window.event)
            event.returnValue = false;
          else
            return false;  
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}
// MaxLength for Multiline textArea control ENDS HERE.

var dtCh= "/";
//var minYear=1900;
//var maxYear=2100;

function isInteger(s)
{
	var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr)
{
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1)
	{
		//self.parent.showPopWin('', 400, 100,false,null,"The date format should be : mm/dd/yyyy","txtDate",2);
		//self.parent.document.getElementById("imgOK").focus();
		return "The date format should be : mm/dd/yyyy";
	}
	if (strMonth.length<1 || month<1 || month>12)
	{
		//self.parent.showPopWin('', 400, 100,false,null,"Please enter a valid month");
		//self.parent.document.getElementById("imgOK").focus();
		return "Please enter a valid month"
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//self.parent.showPopWin('', 400, 100,false,null,"Please enter a valid day");
		//self.parent.document.getElementById("imgOK").focus();
		return "Please enter a valid day"
	}
	if (strYear.length != 4 || year==0 )
	{
		//self.parent.showPopWin('', 400, 100,false,null,"Please enter a valid 4 digit year");
		//self.parent.document.getElementById("imgOK").focus();
		return "Please enter a valid 4 digit year"
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
	{
		//self.parent.showPopWin('', 400, 100,false,null,"Please enter a valid date");
		//self.parent.document.getElementById("imgOK").focus();
		return "Please enter a valid date"
	}
return true
}

function createCookie(name, value, days)
{
    if (days) 
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
    var ca = document.cookie.split(';');
    var nameEQ = name + "=";
    for(var i=0; i < ca.length; i++) 
    {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}


/*function GUIDGen() 
{
var S4 = (((1+Math.random())*0x10000)|0).toString(16).substring(1); 
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}*/


/* Client-side access to querystring name=value pairs
	Version 1.2.3
	22 Jun 2005
	Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}



x =320; 
y = -140;
var statusVisible = 'hidden';
var gObject = "";
var theLeft = "0px";
var theTop = "0px";

function setVisible(obj,leftPos,status)
{  
   var obj =  document.getElementById(obj);  
    statusVisible = status; 

    if(status == 'visible')
    {                 
	    x = leftPos;	    	    	    
	    gObject = obj.id;
	    placeIt();		
	}
	else
	    obj.style.visibility = "hidden";
}

function placeIt()
{
    obj = document.getElementById(gObject);
    if (self.parent.document.documentElement)
	{
		theLeft = self.parent.document.documentElement.scrollLeft;
		theTop = self.parent.document.documentElement.scrollTop;
	}
	else if (self.parent.document.body)
	{
		theLeft = self.parent.document.body.scrollLeft;
		theTop = self.parent.document.body.scrollTop;
	}

	var str = "";
	str = new String(self.location);   
	theLeft += x;
    if (str.indexOf("#MySite") > -1)
        y = 100;
    else
    {
        y = -140;

	    if (theTop == 0)
	        theTop = 50;
	    else
	        theTop += y;
    }
   
    obj.style.left = theLeft + 'px' ;
    obj.style.top = theTop + 'px' ;	
    obj.style.visibility = statusVisible;	
	
	
	var strCallfn = "placeIt()";
    if(obj.style.visibility == 'visible') setTimeout(strCallfn,500);       
   
}

 function doResetPagination()
    {        
        document.getElementById("divPagination").innerHTML =  "";       
        document.getElementById("hidStatusToCall").value = 1;
        document.getElementById("hidCurPage").value = 1;    
        /* Added for reintialization */
        document.getElementById("hidStartPage").value = 0;
        document.getElementById("hidEndPage").value = 0;
        document.getElementById("hidPreVisitedPage").value = 0;
        doPagePostBack(0)
    }


