function validPassword(passwordObj)
{
 var pdStr = passwordObj.value;	
  if(pdStr=="")
  	return true;
  else{
  		var mediumRegex = new RegExp("^(?=.{6,})(((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]))).*$", "g");
 
        if(mediumRegex.test(pdStr)){
          return true;
           //alert('Valid password.');
        } else {
            alert('This password is invalid.  Please enter a valid password:\n6 character minimum (at least one lower case letter, \none upper case letter and one numeric digit required).');
            passwordObj.value="";
            passwordObj.focus();
            return true;
        }
      }
}


function varifyPassword(conPasswordObj, passwordObj)
{
  var vpdStr = conPasswordObj.value;	
  var pdStr = passwordObj.value
  if(vpdStr=="")
  {
  	passwordObj.focus();
  	return true;
  }
  else{
	  	if(pdStr=="")
		{
			conPasswordObj.value = "";
			alert('Please create your password in the preceding field,\nand then re-type it in this field to verify it is the one you want.');
	        passwordObj.focus();
		  	return false;
		}
	  	var mediumRegex = new RegExp("^(?=.{6,})(((?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]))).*$", "g");
 
        if(mediumRegex.test(vpdStr)){
	        if(vpdStr!=pdStr)
	        {
	        	 alert('Your password entries do not match!\nPlease re-type your password to verify it is the one you want.');
	             conPasswordObj.value="";
	        	 conPasswordObj.focus();
	             return false;
	        }
	        else{
	        	return true;
	        }
        } else {
            alert('Your password entries do not match!\nPlease re-type your password to verify it is the one you want.');
            conPasswordObj.value="";
            conPasswordObj.focus();
            return false;
        }
  }	
}

function frmSubmit()
{
	password1= document.changePassword.password1.value;
	password2= document.changePassword.password2.value;
	
	 if(password1=="")
	 {
	  alert('This password is invalid.  Please enter a valid password:\n6 character minimum (at least one lower case letter, \none upper case letter and one numeric digit required).');	
	  document.changePassword.password1.focus();
	  return false
	 }
	 
	 if(password2=="")
	 {
	  alert('Your password entries do not match!\nPlease re-type your password to verify it is the one you want.');
	  document.changePassword.password2.focus();
	  return false
	 }
	if(password1!=password2)
	{
	  alert('Your password entries do not match!\nPlease re-type your password to verify it is the one you want.');
	  document.changePassword.password2.focus();
	  return false	
	}
	document.changePassword.submit();
	return true;
}

function ShowHideDivForImage(id){

	if(id == "custom"){

			document.getElementById('system').style.display = 'none';
			document.getElementById('invisible').style.display = 'none';
			document.getElementById('custom').style.display = '';
			document.getElementById('pixel').style.display = 'none';
			document.getElementById("uploadimgcolorpltdiv").style.display = '';

	}else if(id == "system"){
				
			document.getElementById('custom').style.display = 'none';
			document.getElementById('invisible').style.display = 'none';
			document.getElementById('system').style.display = '';
			document.getElementById('pixel').style.display = 'none';
			document.getElementById("uploadimgcolorpltdiv").style.display = 'none';

	}else if(id == "invisible"){
	
			document.getElementById('system').style.display = 'none';
			document.getElementById('invisible').style.display = '';
			document.getElementById('custom').style.display = 'none';
			document.getElementById('pixel').style.display = 'none';
			document.getElementById("uploadimgcolorpltdiv").style.display = 'none';
	}else if(id="pixel"){
	
			document.getElementById('system').style.display = 'none';
			document.getElementById('invisible').style.display = 'none';
			document.getElementById('custom').style.display = 'none';
			document.getElementById('pixel').style.display = '';
			document.getElementById("uploadimgcolorpltdiv").style.display = 'none';
	
	}

}


function showM(mo,txtfld,colordiv) {
	
	document.getElementById(txtfld).value = mo;
	document.getElementById(colordiv).style.background = '#'+mo;
	
	if(txtfld=="backgroundtxtfld"){
		document.getElementById("choosecolor").style.background = '#'+mo;
	}else if(txtfld=="bordertxtfld"){		
		document.getElementById("choosecolor").style.border = '1px #'+mo+' solid';
	}else if(txtfld=="blogpatroltxtfld"){
		document.getElementById("currentTitle").style.color = '#'+mo;
	}else if(txtfld=="visitortxtfld"){
		document.getElementById("currentCount").style.color = '#'+mo;	
	}else{
		document.getElementById("choosecolor").style.background = '#'+mo;	
	}
}

function showI(mo) {

	document.fc1.selectedinvisiblecode.value = mo;
	document.getElementById("chooseinvisible").style.background = '#'+mo;

}


function bordercolorfn(){
   
    document.fc1.bordertxtfld.value = document.fc1.bordertxtfld.value.toUpperCase();
	var fldstr = document.fc1.bordertxtfld.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.bordertxtfld.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){
	document.getElementById('bordercolordiv').style.background = '#'+fldstr;
	document.getElementById('choosecolor').style.border = '1px #'+fldstr+' solid';
	}
}
function visitorcolorfn(){
    
	document.fc1.visitortxtfld.value = document.fc1.visitortxtfld.value.toUpperCase();
	var fldstr = document.fc1.visitortxtfld.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.visitortxtfld.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){
	document.getElementById('visitorcolordiv').style.background = '#'+fldstr;
	document.getElementById('currentCount').style.color = '#'+fldstr;
	}
}

function backgroundcolorfn(){
    
	document.fc1.backgroundtxtfld.value = document.fc1.backgroundtxtfld.value.toUpperCase();
	var fldstr = document.fc1.backgroundtxtfld.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.backgroundtxtfld.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){
	document.getElementById('backgroundcolordiv').style.background = '#'+fldstr;
	document.getElementById('choosecolor').style.background = '#'+fldstr;
	}
}

function blogpatrolcolorfn(){
    document.fc1.blogpatroltxtfld.value = document.fc1.blogpatroltxtfld.value.toUpperCase();
	var fldstr = document.fc1.blogpatroltxtfld.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.blogpatroltxtfld.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){
	document.getElementById('blogpatrolcolordiv').style.background = '#'+fldstr;
	document.getElementById('currentTitle').style.color = '#'+fldstr;
	}
}

function uploadTitlecolorfn(){
    document.fc1.upldbptitle.value = document.fc1.upldbptitle.value.toUpperCase();
	var fldstr = document.fc1.upldbptitle.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.upldbptitle.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){	
	document.getElementById('upldtitdiv').style.background = '#'+fldstr;
	updatePreviewImage();
	}
}
function uploadTitlecolorfn2(){
    document.fc1.upldbptitle2.value = document.fc1.upldbptitle2.value.toUpperCase();
	var fldstr = document.fc1.upldbptitle2.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.upldbptitle2.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){	
	document.getElementById('upldtitdiv2').style.background = '#'+fldstr;
	updatePreviewImage();
	}
}
function uploadVCcolorfn(){
    document.fc1.upldvc.value = document.fc1.upldvc.value.toUpperCase();
	var fldstr = document.fc1.upldvc.value;
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.upldvc.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6){
	document.getElementById('upldvcdiv').style.background = '#'+fldstr;
	updatePreviewImage();
	}
}
function pixelcode(){
    document.fc1.selectedinvisiblecode.value = document.fc1.selectedinvisiblecode.value.toUpperCase();
	var fldstr = document.fc1.selectedinvisiblecode.value;
	
	var fldstrlen= fldstr.length;
	if(fldstr.match(/[\WG-Zg-z]/)){
		
					
		document.fc1.selectedinvisiblecode.value=fldstr.substring(0,(fldstrlen-1));	
				
	}
	if(fldstrlen == 6)
	document.getElementById('chooseinvisible').style.background = '#'+fldstr;
}

function validateFileExtension(fld) {
	if(!/(\.png|\.gif|\.jpg|\.jpeg)$/i.test(fld.value)) {
		alert("Invalid image file type. Please choose only .JPG, .PNG, .JPEG or .PNG file");
		fld.value='';		
		fld.focus();
		document.getElementById("uploadbtn").style.display = 'none';
		return false;
	}else{
		document.getElementById("uploadbtn").style.display = 'inline';
		return true;
	}
}

function upldShowHideDivForImage(id){

	if(id == "upldtitlecolorplt"){
		document.getElementById('upldtitlecolorplt').style.display = 'inline';
		document.getElementById('upldvccolorplt').style.display = 'none';
		document.getElementById('upldtitlecolorplt2').style.display = 'none';
	}else if(id == "upldvccolorplt"){
	
		document.getElementById('upldtitlecolorplt').style.display = 'none';
		document.getElementById('upldvccolorplt').style.display = 'inline';
		document.getElementById('upldtitlecolorplt2').style.display = 'none';
	}else if(id == "upldtitlecolorplt2"){
	
		document.getElementById('upldtitlecolorplt2').style.display = 'inline';
		document.getElementById('upldtitlecolorplt').style.display = 'none';
		document.getElementById('upldvccolorplt').style.display = 'none';
	}
}

function showU(mo,txtfld,colordiv) {
	
	document.getElementById(txtfld).value = mo;
	document.getElementById(colordiv).style.background = '#'+mo;
	updatePreviewImage();
	
}
