function checkLength(str)
{
        var len = str.length;
        if(len < 6)
        {
                return false;
        }
        else
        {
                return true;
        }
}
function IsBlank( str ) {
        var isValid = false;
         if ( IsNull(str) || IsUndef(str) || (str+"" == "") )
                 isValid = true;
        return isValid;
}
function IsUndef( val ) {
        var isValid = false;
         if (val+"" == "undefined")
                 isValid = true;
        return isValid;
}
function IsNull( val ) {
        var isValid = false;
         if (val+"" == "null")
                 isValid = true;
        return isValid;
}
function IsAlpha( str ) {
        if (str+"" == "undefined" || str+"" == "null" || str+"" == "")
                return false;
        var isValid = true;
                str += "";
          for (i = 0; i < str.length; i++) {
                if ( !( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
                              ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ) ) {
                                         isValid = false;
                                         break;
                              }
   }
        return isValid;
}
function IsValidEmail( str ) {
        if (str+"" == "undefined" || str+"" == "null" || str+"" == "")
                return false;
        var isValid = true;        str += "";namestr = str.substring(0, str.indexOf("@"));
        domainstr = str.substring(str.indexOf("@")+1, str.length);
           if (IsBlank(str) || (namestr.length == 0) ||(domainstr.indexOf(".") <= 0) ||(domainstr.indexOf("@") != -1) ||!IsAlpha(str.charAt(str.length-1)))
                {isValid = false;return isValid;}
}

function aTOz(c)
{
if((c>="a"&&c<="z")||(c>="A"&&c<="Z")) return true;
return false;
}
function Match(frm)
{
  var n=frm.email.value.indexOf("@");
  var m=frm.email.value.indexOf(".");
  var l=frm.email.value.length-1;
  var ln=frm.desc.value.length;
  var x=m>n?m-n:n-m;
  if(l==m||l==n) x=0;
  if(ln>80) 
   {
     alert("Decription should be less than 80 chars");
     return false;
   }
  if(frm.email.value.length == 0) {
  alert("Invalid email address");
  frm.email.focus();
  return(false);}

  if (frm.email.value.indexOf("@") == -1) {
  alert("Invalid email address");
  frm.email.focus();
  return(false);}
  
  if(frm.name.value=="") {
  alert("User name can not be blank");
  frm.name.focus();
  return(false);}

  if(frm.img.value=="") {
  alert("Screenshot Required");
  frm.name.focus();
  return(false);}
  
  if(frm.img.value.indexOf(".bmp") > 1) {
  alert("Invalid image format. Only .jpg, gif, and .png is allowed.");
  frm.name.focus();
  return(false);}
    
 if(frm.pass.value!=frm.rpass.value||frm.pass.value==""){
 alert("Password not matched");
 frm.pass.focus();
 return(false);}
    /*
 if(==false) {
  alert("Enter a valis e-mail address "+frm.email.value);
  frm.email.focus();
  return(false);}
  */
  
  return IsValidEmil(frm.email.value);
  
 return(true);
}
function launchwin(URL, name, pram){
window.open(URL, name, pram)
}


window.onload = function(){
  //(document.getElementById("maxcharfield"),"progressbar2",20)(textCounter)
}

window.onload = function(){
  //(document.getElementById("maxcharfield"),"progressbar1",49)(textCounter)
}



function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth = parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
