function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}


/* Finish */

/* Function js */


var gl_el; //global element
//function compares two dates (string format) date format = YYYY-MM-DD
/* @return: -1 value1 < value2
			 1 value1 > value2
			 0  value1 = value2
*/			
// trim() function defined to remove spaces
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
function dateCompare (value1, value2) {
   var date1, date2;
   var month1, month2;
   var year1, year2;

   year1  = value1.substring (0, value1.indexOf ("-"));
   month1 = value1.substring(value1.indexOf ("-")+1, value1.lastIndexOf ("-"));
   date1  = value1.substring (value1.lastIndexOf ("-")+1, value1.length);

   year2  = value2.substring (0, value2.indexOf ("-"));
   month2 = value2.substring(value2.indexOf ("-")+1, value2.lastIndexOf ("-"));
   date2  = value2.substring (value2.lastIndexOf ("-")+1, value2.length);

   year1  = parseFloat(year1);
   month1 = parseFloat(month1);
   date1  = parseFloat(date1);

   year2  = parseFloat(year2);
   month2 = parseFloat(month2);
   date2  = parseFloat(date2);

   if (year1 > year2){ return 1;}
   else { 
		if (year1 < year2){  return -1;}
		else { //means year1=year2
			if (month1 > month2){ return 1;}
			else{ 
				if (month1 < month2) { return -1;}
				else {//means month1=month2
					if (date1 > date2){ return 1;}
					else { 
						if (date1 < date2) {  return -1;}
						else{ //means date1=date2
							return 0;
						}
					}
				}
			}
		}
   }
}


function floatValueCheckLimit(floatVal,beforeDecimal,afterDecimal){
	var amt = floatVal.split(".");
	if(amt.length>2){
		return false;
	}else{
		var temp = +amt[0];
		var b_dec = temp+'';
		if(amt.length==1){
			if(b_dec.length > beforeDecimal){ 
				return false;
			}
		}else{
			if(b_dec.length > beforeDecimal){ 
				return false;
			}
			if(amt[1].length > afterDecimal){
				return false;
			}
		}
		return true;
	}
}

function counterText(field, countfield, maxlimit) {
	/*
	* The input parameters are: the field name;
	* field that holds the number of characters remaining;
	* the max. numb. of characters.
	*/
	if (field.value.length > maxlimit) // if the current length is more than allowed
		field.value =field.value.substring(0, maxlimit); // don't allow further input
	else
		countfield.value = maxlimit - field.value.length;
} // set the display field to remaining number



/*
	validation function
	
*/
function trim(b){
	var i=0;
	while(b.charAt(i)==" "){
		i++;
	}
	
	b=b.substring(i,b.length);
	len=b.length-1;
	
	while(b.charAt(len)==" "){
		len--;
	}
	b=b.substring(0,len+1);
	return b;
}

function isCharsInBag (s, bag)
  {
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
 }


//function to check valid Telephone,. Fax no. etc
function isPhone(s)
  {
	return isCharsInBag (s, "0123456789-+(). ");//simple test
	
	var PNum = new String(s);
	
	//	555-555-5555
	//	(555)555-5555
	//	(555) 555-5555
	//	555-5555

    // NOTE: COMBINE THE FOLLOWING FOUR LINES ONTO ONE LINE.
	var regex = /^[0-9]{3,3}\-[0-9]{3,3}\-[0-9]{4,4}$|^\([0-9]{3,3}\) [0-9]{3,3}\-[0-9]{4,4}$|^\([0-9]{3,3}\)[0-9]{3,3}\-[0-9]{4,4}$|^[0-9]{3,3}\-[0-9]{4,4}$/;
//	var regex = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/; //(999) 999-9999 or (999)999-9999
	if( regex.test(PNum))
		return true;
	else
		return false;
	
	/*//code1
	var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/; 
	if (s.match(phone2)) {
   		return true;
 	} else {
 		return false;
 	}

	
	*/
	
	/*//code2
	var stripped = s.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
	   return false;
	}
	
	
	if (!(stripped.length == 10)) {
			return false;
	}
	*/
	
	/*//code3
	if (isCharsInBag (s, "- +().,/;0123456789") == false)
    {
        return false;
    }
    return true;
	*/
 }
 
function isValidComment(s){
	if(s.charAt(0)==' ') { return false; }
    return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?<>()!#$%&*@,:'.-_ ");
} 
 
function isValidNameText(s){
	 if(s.charAt(0)==' ') { return false; }
    return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ ");
} 
 
function isValidText(s){
	if(s.charAt(0)==' ') { return false; }
    return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?()&*%@.- ");
}

function isValidString(s){
	 if(s.charAt(0)==' ') { return false; }
    return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.,?-_ ");
}

function isUserId(s){
	 if(s.charAt(0)==' ') { return false; }
    return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_");
}
 

function isAlphaNumeric(s){
	if(s.charAt(0)==' ') { return false; }
    	return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ");
}

function isAlpha(s){
	if(s.charAt(0)==' ') { return false; }
    	return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
}

function isNumeric(s){
	if(s.charAt(0)==' ') { return false; }
    	return isCharsInBag (s, "0123456789");
}

function isEmpty(s)
{
		  s=trim(s);
		  return ((s == null) || (s.length == 0))
}


function isValidateUrl(strUrl) {
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if (!v.test(strUrl)) { 
        return false;
    }
	return true;
} 

//Validation for numeric fields
function isFloat(var1){
	str = var1;
	return isCharsInBag (str, "0123456789.");
}

function isUserName(s)
{
	if(s.charAt(0)==' ') { return false; }
   s=trim(s);
   return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
   
}
function isUserPass(s)
{
	if(s.charAt(0)==' ') { return false; }
   s=trim(s);
   return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
   
}

function isName(s){
	if(s.charAt(0)==' ') { return false; }
	s=trim(s.toString());
	return isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ");
}


  // This function accepts a string variable and verifies if it is a
  // proper date or not. It validates format matching either
  // mm-dd-yyyy or mm/dd/yyyy. Then it checks to make sure the month
  // has the proper number of days, based on which month it is.	 
  // The function returns true if a valid date, false if not.
  // ******************************************************************	 
  function isDate(dateStr) 
  {

	   var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{2})$/;
	   var matchArray = dateStr.match(datePat); // is the format ok?
	   months= new Array(12);
	   months[0]="Jan";
	   months[1]="Feb";
	   months[2]="Mar";
	   months[3]="Apr";
	   months[4]="May";
	   months[5]="Jun";
	   months[6]="Jul";
	   months[7]="Aug";
	   months[8]="Sep";
	   months[9]="Oct";
	   months[10]="Nov";
	   months[11]="Dec"; 
	  if (matchArray == null) 
	  {
		  alert("Please enter date as either mm/dd/yy or mm-dd-yy.");
		  return false;
	  }
 
	  month = matchArray[1]; // parse date into variables
	  day = matchArray[3];
	  year = matchArray[5];

	  if (month < 1 || month > 12) // check month range
	  { 
		  alert("Month must be between 1 and 12.");
		  return false;
	  }
 
	  if (day < 1 || day > 31) 
	  {
		  alert("Day must be between 1 and 31.");
		  return false;
	  }
 
	  if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	  {
		  alert("Month "+ months[month-1]+" doesn't have 31 days!")
		  return false;
	  }
 
	  if (month == 2)  // check for february 29th
	  {
		  var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		  if (day > 29 || (day==29 && !isleap)) 
		  {
			  alert("February " + year + " doesn't have " + day + " days!");
			  return false;
		  }
	  }
	  return true; // date is valid
  }
  
  
//function to check valid email id
function isEmail(s)
{
	
	
	/*//code 3.
	var regex = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
    return regex.test(s);
	*/
	
	var regex = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i
	var regex =	/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	return regex.test(s);
	
}


//format YYYY-MM-DD
function isValidDate(strdate) { 
 // alert(strdate)
  var datedelimiter = '-';
  var datesplit = strdate.split(datedelimiter)
  if (datesplit.length > 3) {return false;}
  var month = 0; 
  month = datesplit[1];
  if (month < 1 || month >12 ) {return false;}
  if (isNaN(datesplit[0])) {return false;}
  else if (isNaN(datesplit[1])) {return false;}
  else if (isNaN(datesplit[2])) {return false;}
  else {
    //var year = parseInt(datesplit[2],10);
    var yearLn = (datesplit[0].length);
    var year= datesplit[0];
    	
    if (yearLn==1){return false;}
    if (yearLn==3){return false;}
    if (year<1){return false;}
    if (yearLn==2){
         year = '20'+ year
    }

   //var year = year;
   // alert(year)
    // var year = (datesplit[2],10);

    var day = parseInt(datesplit[2],10);
     if(day<0){return false;}
	if (day>31){return false;}
    if ((day > 30) && ((month == 4) || (month == 6) || (month == 9) || (month == 11))) {return false;}
    if (month == 2) {  // This calculates the basic leap year no matter the format, i.e. 2000 or 00. 
		var leap = ((year/4) == parseInt(year/4))
		if (leap) {if (day > 29) {return false;}
		}else {if (day > 28) {return false;}
      }
    }
  } 
  return true;
}



function isbigDateTime(StDate, StTime, EdDate, EdTime)
 {
//alert('start' + StTime + 'end' + EdTime)
	//var DTDelimiter = ' ';
	var DateDelimiter='/';
	var TimeDelimiter=':';
	
	//Split start date and time.
	//var StDTSplit = StDateTime.split(DTDelimiter);
	//if (StDTSplit.length>2){return false;}
	//var StDate=StDTSplit[0];
	//var StTime=StDTSplit[1];
	var StDSplit = StDate.split(DateDelimiter);//Splite date into MM/DD/YYYY
	//alert(StDSplit.length)
	if (StDSplit.length>3){return false;}
	var StMM=parseInt(StDSplit[0]);
	var StDD=parseInt(StDSplit[1]);
	var StYY=parseInt(StDSplit[2]);
	var StTSplit = StTime.split(TimeDelimiter);//Splite time into H:M
	if (StTSplit.length>2){return false;}
	var StH=StTSplit[0];
	var StM=StTSplit[1];
	//alert('StMM' + StMM + '  StDD' + StDD + '  StYY' + StYY + '  StH' + StH + '  StM' 

//+ StM);
	
	//Split end date and time.
	//var EdDTSplit = EdDateTime.split(DTDelimiter);
	//if (EdDTSplit.length>2){return false;}
	//var EdDate=EdDTSplit[0];
	//var EdTime=EdDTSplit[1];
	var EdDSplit = EdDate.split(DateDelimiter);//Splite date into MM/DD/YYYY
	if (EdDSplit.length>3){return false;}
	
	var EdMM=parseInt(EdDSplit[0]);
	var EdDD=parseInt(EdDSplit[1]);
	var EdYY=parseInt(EdDSplit[2]);
	var EdTSplit = EdTime.split(TimeDelimiter);//Splite time into H:M
	//alert(EdTSplit.length)
	if (EdTSplit.length>2){return false;}
	var EdH=EdTSplit[0];
	var EdM=EdTSplit[1];
	//alert('time'+ EdH)
	//alert('EdMM' + EdMM + '  EdDD' + EdDD + '  EdYY' + EdYY + '  EdH' + EdH + '  EdM' 

//+ EdM);
	
	if(StYY>EdYY){
	    form1.txtDateEnd.focus()
		return false;
	}
	else if(StYY==EdYY && StMM>EdMM){return false;}	
	else if(StYY==EdYY && StMM==EdMM && StDD>EdDD){return false;}	
	else if(StYY==EdYY && StMM==EdMM && StDD==EdDD && StH>EdH){
		//alert("time HH")
		form1.selEndTime.focus(); 
		return false;
	}else if(StYY==EdYY && StMM==EdMM && StDD==EdDD && StH==EdH && StM>=EdM){
		//alert("time MM")
		form1.selEndTime.focus(); 
		//form.selEndTime.focus();
		return false;
	}	return true;	
}


function OpenWin(width,height,URL,title)
{
	window.open(URL,'',"height=" + height + ",width=" + width + ",toolbar=no,location=no,directories=no,status=no,menubar=no,,scrollbars=yes,resizable=yes");
}


function SelectOption(pObj,pSelOption)
{
	for(var i=0;i<pObj.options.length;i++)
	{
		if(pObj.options[i].value==pSelOption)
		{
			pObj.options[i].selected=true;
		}
	}
}


function trim(b)
{
	b = b.toString();
	var i=0;
	while(b.charAt(i)==" ")
	{
	i++;
	}
	b=b.substring(i,b.length);
	len=b.length-1;
	while(b.charAt(len)==" "){
	len--;
	}
	b=b.substring(0,len+1);
	return b;
}



//Validation for radio buttons
function validateRadio(var1, var2){
	var sCheck = "N";
	for (i = 0; i < var1.length; i++){
		if (var1[i].checked == true){
		  sCheck = "Y";
		}
	}
	if (sCheck != "Y"){
		return false;
	}
	return true;
}

//Validation for percentage
function validatePercentage(var1, var2){
	var fld = "";
	fld = var1.value;
	if (fld > 100 && fld != ""){
		return false;
	}
	return true;
}


  function selval(sellist, selvalue){
  	for(iVar=0;iVar<sellist.options.length;iVar++){
		if (selvalue == ""){
			sellist.selectedIndex = 0;
			return;
		} else if (sellist.options[iVar].value == selvalue){
			sellist.selectedIndex = iVar;
			return;
		}
	}
	return;
  }


  //set focus on el or global variable gl_el;
  function setFocus(el){
	if(el != "undefined"){
		document.getElementById(el).focus();
		setAlertStyle(el);
	//	addEvent(document.getElementById(el),'onblur',function(){ alert('hello!'); })
	}else if(typeof gl_el != "undefined"){
		gl_el.focus();	
	}
	return true;
	
  }
  
  function setAlertStyle(el){
	document.getElementById(el).style.border = '2px solid';
	document.getElementById(el).style.borderColor = '#fdd42d';
  }
    
  function unsetAlertStyle(el){
	document.getElementById(el).style.border = '2px solid';
	document.getElementById(el).style.borderColor = '#01903C';
  }

  function addEvent( obj, type, fn ) {
   if ( obj.attachEvent ) {
     obj['e'+type+fn] = fn;
     obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
     obj.attachEvent( 'on'+type, obj[type+fn] );
   } else
     obj.addEventListener( type, fn, false );
 }
 
 
 
/*
 * msg = message to print
 * callback = function to be called when ok is clicked
 * el is the element to be passed when cllback is called
 */
function winAlert(msg,el,callback){
	if(!callback)
		callback = 'setFocus';
	
	/*
	alert(el);
	eval(callback+'("'+el+'");');*/
	
	Dialog.alert(
		'<span class="arial14">'+msg+'</span>', 
		{
			windowParameters: 
			{
				className: "alphacube",
				width:300
			},
			
			okLabel: "Ok",
			ok: function(win) { eval(callback+'("'+el+'");'); return true;}
		}
	);
	
}





/*
 * msg = message to print
 * callback = function to be called when ok is clicked
 * el is the element to be passed when cllback is called
 */
function winConfirm(msg,okcallback,cancelcallback){
	Dialog.confirm(
		msg,
		{
			windowParameters: 
			{
				className: "alphacube",
				width:300
			}, 
			
			okLable: "Ok",
			cancelLable: "Cancel",
			ok: function(win) { eval(okcallback); return true;},
			cancel:function(win) {
				if(cancelcallback){
					eval(cancelcallback);
				}
				return true;
			} 
		 }
	);	
}

function winOpen(url,width,height,name){
	if(!name)
		name = '';
	if(!width)
		width  = 800;
	if(!height)
		height = 500;
	leftVal = (screen.width - width) / 2;
	topVal = (screen.height - height) / 2;
	popUp = window.open(url,name,'scrollbars=1,resizable=1,width='+width+',height='+height+',left='+leftVal+',top='+topVal);
	return popUp;
}



function winClose(){
	window.close();
}

function intergerValue(value) {
	return parseInt(value);
}

function addOption(selectId, val, txt) {
	var objOption = new Option(txt, val);
	document.getElementById(selectId).options.add(objOption);
}



function checkAtLeastOneBox(name) {
	count = 0;
	elements = document.getElementsByName(name);
	len = elements.length;

	for (var i = 0; i < len; i++) {
		var e = elements[i];
		if (e.checked) {
			count=count+1;
		}
	}

	if (count == 0){
		return false;
	}
	else {
		return true;
	}
}

//to check name feild length

function checkNameLength(s)
{ 
	if(s.length < 5 || s.length > 20 )
		{
		return false;
		}
		return true;

}

	function checkFieldLength(s,start,end)
	{
		if(s.length > end )
			{
			return false;
			}
			return true;
	}

	function redirectURL(rediectUrl) {
		location.href= rediectUrl;
	}

	function removeHTMLTags(html){
		if(!isEmpty(html)){
			var strInputCode = html;
			/* 
				This line is optional, it replaces escaped brackets with real ones, 
				i.e. &lt; is replaced with < and &gt; is replaced with >
			*/	
			strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
				return (p1 == "lt")? "<" : ">";
			});
			strTagStrippedText = strInputCode.replace(/(&nbsp;)/ig, "");
			return strTagStrippedText = strTagStrippedText.replace(/<\/?[^>]+(>|$)/g, "");
		}	
	}




function ReverseDisplay(d) 
{
	if(document.getElementById(d).style.display == "none") 
	{ 
		document.getElementById(d).style.display = "block"; 
	}
	else 
	{ 
		document.getElementById(d).style.display = "none"; 
		document.getElementById('name').value="";
		document.getElementById('email').value="";
		document.getElementById('password').value="";
		document.getElementById('confirm_password').value="";
		document.getElementById('user_type').value="";
//		document.getElementById('country').value="Brazil";
//		document.getElementById('state').value="";
//		document.getElementById('city').value="";
		document.getElementById('location').value="";
		document.getElementById('phoneNumber').value="";
		document.getElementById('email_message').innerHTML="";
	}
}



function ReverseDisplay1(d) 
{
	if(document.getElementById(d).style.display == "none") 
	{ 
		document.getElementById(d).style.display = "block"; 
	}
	else 
	{ 
		document.getElementById(d).style.display = "none"; 
		document.getElementById('login_email').value="";
		document.getElementById('login_password').value="";
		document.getElementById('login_message').innerHTML="";
	}
}


function ReverseDisplay2(d) 
{
	if(document.getElementById(d).style.display == "none") 
	{ 
		document.getElementById(d).style.display = "block"; 
	}
	else 
	{ 
		document.getElementById(d).style.display = "none"; 
		document.getElementById('forgot_email').value="";
		document.getElementById('forgot_message').innerHTML="";
	}
}


function ReverseDisplay3(d) 
{
	if(document.getElementById(d).style.display == "none") 
	{ 
		document.getElementById(d).style.display = "block"; 
	}
	else 
	{ 
		document.getElementById(d).style.display = "none"; 
		document.getElementById('forgot_email').value="";
		document.getElementById('forgot_message').innerHTML="";
	}
}


function ReverseDisplay5(d) 
{
	if(document.getElementById(d).style.display == "none") 
	{ 
		document.getElementById(d).style.display = "block"; 
	}
	else 
	{ 
		document.getElementById(d).style.display = "none"; 
	}
}



function show_registration()
{
	var Areturn = getScrollXY1()
	var countTop2 = Areturn[1];
	var countTop3 = parseInt(100) + parseInt(countTop2);
	countTop3 = countTop3+'px';
	//document.getElementById("user_registration").style.top=countTop3;

	document.getElementById('idBack').style.display = "none";
	document.getElementById('idCountry').style.display = "none";
	document.getElementById('idLocation').style.display = "block";
	document.getElementById('idNocountry').style.display = "block";
	document.getElementById('cityExample').style.display = "block";

	document.getElementById('checkLocation').value="1";

	document.getElementById("user_login").style.display='none';
	document.getElementById("user_forgotpassword").style.display='none';
	//document.getElementById("user_registration").style.display='block';
	document.getElementById("user_contactus").style.display='none';
	document.getElementById('name').focus();
}



function getScrollXY1() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


function show_login()
{
	var Areturn = getScrollXY1()
	var countTop2 = Areturn[1];
	var countTop3 = parseInt(120) + parseInt(countTop2);
	countTop3 = countTop3+'px';

	var leftDist =  (parseInt(document.body.clientWidth)/2);
	leftDist = parseInt(leftDist)-200;
	leftDist = leftDist+'px';

	document.getElementById("user_login").style.left=leftDist;
	document.getElementById("user_login").style.top=countTop3;
	document.getElementById("user_contactus").style.display='none';
	//document.getElementById("user_registration").style.display='none';
	document.getElementById("user_forgotpassword").style.display='none';
	document.getElementById("user_login").style.display='block';

	document.getElementById("login_email").value="";
	document.getElementById("login_password").value="";

	document.getElementById("login_email").focus();
}


function show_forgotpassword()
{
	var Areturn = getScrollXY1()
	var countTop2 = Areturn[1];
	var countTop3 = parseInt(120) + parseInt(countTop2);
	countTop3 = countTop3+'px';
	document.getElementById("user_forgotpassword").style.top=countTop3;

	document.getElementById("user_contactus").style.display='none';
	//document.getElementById("user_registration").style.display='none';
	document.getElementById("user_login").style.display='none';
	document.getElementById("user_forgotpassword").style.display='block';
	document.getElementById("forgot_email").value="";
	document.getElementById("forgot_email").focus();
}

function show_contact()
{
	var Areturn = getScrollXY1()
	var countTop2 = Areturn[1];
	var countTop3 = parseInt(100) + parseInt(countTop2);
	countTop3 = countTop3+'px';
	document.getElementById("user_contactus").style.top=countTop3;

	//document.getElementById("user_registration").style.display='none';
	document.getElementById("user_login").style.display='none';
	document.getElementById("user_forgotpassword").style.display='none';
	document.getElementById("user_contactus").style.display='block';
	document.getElementById("cmessage").focus();
}

/* Finish */




/* Common funciton */


//------------Rating section -----------------
var imagePath		 = "http://172.24.0.9:7003/Storage/rating/";
//var imagePath		 = "http://smartdatainc.co.in:8066/Images/rating/";
//var imagePath = document.getElementById("imagePath").value ;

var largeStarLeftOn  = imagePath+"star_v_on_l.gif";
var largeStarLeftOff = imagePath+"star_v_off_l.gif";
var largeStarMidOn   = imagePath+"star_v_on_m.gif";
var largeStarMidOff  = imagePath+"star_v_off_m.gif";
var largeStarRightOn = imagePath+"star_v_on_r.gif";
var largeStarRightOff= imagePath+"star_v_off_r.gif";
UserRating	= 0;

/*
function isAddress(s){
	//var s=trim(s);
	var bag = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-, ";
	var flag = false; 
	
	for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1){
			flag = true;
		}
    }
    return flag;
}
*/

function checkBadWords(fieldName,badArr,replaceArr){
	var tempStr = new String();
	tempStr=getObject(fieldName).value;
	var i = 0;
	for(i in badArr){
		tempStr = tempStr.replace(eval("/"+badArr[i]+"/g"),replaceArr[i]);
	}
	getObject(fieldName).value = tempStr;
}





function OnMouseClickStars(ratingId){
    
	if(UserRating!=0){
		UserRating=0;
	}else {
		UserRating = ratingId; 	
		getObject("txtRating").value	= ratingId;
	}
}

function OnMouseOverStars(ratingId, img){

  if ((ratingId < 1)||(ratingId > 5)||(UserRating > 0))
    return;

  img.style.cursor = "pointer";
  
  if (ratingId >= 1)
    getObject("rating_star_1").src = largeStarLeftOn;
  else  
    getObject("rating_star_1").src = largeStarLeftOff;
        
  if (ratingId >= 2)        
    getObject("rating_star_2").src = largeStarMidOn;
  else  
    getObject("rating_star_2").src = largeStarMidOff;    
    
  if (ratingId >= 3)            
    getObject("rating_star_3").src = largeStarMidOn;
  else  
    getObject("rating_star_3").src = largeStarMidOff;    
    
  if (ratingId >= 4)                
    getObject("rating_star_4").src = largeStarMidOn;
  else  
    getObject("rating_star_4").src = largeStarMidOff;    
    
  if (ratingId >= 5)                    
    getObject("rating_star_5").src = largeStarRightOn;
  else  
    getObject("rating_star_5").src = largeStarRightOff;
}

function OnMouseOutRating(a, img){

  img.style.cursor = "default";

  if (UserRating == 0){
    getObject("rating_star_1").src = largeStarLeftOff;
    getObject("rating_star_2").src = largeStarMidOff;
    getObject("rating_star_3").src = largeStarMidOff;
    getObject("rating_star_4").src = largeStarMidOff;
    getObject("rating_star_5").src = largeStarRightOff;
 	getObject("txtRating").value	= 0;
  }  
} 

function setSort(frmName,FieldName,srtBy)
 {
	document.forms[frmName].hidSortValue.value='sort';
	if(document.forms[frmName].hidSortValue.value=='sort')
	{
	 if(srtBy=='')
	    {
			document.forms[frmName].hidSortAction.value="ASC";	
		}
		else
		{
			document.forms[frmName].hidSortAction.value=srtBy;
		}
	}
	document.forms[frmName].hidSortField.value=FieldName;
	document.forms[frmName].submit();
}

function showBetweenDate(frmobj)
   {
		document.getElementById('betweenData').style.display="";
		document.getElementById('betweenText').style.display="";
  }
function hideBetweenDate(frmobj)
   {
		document.getElementById('betweenData').style.display="none";
		document.getElementById('betweenText').style.display="none";
		document.getElementById('dateFrom').value="";
		document.getElementById('dateto').value="";
	}


function setView(frmObj,FieldName)
{
	if(document.forms[frmObj.name].show_name_photo.checked==true)
	{	
		document.getElementById(FieldName).value="thumb";
	}
}


	
	
	//=====================tooltip======================================
		function xstooltip_findPosX(obj) 
		{
		  var curleft = 0;
		  if (obj.offsetParent) 
		  {
			while (obj.offsetParent) 
				{
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			}
			else if (obj.x)
				curleft += obj.x;
			return curleft;
		}
		
		function xstooltip_findPosY(obj) 
		{
			var curtop = 0;
			if (obj.offsetParent) 
			{
				while (obj.offsetParent) 
				{
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			}
			else if (obj.y)
				curtop += obj.y;
			return curtop;
		}
		function xstooltip_show(tooltipId, parentId, divWidth,displayText,messageType)
		{
			posX	= 0;
			posY	= 0;
			//alert("sdfsdfsd");
			it = getObject(tooltipId);
			
			
			it.style.top	= "";
			it.style.width	= divWidth;
			it.style.left	= "";
			if ((it.style.top == '' || it.style.top == 0) 
				&& (it.style.left == '' || it.style.left == 0))
			{
				// need to fixate default size (MSIE problem)
				it.style.width = it.offsetWidth + 'px';
				it.style.height = it.offsetHeight + 'px';
				
				img = getObject(parentId); 
				
				// if tooltip is too wide, shift left to be within parent 
				if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
				if (posX < 0 ) posX = 0; 
				
				x = xstooltip_findPosX(img) + posX;
				y = xstooltip_findPosY(img) + posY;
				var browser=navigator.appName;
				if(browser=="Microsoft Internet Explorer"){
					it.style.top = y+35 + 'px';
					it.style.left = x+5 + 'px';
				}else {
					it.style.top = y+20 + 'px';
					it.style.left = x-5 + 'px';
				}
			}
			displayTextDivObj	= getObject("errorMessageTD");
			displayTextDivObj.innerHTML	= displayText; 
			if(messageType==1){
				displayTextDivObj.style.color	= "#CC3300";
			}else if(messageType==2){
				displayTextDivObj.style.color	= "#006600";
			}
			it.style.visibility = 'visible'; 
		}
		function xstooltip_hide(id)
		{
			it = getObject(id); 
			it.style.visibility = 'hidden'; 
		}
		
		
		
		function xstooltipImg_show(tooltipId, parentId, divWidth,imgSource)
		{
			posX	= 0;
			posY	= 0;
			//alert("sdfsdfsd");
			it = getObject(tooltipId);
			it.style.top	= "";
			it.style.width	= divWidth;
			it.style.left	= "";
			if ((it.style.top == '' || it.style.top == 0) 
				&& (it.style.left == '' || it.style.left == 0))
			{
				// need to fixate default size (MSIE problem)
				it.style.width = it.offsetWidth + 'px';
				it.style.height = it.offsetHeight + 'px';
				
				img = getObject(parentId); 
			
				// if tooltip is too wide, shift left to be within parent 
				if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
				if (posX < 0 ) posX = 0; 
				
				x = xstooltip_findPosX(img) + posX;
				y = xstooltip_findPosY(img) + posY;
				var browser=navigator.appName;
				if(browser=="Microsoft Internet Explorer"){
					it.style.top = y+35 + 'px';
					it.style.left = x+5 + 'px';
				}else {
					it.style.top = y+20 + 'px';
					it.style.left = x-5 + 'px';
				}
			}
			displayImgDivObj		= getObject("imageforShowFull");
			displayImgDivObj.src	= imgSource;
			it.style.visibility = 'visible'; 
		}
		
	
	//====================================================================

//===============================Create object ============================

function getObject(a){
	  if(document.getElementById && document.getElementById(a)){
		return document.getElementById(a)
	  }else if(document.all&&document.all(a)){
		return document.all(a)
	  }else if(document.layers&&document.layers[a]){
		return document.layers[a]
	  }else{
		return false
	  }
}

//==========================================================================




// ===========================Prelaod images==============================


		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_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_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];}
		}


// ==========================================================================

function showHideDiv(divName){
	divObj	= getObject(divName);
	if(divObj.style.display=="none"){
		divObj.style.display	= "inline";
	}else {
		divObj.style.display	= "none";
	}
}


function submitFormThroughJS(frmName){
	frmObj	= getObject(frmName);
	frmObj.submit();
}

function submitFormThroughHyperLink(obj){
	var validationFunction	= obj.name +"_validation(obj)";
	var returnStatus = eval(validationFunction);
	if(returnStatus==true){
		obj.submit();
	}
}

function resetFormThroughHyperLink(obj)
{
	obj.reset();
}



//===========================================================
function SetAllCheckBoxes(FormName,FieldName)
	{
	var isChecked=document.getElementById('checkAll').checked;

	if(isChecked==true){
		var	CheckValue='true';
		
	}
	else
	{
		var	CheckValue='';
	}	

	if(!FormName)
		return;
		var objCheckBoxes = document.forms[FormName].elements[FieldName];

	if(!objCheckBoxes)
		return;
		var countCheckBoxes = objCheckBoxes.length;

	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
		{
				objCheckBoxes[i].checked = CheckValue;

			
		}
}

function test_me()
	{
	  var flag=0;
	  for(var i=0;i<(document.frmInvoiceList.selectAll.length);i++)
	  {
	        
			if(document.frmInvoiceList.selectAll[i].checked)
			{
	           
			   	flag=1;	
			}
			else if(!(document.frmInvoiceList.selectAll[i].checked))
			{
			  flag=0;
			  break;
			}
	  }
	
	  if(flag==1)
	  {
	    document.getElementById('checkAll').checked=true;
	  }
	  else
	  {
	    document.getElementById('checkAll').checked=false;
	  }
	
  }

function checkMasterCheckBox(checkBoxObj,formName,checkBoxName,masterCheckBoxName){
	
	allCheckBoxCheckedStatus	= false;
	formObj	= getObject(formName);
	masterCheckBoxObj	= getObject(masterCheckBoxName);
	allCheckBoxCheckedStatus	= isAllcheckBoxSelected(formObj,checkBoxName);
	//alert(allCheckBoxCheckedStatus);
	if(checkBoxObj.checked==true){
		if(allCheckBoxCheckedStatus==true){
			masterCheckBoxObj.checked	= true;
		}
	}else{
		masterCheckBoxObj.checked	= false;
	}
	
}


//=============================================================
//===========================================================
function checkedUnCheckedAllCheckboxes(FormName,masterCheckBoxObj,checkBoxName)
	{
	var isChecked=masterCheckBoxObj.checked;
	
	if(isChecked==true){
		var	CheckValue='true';
		
	}
	else
	{
		var	CheckValue='';
	}	

	if(!FormName)
		return;
		var objCheckBoxes = document.forms[FormName].elements[checkBoxName];

	if(!objCheckBoxes)
		return;
		var countCheckBoxes = objCheckBoxes.length;

	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
		{
				objCheckBoxes[i].checked = CheckValue;

			
		}
}


//=============================================================


function isAllcheckBoxSelected(formObj,checkBoxName){
	var status	= false;
	var countCheckBoxes = 0;
	var objCheckBoxes = formObj.elements[checkBoxName];
	countCheckBoxes = objCheckBoxes.length;
	if(countCheckBoxes!=0){
		for(var i = 0; i <countCheckBoxes; i++){
			if(objCheckBoxes[i].checked==true){
				status	= true;
			}else{
				status	= false;
				break;
			}
		}
	}if(!countCheckBoxes) {
		if(objCheckBoxes.checked==true){
			status	= true;
		}else {
			status	= false;
		}
	}
	return status;
}


//======================= Javacsript function for mouse effect on buttons ===================================

//========== Function for loign button in header =============

function buttonOnMouseOverHeader(buttonObj,buttonEndImageDiv)
{
	buttonObj.className="buttonGrayBackground1";
	document.getElementById(buttonEndImageDiv).className="buttonEndGrayBackground1";
}
function buttonOnMouseOutHeader(buttonObj,buttonEndImageDiv)
{
	buttonObj.className="buttonRedBackground1";
	document.getElementById(buttonEndImageDiv).className="buttonEndRedBackground1";

}

//=============== function for normal button =================
function buttonOnMouseOver(buttonObj,buttonEndImageDiv)
{
	buttonObj.className="buttonGrayBackground";
	document.getElementById(buttonEndImageDiv).className="buttonEndGrayBackground";
}
function buttonOnMouseOut(buttonObj,buttonEndImageDiv)
{
	buttonObj.className="buttonRedBackground";
	document.getElementById(buttonEndImageDiv).className="buttonEndRedBackground";

}


//-------------------- Search box on top bar ====================
function onFocusOnSearchBoxInTop(){
	getObject('srch_data').value	= "";
}

function onFocusOutOnSearchBoxInTop(){
	if(getObject('srch_data').value	== "")
	getObject('srch_data').value	= "Keyword search";
}

//===============================================================



/* Finish */