<!-- BEGIN
// JavaScript Document
/*
	File is generated for use varius function which is need in the varius purpose
	some function is taken from http://www.yahoo.com but modified for my own
	Created By: Md. Shahadat Hossain Khan Razon   eMail: razonklnbd@yahoo.com   web: www.razon.s5.com/personal
	Created Date: 20th Nov. 2004
	Last Modified By: Md. Shahadat Hossain Khan Razon   eMail: razonklnbd@yahoo.com   web: www.razon.s5.com/personal
	Last Modified Date: 1st Dec. 2005
*/

function yg_Browser(){
 d=document;
 this.agt=navigator.userAgent.toLowerCase();
 this.major=parseInt(navigator.appVersion);
 this.dom=(d.getElementById);
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major>=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(window.opera);
 if(d.all)this.ie=1;else this.ie=0;
 this.ie4=(d.all&&!this.dom);
 this.ie4up=(this.ie&&this.major>=4);
 this.ie5=(d.all&&this.dom);
 this.ie6=(d.nodeType);
 this.sf=(this.agt.indexOf("safari")!=-1);
 this.win=((this.agt.indexOf("win")!=-1)||(this.agt.indexOf("16bit")!=-1));
 this.winme=(this.agt.indexOf("win 9x 4.90")!=-1);
 this.xpsp2=(this.agt.indexOf("sv1")!=-1);
 this.mac=(this.agt.indexOf("mac")!=-1);
}
var oBw=new yg_Browser();

//switch layers for different browsers
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

//  check id length and validity at offline
function isValidID(){
	var vMax, vMin, vReturnVal;
	var args = isValidID.arguments;
	vMax=parseInt(args[1]);
	if(isNaN(vMax)) vMax=15;
	vMin=parseInt(args[2]);
	if(isNaN(vMin)) vMin=4;
	if(vMin > vMax) vMin=0
	var idVal=args[0];
	var err='';
	if(idVal.length<vMin && vMin>0) err = 'ID must be '+vMin+' character or long..\n';
	if(idVal.length>vMax) err = 'ID can\'t more then '+vMax+' character long..\n';
	var re = new RegExp('^[a-zA-Z]'); //[a-z0-9_]
	var m = re.exec(idVal);
	if(m==null) err+='ID must start with a character [a-z]\n';
	re = new RegExp('[^a-z0-9_]');
	m = re.exec(idVal);
	if(m!=null) err+='ID can\'t contain space, uppercase or special character\n';
	if(idVal.length <= 0) err+='Empty ID is not valid..!';
	vReturnVal = Array();
	vReturnVal[0]=true;
	vReturnVal[1]=err;
	if(err.length > 0) vReturnVal[0]=false;
	if(idVal.length <= 0) vReturnVal[0]=false;
	return vReturnVal;
}

//open popup window
function popWindow(theURL,winName,winWidth,winHeight,otherFeatures, returnType) {
   var x = 0;
   var y = 0;
   x = (screen.availWidth - 12 - winWidth) / 2;
   y = (screen.availHeight - 48 - winHeight) / 2;
   if (otherFeatures != "") {otherFeatures = "," + otherFeatures}
   var features = "screenX=" + x + ",screenY=" + y + ",width=" + winWidth + 
",height=" + winHeight+",top="+y+",left="+x+"'" + otherFeatures
   var NewWindow = window.open(theURL,winName,features);
   NewWindow.focus();
   if(returnType==1024) return NewWindow;
}

//return an array containing saperated word with separators of inputed string by inputstring variable
function explode(inputstring, separators) {
	inputstring = new String(inputstring);
	separators = new String(separators);
	
	if(separators == "undefined") separators = ";";
	
	fixedExplode = new Array();
	currentElement = "";
	count = 0;
	
	for(x=0; x < inputstring.length; x++) {
		char = inputstring.charAt(x);
		if(separators.indexOf(char) != -1) {
			if (currentElement != "") {
				fixedExplode[count] = currentElement;
				count++;
				currentElement = "";
			}
		}
		else currentElement += char;
	}
	
	fixedExplode[count] = currentElement;
	return fixedExplode;
}

//check word length in a sentence
//sentence is retrieved from an inputbox or textarea {default: 30}
//check must or not [0-must, 1-optional] {default: 0}
function checkWord(){
	var pOptional, pMaxLen, pWord;
	var args = checkWord.arguments;
	pWord=args[0];
	pMaxLen=30;
	if(args.length>1) pMaxLen=parseInt(args[1]);
	if(isNaN(pMaxLen)) pMaxLen=30;
	pOptional=0;
	if(args.length>2) pOptional=parseInt(args[2]);
	if(isNaN(pOptional)) pOptional=0;

	var wrd = document.getElementById(pWord);
	var wrdVal = wrd.value;
//	replace front slash with a blank space for word length validation
	var re = new RegExp ('/', 'g') ;
	var tmpWrd = wrdVal.replace(re, ' / ');
	wrdVal = tmpWrd;
	
	
	var err='';
	var char1='';
	var tmpLen=0;
	var maxLen=1;
	tmpWrd='';
//	replace line break with a blank space
	re = new RegExp ('\n', 'g') ;
	var mainWrd0 = wrdVal.replace(re, ' ');
//	replace carrieg with a blank space for windows plateform
	re = new RegExp ('\r', 'g') ;
	var mainWrd = mainWrd0.replace(re, ' ');
	var tmpChar = explode(mainWrd,' ');

	for(i=0; i < tmpChar.length; i++){
		tmpLen=tmpChar[i].length;
		if(tmpLen > maxLen) maxLen=tmpLen;
	}
	if(maxLen > pMaxLen) err='A word can\'t contain more than '+pMaxLen+' character...';
	if(err.length>0 && wrdVal.length>0){
		if(pOptional==0){
			alert(err);
			wrd.focus();
		}
		if(pOptional==1){
			if(!confirm(err+'\nWant to add more then '+pMaxLen+' character?\n(OK = Yes, Cancel = No)')) wrd.focus();
		}
	}
	return true;
}

function dtCorrection(idYear, idMonth, idDay) {
	var fsYear, fsMonth, fsDay;
	if (ie4){
		fsYear	  = document.all[idYear];
		fsMonth	  = document.all[idMonth];
		fsDay	  = document.all[idDay];
	}
	if (ns4){
		fsYear	  = document.layers[idYear];
		fsMonth	  = document.layers[idMonth];
		fsDay	  = document.layers[idDay];
	}
	if (ns6){
		fsYear	  = document.getElementById([idYear]);
		fsMonth	  = document.getElementById([idMonth]);
		fsDay	  = document.getElementById([idDay]);
	}
	var year      = fsYear.options[fsYear.options.selectedIndex].value;
	var month     = fsMonth.options[fsMonth.options.selectedIndex].value;
	var sr        = fsDay.options;
	var day       = sr[sr.selectedIndex].value;
	var daylength = sr.length;
	
	if(year == '' || month == '') return;
	
	var leapyear = year % 4;
	var lday = (leapyear==0) ? 29 : 28;
	var alldays = new Array(31, lday, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var days = alldays[month-1];
	
	//Reset the day select field
	for(i=(daylength-1); i >=0; i--) {
	  sr[i] = null;
	}
	
	dayselected = false;
	for(p=0; p<days; p++) {
	  pp = p+1;
	  sr[p] = new Option(pp);
	  sr[p].value = pp;
	  if(p+1 == parseInt(day)) {
		sr[p].selected = true;
		dayselected = true;
	  }
	}
	if(!dayselected) sr[0].selected = true;
}

function yreg_pop(s){
	window.open(s,"yec_pop3","width=520,height=500,scrollbars=yes,resizable=yes");
}

function suchona_winPrint(id){ 
	if(window.print()){
		var d=eval(id)==null||eval(id+".closed");
		if(!d){eval(id+".print()");}
	}
}

function hidelayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "hidden";}
	if (ns4) {document.layers[lay].visibility = "hide";}
	if (ns6) {document.getElementById([lay]).style.display = "none";}
}

function showlayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4) {document.layers[lay].visibility = "show";}
	if (ns6) {document.getElementById([lay]).style.display = "block";}
}

function locateObject(n, d) { //v3.0
  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=locateObject(n,d.layers[i].document); return x;
}

//Begin dHTML Toolltip Timer
var tipTimer;
//End dHTML Toolltip Timer

//Usages: onMouseOut="hideTooltip('dHTMLToolTip')"
function hideTooltip(object){
	if (document.all){
		locateObject(object).style.visibility="hidden";
		locateObject(object).style.left = 0;
		locateObject(object).style.top = -50;
		return false;
	}
	else if (document.layers){
		locateObject(object).visibility="hide";
		locateObject(object).left = 0;
		locateObject(object).top = -50;
		return false;
	}else return true;
}

//Usages: onMouseOver="showTooltip('dHTMLToolTip', event, 'Print%20Poll%20Results', '#336699','#FFFFFF','#FFFFFF', 'Tahoma, Arial, Helvetica, sans-serif','6000')"
function showTooltip(object, e, tipContent, backcolor, bordercolor, textcolor, fontfamily, displaytime){
	window.clearTimeout(tipTimer);
	if (document.all){
		locateObject(object).style.top=document.body.scrollTop+event.clientY+20;
		locateObject(object).innerHTML='<table style="border: '+bordercolor+'; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; background-color: '+backcolor+'" width=10 border=0 cellspacing=0 cellpadding=1><tr><td nowrap style="font-family: '+fontfamily+'; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</td></tr></table> ';
		if ((e.x + locateObject(object).clientWidth) > (document.body.clientWidth + document.body.scrollLeft)){	
				locateObject(object).style.left = (document.body.clientWidth + document.body.scrollLeft) - locateObject(object).clientWidth-10;
		}else{
			locateObject(object).style.left=document.body.scrollLeft+event.clientX;
		}
		locateObject(object).style.visibility="visible";
		tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
		return true;
	}else if (document.layers){
		locateObject(object).document.write('<table width=10 border=0 cellspacing=0 cellpadding=1><tr bgcolor="'+bordercolor+'"><td><table width=10 border=0 cellspacing=0 cellpadding=2><tr bgcolor="'+backcolor+'"><td nowrap><font style="font-family: '+fontfamily+'; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table></td></tr></table>');
		locateObject(object).document.close();
		locateObject(object).top=e.y+20;
		if ((e.x + locateObject(object).clip.width) > (window.pageXOffset + window.innerWidth)){
			locateObject(object).left = window.innerWidth - locateObject(object).clip.width-10;
		}else{
			locateObject(object).left=e.x;
		}
		locateObject(object).visibility="show";
		tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
		return true;
	}else return true;
}

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_validateForm() { //v4.1
  var vID,i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); vID=args[i];
    if (val) { 
		//nm=val.name;
		nm=vID;
		if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

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_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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var NewWindow=window.open(theURL,winName,features);
  NewWindow.focus();
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function curClientDateString(){
	var curClientDate = new Date();
	var year = curClientDate.getYear();
	if (year < 1000) year += 1900;
	var day = curClientDate.getDate();
	var month = curClientDate.getMonth()+1;
	var tmpDateString = '';
	tmpDateString = DDtoDay(day)+" "+MMtoMonth(month, 0)+", "+year;
	return tmpDateString;
}

function DDtoDay(inputDate){
	var dateString = new Array('','st','nd','rd','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','st','nd','rd','th','th','th','th','th','th','th','st');
	var returnDate = '';
	var tempDate = parseInt(inputDate);
	if (tempDate >= 1 && tempDate <= 31) returnDate = inputDate + dateString[tempDate];
	return returnDate;
}

function MMtoMonth(inputMonth, formatFlag){
	var monthStringLong = new Array('','January','February','March','April','May','June','July','August','September','October','November','December');
	var monthStringShort = new Array('','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec');
	var returnMonth = '';
	var tempMonth = parseInt(inputMonth);
	var tempFlag = parseInt(formatFlag);
	if (tempMonth >= 1 && tempMonth <= 12){
		returnMonth = monthStringLong[tempMonth];
		if(tempFlag == 1) returnMonth = monthStringShort[tempMonth];
	}
	return returnMonth;
}

function go_myUrl(){
	var i;
	var args = go_myUrl.arguments;
	i=parseInt(args[0]);
	if(isNaN(i)) i=0;
	if(theArray.length<=i || i<0) i=0;
	window.location.href = theArray[i];
}

//return error message if email address is invalid otherwise return true
function checkMail(x) {
	var rtrnMsg = '';
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{1,4})+$/;
	if (filter.test(x)){
		/* 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=/^(.+)@(.+)$/;
		/* Begin with the coarse pattern to simply break up user@domain into
		   different pieces that are easy to analyze. */
		var matchArray=x.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. */
			rtrnMsg = "Email address seems incorrect (check @ and .'s)\n";
		}
		var user=matchArray[1];
		var domain=matchArray[2];

		/* 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})$/;
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
		if(ipDomainPat.test(domain) == true){
			var IPArray = new Array();
			var currentElement = "";
			var separators = '.';
			var count = 0;
			var char;
			for(var j=0; j < domain.length; j++) {
				char = domain.charAt(j);
				if(separators.indexOf(char) != -1) {
					if (currentElement != "") {
						IPArray[count] = currentElement;
						count++;
						currentElement = "";
					}
				}
				else currentElement += char;
			}
			IPArray[count] = currentElement;
			for (var i=0;i<4;i++) {
				if (IPArray[i]>255) rtrnMsg += "Destination IP address is invalid! " + IPArray[i] + '\n';
			}
		}else{
			var filter1  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if(filter1.test(x) == false) rtrnMsg += 'Incorrect email address...';
		}
		/*
			If no error found the email address is valid
		*/
		if(rtrnMsg.length <= 0) rtrnMsg = true;
	}else rtrnMsg = 'Invalid eMail Address...';
	return rtrnMsg;
}

/*
function are teken from http://www.breakingpar.com/bkp/home.nsf/Doc?OpenNavigator&U=87256B14007C5C6A87256AFB0013C722
collected and updated for www.suchona.com by Md. Shahadat Hossain Khan Razon  eMail: razonklnbd@yahoo.com
*/
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
}

function changeLayerStyle(lay, fl, target) {
	var x = document.getElementById(lay);
	if(fl == 1){
		x.style.background = '#FFE6E6';
		x.style.color = '#000000';
	}else{
		x.style.background = '#CEDBFF';
		x.style.color = '#666666';
	}
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue){
	if(!document.forms[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 showAlertDel() {
	if(confirm('Are you want to delete these information(s)....?\n[Caution: This will permanently deleted from your record.]')) return true;
	else return false;
}

function showHideCheckUncheck(frm, fld, status, layForHide, layForShow){
	var objLay1, objLay2;
	if (ie4){
		objLay1 = document.all[layForHide];
		objLay2 = document.all[layForShow];
	}
	if (ns4){
		objLay1 = document.layers[layForHide];
		objLay2 = document.layers[layForShow];
	}
	if (ns6){
		objLay1 = document.getElementById([layForHide]);
		objLay2 = document.getElementById([layForShow]);
	}
	if(objLay1 && objLay2){
		if (ie4 || ns6){
			objLay1.style.display = "none";
			objLay2.style.display = "block";
		}
		if (ns4){
			objLay1.visibility = "hide";
			objLay2.visibility = "show";
		}
	}
	SetAllCheckBoxes(frm, fld, status);
}

function getCheckBoxValue(appType, defaultValue){ //v1.5
	var appTypeVal;
	var valFound=false;
	// Loop from zero to the one minus the number of radio button selections
	for (var counter=0; counter<appType.length; counter++){
		if(appType[counter].checked){
			appTypeVal=appType[counter].value;
			valFound=true;
		}
	}
	if(valFound==false) appTypeVal=defaultValue;
	return appTypeVal;
}

function isNumberFloat(inputString){
  return (!isNaN(parseFloat(inputString))) ? true : false;
}

function stringToFloat (inputString){
  return parseFloat(inputString);
}

function loadPopUpWithText(myText, winName, winSettings){
	var np_win;
	np_win=open('',winName,winSettings);
	np_win.document.open();
	np_win.document.write(myText);
	np_win.document.close();
	return np_win;
}

// End -->