
// only return 0-9 a-z or A-Z
function ValHandle1(o){
	// hyphen (i.e. \x2D) removed from list of valid characters
  o.value=o.value.replace(/([^0-9A-Za-z])/g,"");
  if (o.value.length > 15) {
	o.value = o.value.substring(0,15);  
	alert("Sorry, Max characters is 15 for username");
  }
}

// only return 0-9 a-z or A-Z
function ValHandle2(o){
  if(/[^0-9A-Za-z]/.test(o.value)){
    o.value=o.value.replace(/([^0-9A-Za-z\x2D])/g,"");
  }
}

// Macromedia Library functions for menu control
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.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=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.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 jump(menu){
  var loc = menu[menu.selectedIndex].value.split("|");
  if(loc.length == 2)
    window.open(loc[1], loc[0]);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// This function tests any text cell for the presence of double width chars
function WidthTest(evt, option) {
	// option 0 = anything allowed
	// option 1 = auto convert double english to single
	// option 2 = error on double width english
	for (count=0; count<=evt.value.length; count++)	{
		teststring = evt.value
		testchar = teststring.substr(count, 1);
		testasc = testchar.charCodeAt()
		// option 1 dbl width english conversion
		if ((testasc > 65295) && (testasc < 65371) && (option == 1)) {
								evt.value = teststring.substr(0, count) + String.fromCharCode(testasc-65248) + teststring.substr(count+1, (teststring.length - (count+1)));
    							}
		// Convert full width Katakana to half width Katakana						
		if ((testasc >= 12450) && (testasc <= 12531) && (option == 1)) {
			//alert(testasc);
			result = "";
			if (testasc == 12450) {result = String.fromCharCode(65393);};
			if (testasc == 12452) {result = String.fromCharCode(65394);};
			if (testasc == 12454) {result = String.fromCharCode(65395);};
			if (testasc == 12456) {result = String.fromCharCode(65396);};
			if (testasc == 12458) {result = String.fromCharCode(65397);};
			
			if (testasc == 12459) {result = String.fromCharCode(65398);};
			if (testasc == 12460) {result = String.fromCharCode(65398) + String.fromCharCode(65438);};
			if (testasc == 12461) {result = String.fromCharCode(65399);};
			if (testasc == 12462) {result = String.fromCharCode(65399) + String.fromCharCode(65438);};
			if (testasc == 12463) {result = String.fromCharCode(65400);};
			if (testasc == 12464) {result = String.fromCharCode(65400) + String.fromCharCode(65438);};
			if (testasc == 12465) {result = String.fromCharCode(65401);};
			if (testasc == 12466) {result = String.fromCharCode(65401) + String.fromCharCode(65438);};
			if (testasc == 12467) {result = String.fromCharCode(65402);};
			if (testasc == 12468) {result = String.fromCharCode(65402) + String.fromCharCode(65438);};

			if (testasc == 12469) {result = String.fromCharCode(65403);};
			if (testasc == 12470) {result = String.fromCharCode(65403) + String.fromCharCode(65438);};
			if (testasc == 12471) {result = String.fromCharCode(65404);};
			if (testasc == 12472) {result = String.fromCharCode(65404) + String.fromCharCode(65438);};
			if (testasc == 12473) {result = String.fromCharCode(65405);};
			if (testasc == 12474) {result = String.fromCharCode(65405) + String.fromCharCode(65438);};
			if (testasc == 12475) {result = String.fromCharCode(65406);};
			if (testasc == 12476) {result = String.fromCharCode(65406) + String.fromCharCode(65438);};
			if (testasc == 12477) {result = String.fromCharCode(65407);};
			if (testasc == 12478) {result = String.fromCharCode(65407) + String.fromCharCode(65438);};

			if (testasc == 12479) {result = String.fromCharCode(65408);};
			if (testasc == 12480) {result = String.fromCharCode(65408) + String.fromCharCode(65438);};
			if (testasc == 12481) {result = String.fromCharCode(65409);};
			if (testasc == 12482) {result = String.fromCharCode(65409) + String.fromCharCode(65438);};
			if (testasc == 12484) {result = String.fromCharCode(65410);};
			if (testasc == 12485) {result = String.fromCharCode(65410) + String.fromCharCode(65438);};
			if (testasc == 12486) {result = String.fromCharCode(65411);};
			if (testasc == 12487) {result = String.fromCharCode(65411) + String.fromCharCode(65438);};
			if (testasc == 12488) {result = String.fromCharCode(65412);};
			if (testasc == 12489) {result = String.fromCharCode(65412) + String.fromCharCode(65438);};

			if (testasc == 12490) {result = String.fromCharCode(65413);};
			if (testasc == 12491) {result = String.fromCharCode(65414);};
			if (testasc == 12492) {result = String.fromCharCode(65415);};
			if (testasc == 12493) {result = String.fromCharCode(65416);};
			if (testasc == 12494) {result = String.fromCharCode(65417);};

			if (testasc == 12495) {result = String.fromCharCode(65418);};
			if (testasc == 12496) {result = String.fromCharCode(65418) + String.fromCharCode(65438);};
			if (testasc == 12497) {result = String.fromCharCode(65418) + String.fromCharCode(65439);};
			if (testasc == 12498) {result = String.fromCharCode(65419);};
			if (testasc == 12499) {result = String.fromCharCode(65419) + String.fromCharCode(65438);};
			if (testasc == 12500) {result = String.fromCharCode(65419) + String.fromCharCode(65439);};
			if (testasc == 12501) {result = String.fromCharCode(65420);};
			if (testasc == 12502) {result = String.fromCharCode(65420) + String.fromCharCode(65438);};
			if (testasc == 12503) {result = String.fromCharCode(65420) + String.fromCharCode(65439);};
			if (testasc == 12504) {result = String.fromCharCode(65421);};
			if (testasc == 12505) {result = String.fromCharCode(65421) + String.fromCharCode(65438);};
			if (testasc == 12506) {result = String.fromCharCode(65421) + String.fromCharCode(65439);};
			if (testasc == 12507) {result = String.fromCharCode(65422);};
			if (testasc == 12508) {result = String.fromCharCode(65422) + String.fromCharCode(65438);};
			if (testasc == 12509) {result = String.fromCharCode(65422) + String.fromCharCode(65439);};

			if (testasc == 12510) {result = String.fromCharCode(65423);};
			if (testasc == 12511) {result = String.fromCharCode(65424);};
			if (testasc == 12512) {result = String.fromCharCode(65425);};
			if (testasc == 12513) {result = String.fromCharCode(65426);};
			if (testasc == 12514) {result = String.fromCharCode(65427);};

			if (testasc == 12516) {result = String.fromCharCode(65428);};
			if (testasc == 12517) {result = String.fromCharCode(65429);};
			if (testasc == 12518) {result = String.fromCharCode(65429);};
			if (testasc == 12519) {result = String.fromCharCode(65430);};
			if (testasc == 12520) {result = String.fromCharCode(65430);};

			if (testasc == 12521) {result = String.fromCharCode(65431);};
			if (testasc == 12522) {result = String.fromCharCode(65432);};
			if (testasc == 12523) {result = String.fromCharCode(65433);};
			if (testasc == 12524) {result = String.fromCharCode(65434);};
			if (testasc == 12525) {result = String.fromCharCode(65435);};

			if (testasc == 12526) {result = String.fromCharCode(65436);};
			if (testasc == 12527) {result = String.fromCharCode(65436);};
			if (testasc == 12530) {result = String.fromCharCode(65382);};
			if (testasc == 12531) {result = String.fromCharCode(65437);};
					
			if (result != "") {		
					resultstring = teststring.substr(0, count) + result + teststring.substr(count+1, (teststring.length - (count+1)));
					evt.value = resultstring;
					//alert(result.charCodeAt());
								}
								}
		// option 2 dbl width english error						
		if ((testasc > 65295) && (testasc < 65371) && (option == 2)) {
								alert("<%=WebTextCart(7)%>");
									// No Double Width Chars Allowed!
								evt.value = "";
								evt.focus();
								evt.focus();
    							}

													}
}

//------------------------------ This for tree menu --------------------------------------
function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
	 
   if (visible) {
     obj.style.display="none";
   } else {
      obj.style.display="block";
   }
}

function Toggle_Menu_Ins_old(item, imagefolder, style, level) {
	obj=document.getElementById(item);
	visible=(obj.style.display!="none")
	key=document.getElementById("X" + item);
	if (style == '2') {
		if (level == '2') {
		   imagefileExpand = imagefolder+"expand2.gif"
		   imagefileCollapse = imagefolder+"collapse2.gif"
		} else {
		   imagefileExpand = imagefolder+"expand1.gif"
		   imagefileCollapse = imagefolder+"collapse1.gif"
		}
	} else {
	   imagefileExpand = imagefolder+"expand.gif"
	   imagefileCollapse = imagefolder+"collapse.gif"
	}
	if (visible) {
	 obj.style.display="none";
	 key.innerHTML="<img src='"+imagefileExpand+"' border=0>";
	} else {
	  obj.style.display="block";
	  key.innerHTML="<img src='"+imagefileCollapse+"' border=0>";
	}
}

function Toggle_Menu_Ins(item, imagefolder) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("X" + item);
   imagefileExpand = imagefolder+"expand1.gif"
   imagefileCollapse = imagefolder+"collapse1.gif"
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='"+imagefileExpand+"' border=0>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='"+imagefileCollapse+"' border=0>";
   }
}


function Toggle_Menu_Ins2(item, imagefolder) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("X" + item);
   imagefileExpand = imagefolder+"expand2.gif"
   imagefileCollapse = imagefolder+"collapse2.gif"
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='"+imagefileExpand+"' border=0>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='"+imagefileCollapse+"' border=0>";
   }
}

function show_help(item) {
	obj=document.getElementById(item);
	if(obj != null)
		obj.style.display="inline";
}

function hide_help(item) {
	obj=document.getElementById(item);
	if(obj != null)
		obj.style.display="none";
}
/*function Expand() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="block";
     key=document.getElementById("X" + divs[i].id);
     key.innerHTML="<img src='/clientinc/template0/colapse.gif' border=0>";
   }
}

function Collapse() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="none";
     key=document.getElementById("X" + divs[i].id);
     key.innerHTML="<img src='/clientinc/template0/expand.gif' border=0>";
   }
}*/

/* BookMark URL Used on the Members Promotion Tips Page */

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

/* Limit Max Chars */

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

/* Refresh Page */
function timedPageRefresh(timePeriod) {
	setTimeout("location.reload(true);",timePeriod);
}


function number_format(number, decimals, dec_point, thousands_sep) {

var n = number, prec = decimals;

var toFixedFix = function (n,prec) {
    var k = Math.pow(10,prec);
    return (Math.round(n*k)/k).toString();
};

n = !isFinite(+n) ? 0 : +n;
prec = !isFinite(+prec) ? 0 : Math.abs(prec);
var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;

var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;

var abs = toFixedFix(Math.abs(n), prec);
var _, i;

if (abs >= 1000) {
    _ = abs.split(/\D/);
    i = _[0].length % 3 || 3;

    _[0] = s.slice(0,i + (n < 0)) +
          _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
    s = _.join(dec);
} else {
    s = s.replace('.', dec);
}

var decPos = s.indexOf(dec);
if (prec >= 1 && decPos !== -1 && (s.length-decPos-1) < prec) {
    s += new Array(prec-(s.length-decPos-1)).join(0)+'0';
}
else if (prec >= 1 && decPos === -1) {
    s += dec+new Array(prec).join(0)+'0';
}
return s; }


