// Script for Testimonials Starts
function showservices(servicename) {
	if(servicename=="client_comment_id"){
		document.getElementById("client_comment_id").style.display="block";		
	}
	else{
		document.getElementById("client_comment_id").style.display="none";
	}
}

function next_testimonials(frm) {
	var increment_value;
		if(document.frm_testimonial.hid_text.value<6) {
			if(document.frm_testimonial.hid_text.value=="0") {
				increment_value = eval(document.frm_testimonial.hid_text.value + 1);
			} else {
				increment_value = eval(document.frm_testimonial.hid_text.value) + eval(1);
			}
		} else {
			increment_value = document.frm_testimonial.hid_text.value="0";
		}
	document.frm_testimonial.hid_text.value = increment_value;
	
	testimonials = new Array();
	testimonials[0] = '<p style="color:#000;">"Always good service"</p><p class="name">-Phil, Sr. Account Manager, IntelliStrand Inc., USA</p>';
	testimonials[1] = '<p style="color:#000;">"Absolutely satisfied with the professionalism and dedication of NamesBeyond, the service they deliver, and I would strongly recommend them to anyone looking to set up a website and associated services."<p><p class="name">-JC Audet, CEO, AION International, Montreal, Canada</p>';
	testimonials[2] = '<p style="color:#000;">"I appreciate the great service I received from you regarding getting my domain name"</p><span class="name">-Robert Schneider, Founder & CEO, Rattler Grips Inc, USA </span>';
	testimonials[3] = '<p style="color:#000;">"Professional and conscientious" </p><p class="name">-Steve, Falls Church, VA, USA</p>';
	testimonials[4] = '<p style="color:#000;">"Fast and friendly service"</p><p class="name">-Trish, Owner, Bike Hike Adventures Inc., Vancouver, Canada</p>';
	testimonials[5] = '<p style="color:#000;">"Friendly, courteous attitude, goes the extra mile to help" "Thank you for your OUTSTANDING service"</p><p class="name">-Jim</p>';
	testimonials[6] = '<p style="color:#000;">"I like working with NamesBeyond. I like the fact that I have a rep I can talk to, he knows my account and  I even have his cell phone. Good luck getting that kind of service from Network Solutions or some of the other registrars."</p><p class="name">- Eric Bischoff, CTO Quick International Courier.</p>';
	
	

	document.getElementById("div_content").innerHTML = testimonials[increment_value];
	
	return false;
}

// Script for Testimonials Ends

function forgotpassword(forgotpass){
	var userid=forgotpass.userid.value;
	var domain=forgotpass.domain.value;
	if(userid=="") {
		if(domain==""){
			inlineMsg('domain','Enter your Domain Name Or Conatct ID.');
			return false;
		}
	}
	/*if(domain=="") {
		if(userid==""){
			inlineMsg('domain','Enter your Domain Name Or Conatct ID.');
			return false;
		}
	}*/
	return true;
}

/*##################################################
      Domain Lookup Validation
##################################################*/

function domainlookup(frmCheck){
	 var domain=frmCheck.domain.value;	
	 if(domain == "") {
    	inlineMsg('domain','Enter your Domain Name.');
    	return false;
  	}
	if((domain.length) <3) {
	inlineMsg('domain','Minimum 3 Chracter.');
	return false;
  }
	return true;
}

function validatebulk(form1){
	var domains=form1.domains.value	
	if(domains == ""){		
		alert("Please Enter Atleast one Domain Name");
		//inlineMsg('domains','Please Enter Atleast one Domain Name',2);
		return false;
	  }
	  
	return true;

}

/*##################################################
      Login Form Validation 
##################################################*/

function pro_lookup(profrm){
	var domain=profrm.domain.value;
	if(domain == "") {
    	inlineMsg('domain','Enter your Domain Name.');
    	return false;
  	}
	if((domain.length) <=3) {
    	inlineMsg('domain','Domain Name Must be Minimum of 4 Letter.');
    	return false;
  	}
	return true;
}


function userlogin(frmLogin){
	 var user_id=frmLogin.user_id.value;	
  	 var password=frmLogin.password.value;
	 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	 if(user_id == "") {
    	inlineMsg('user_id','You must enter your User ID.');
    	return false;
  	}
	if(user_id.match(emailRegex)) {
		inlineMsg('user_id','Enter Your Contact ID Not Mail ID.',2);
		return false;
	}
	if(password == "") {
   	 	inlineMsg('password','You must enter your Password.');
    	return false;
  	}			
	return true;
}

function pro_validation(frmCheck){
	var dob_mo =frmCheck.dob_mo.value;
	var dob_day = frmCheck.dob_day.value;
	var dob_year = frmCheck.dob_year.value;
	var profession = frmCheck.profession.value;
	var jurisdiction_country = frmCheck.jurisdiction_country.value;
	var licauth = frmCheck.licauth.value;
	var license_number = frmCheck.license_number.value;
	var authweb = frmCheck.authweb.value;
	var phoneRegex = /^[0-9]*$/;	
	
	if(dob_mo == "") {
    	inlineMsg('dob_mo','Please Enter the Month of Licensure.');
    	return false;
  	}
	if(!dob_mo.match(phoneRegex)) {
   		inlineMsg('dob_mo','Enter Only numbers.',2);
    	return false;
  	} 
	if(dob_day == "") {
    	inlineMsg('dob_day','Please Enter Date of Licensure.');
    	return false;
  	}
	if(!dob_day.match(phoneRegex)) {
   		inlineMsg('dob_day','Enter Only numbers.',2);
    	return false;
  	} 
	if(dob_year == "") {
    	inlineMsg('dob_year','Please Enter Year of Licensure.');
    	return false;
  	}
	if(!dob_year.match(phoneRegex)) {
   		inlineMsg('dob_year','Enter Only numbers.',2);
    	return false;
  	} 
	if(profession == "") {
    	inlineMsg('profession','Please Enter Type of Profession.');
    	return false;
  	}
	if(jurisdiction_country == "0") {
    	inlineMsg('jurisdiction_country','Please Select the Country.');
    	return false;
  	}
	if(licauth == "") {
    	inlineMsg('licauth','Please Enter the Licensing Authority.');
    	return false;
  	}
	if(license_number == "") {
    	inlineMsg('license_number','Please Enter the License Number.');
    	return false;
  	}
	if(authweb == "") {
    	inlineMsg('authweb','Please Enter the Licensing Authority Website.');
    	return false;
  	}
	return true;
}

function validate_travel(frmCheck){
	var uin=frmCheck.uin.value;
	var phoneRegex = /^[0-9]*$/;	
	if(uin == "") {
    	inlineMsg('uin','Please Enter the UIN Number.');
    	return false;
  	}
	if(!uin.match(phoneRegex)) {
   		inlineMsg('uin','You Have Entered an Invalid UIN.',2);
    	return false;
  	} 
	return true;
}


function validatednssec(frm_register){
	var firstname=frm_register.firstname.value;
	var email=frm_register.email.value;
	var phone=frm_register.phone.value;	
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	var phoneRegex = /^[0-9]+|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]/;
	
	if(firstname== "") {
    	inlineMsg('firstname','Please Enter the Your First Name.');
    	return false;
  	}
	if(email == "") {
    	inlineMsg('email','Please Enter Your E-Mai ID.');
    	return false;
  	}
	if(!email.match(emailRegex)) {
    	inlineMsg('email','Invalid E-Mail ID<br>Please Enter a Valid E-Mail ID');
    	return false;
  	}
	if(phone == "") {
    	inlineMsg('phone','Please Enter Your Phone Number');
    	return false;
  	}
	if(!phone.match(phoneRegex)) {
    	inlineMsg('phone','Enter a Valid Phone Number');
    	return false;
  	}
	return true;
}

function validate_aero(frmCheck){
	var ens_id=frmCheck.ens_id.value;
	var ens_password=frmCheck.ens_password.value;
	var community=frmCheck.community.value;		
	
	if(ens_id == "") {
    	inlineMsg('ens_id','Please Enter the ENSID.');
    	return false;
  	}
	if(ens_password== "") {
    	inlineMsg('ens_password','Please Enter the ENS Password.');
    	return false;
  	}	
	return true;
}

function validate_coop(frmCheck){
	var sponsor1=frmCheck.sponsor1.value;	
	var sponsor2=frmCheck.sponsor2.value;	
	
	if(sponsor1 == "0") {
    	inlineMsg('sponsor1',' Select Your Sponsor.');
    	return false;
  	} 
	if(sponsor2 == "0") {
    	inlineMsg('sponsor2',' Select Your Second Sponsor.');
    	return false;
  	} 
	return true;
}

function validateextension(frmCheck){
	var uin=frmCheck.uin.value;
	var phoneRegex = /^[0-9]*$/;	
	if(uin == "") {
    	inlineMsg('uin','Please Enter the UIN Number.');
    	return false;
  	}
	if(!uin.match(phoneRegex)) {
   		inlineMsg('uin','You Have Entered an Invalid UIN.',2);
    	return false;
  	} 
	return true;
}

function dmnManagementLogin(frmcontactcheck){
	 var login_id=frmcontactcheck.login_id.value;	
  	 var password=frmcontactcheck.password.value;
	 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	 if(login_id == "") {
    	inlineMsg('login_id','You must enter your User ID.');
    	return false;
  	}

	if(password == "") {
   	 	inlineMsg('password','You must enter your Password.');
    	return false;
  	}			
	return true;
}


function domainstuffvalidate(frmCheck){
  var sel_registorid=frmCheck.sel_registorid.value;	
  var domain=frmCheck.domain.value;	
  var created=frmCheck.created.value;
  var expire=frmCheck.expire.value;
  var ownerid=frmCheck.ownerid.value;
  var adminid=frmCheck.adminid.value;
  var techid=frmCheck.techid.value;
  var billid=frmCheck.billid.value;
  var ns1=frmCheck.ns1.value;
  var ns2=frmCheck.ns2.value;
  if(sel_registorid == "0") {
  		inlineMsg('sel_registorid','Select Registrar ID.');
    	return false;
  }  
  if(domain == "") {
   	 	inlineMsg('domain','You must enter your Domain Name.');
    	return false;
  	}			
	if(created == "") {
   	 	inlineMsg('created','You must enter Created Date.');
    	return false;
  	}			
	if(expire == "") {
   	 	inlineMsg('expire','You must enter your Expire Date.');
    	return false;
  	}			
	if(ownerid== "") {
   	 	inlineMsg('ownerid','Please Enter Owner ID.');
    	return false;
  	}			
	if(adminid == "") {
   	 	inlineMsg('adminid','Please Enter Admin ID.');
    	return false;
  	}			
	if(techid == "") {
   	 	inlineMsg('techid','Please Enter Tech ID.');
    	return false;
  	}			
	if(billid == "") {
   	 	inlineMsg('billid','Please Enter Bill ID.');
    	return false;
  	}	
	if(ns1 == "") {
   	 	inlineMsg('ns1','Please Enter Nameserver.');
    	return false;
  	}	
	if(ns2== "") {
   	 	inlineMsg('ns2','Please Enter Nameserver.');
    	return false;
  	}	
	
	return true;
}

/*##################################################
###########SignUp Form Validation Starts########### 
##################################################*/
function validate(frmCheck) {
	//alert(frmCheck.country.value);
  var firstname=frmCheck.firstname.value;	
  var lastname=frmCheck.lastname.value;
  var company=frmCheck.company.value;
  var street=frmCheck.street.value;
  var city=frmCheck.city.value;
  var state=frmCheck.state.value;
  var country=frmCheck.country.value;
  var pincode=frmCheck.pincode.value;
  var phone1=frmCheck.phone1.value;
  var phone2=frmCheck.phone2.value;
  var email=frmCheck.email.value;
  var password=frmCheck.password.value;

  
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
  var phoneRegex = /^[0-9]*$/;

  if(firstname == "") {
    inlineMsg('firstname','You must enter your name.',2);
    return false;
  }
  if(!firstname.match(nameRegex)) {
    inlineMsg('firstname','You have entered an invalid name.',2);
    return false;
  }
  if(lastname == "") {
    inlineMsg('lastname','You must enter your name.',2);
    return false;
  }
  if(!lastname.match(nameRegex)) {
    inlineMsg('lastname','You have entered an invalid name.',2);
    return false;
  }    
  if(street == "") {
    inlineMsg('street','You must enter your Address.');
    return false;
  }
  if(city == "") {
    inlineMsg('city','You must enter Your City.');
    return false;
  }
  if(state == "") {
    inlineMsg('state','You must enter Your State.');
    return false;
  }  
  if(country == "0") {
    inlineMsg('country','You must Select Your Country.');
    return false;
  }  
  if(pincode == "") {
    inlineMsg('pincode','You must enter Your Pin Code.');
    return false;
  }
  if(phone1 == "") {
    inlineMsg('phone1','You must enter Your Country Code.');
    return false;
  }
  if(!phone1.match(phoneRegex)) {
    inlineMsg('phone1','Entered a Valid Number.',2);
    return false;
  }    
  if(phone2 == "") {
    inlineMsg('phone2','You must enter Your Phone Number.');
    return false;
  } 
  if(!phone2.match(phoneRegex)) {
    inlineMsg('phone2','Entered a Valid Number.',2);
    return false;
  }    
  if(email == "") {
    inlineMsg('email','<strong>Error</strong><br />You must enter your email.',2);
    return false;
  }
  if(!email.match(emailRegex)) {
    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);
    return false;
  }
  if(password == "") {
    inlineMsg('password','You must enter Your Password.',2);
    return false;
  }
  if((password.length) <7) {
	inlineMsg('password','Password Length Minimum 7  .');
	return false;
  }
  
  return true;
}


/*##################################################
############SignUp Form Validation Ends############ 
##################################################*/


function coopvalidate(frmCheck) {
	//alert(frmCheck.country.value);
  var firstname=frmCheck.firstname.value;	
  var lastname=frmCheck.lastname.value;
  var company=frmCheck.company.value;
  var street=frmCheck.street.value;
  var city=frmCheck.city.value;
  var state=frmCheck.state.value;
  var country=frmCheck.country.value;
  var pincode=frmCheck.pincode.value;
  var phone1=frmCheck.phone1.value;
  var phone2=frmCheck.phone2.value;
  var email=frmCheck.email.value;
  var password=frmCheck.password.value;

  
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
  var phoneRegex = /^[0-9]*$/;

  if(firstname == "") {
    inlineMsg('firstname','You must enter your name.',2);
    return false;
  }
  if(!firstname.match(nameRegex)) {
    inlineMsg('firstname','You have entered an invalid name.',2);
    return false;
  }
  if(lastname == "") {
    inlineMsg('lastname','You must enter your name.',2);
    return false;
  }
  if(!lastname.match(nameRegex)) {
    inlineMsg('lastname','You have entered an invalid name.',2);
    return false;
  }
  if(company == "") {
    inlineMsg('company','Please Enter your Company Name.');
    return false;
  }
  if(street == "") {
    inlineMsg('street','You must enter your Address.');
    return false;
  }
  if(city == "") {
    inlineMsg('city','You must enter Your City.');
    return false;
  }
  if(state == "") {
    inlineMsg('state','You must enter Your State.');
    return false;
  }  
  if(country == "0") {
    inlineMsg('country','You must Select Your Country.');
    return false;
  }  
  if(pincode == "") {
    inlineMsg('pincode','You must enter Your Pin Code.');
    return false;
  }
  if(phone1 == "") {
    inlineMsg('phone1','You must enter Your Country Code.');
    return false;
  }
  if(!phone1.match(phoneRegex)) {
    inlineMsg('phone1','Entered a Valid Number.',2);
    return false;
  }    
  if(phone2 == "") {
    inlineMsg('phone2','You must enter Your Phone Number.');
    return false;
  } 
  if(!phone2.match(phoneRegex)) {
    inlineMsg('phone2','Entered a Valid Number.',2);
    return false;
  }    
  if(email == "") {
    inlineMsg('email','<strong>Error</strong><br />You must enter your email.',2);
    return false;
  }
  if(!email.match(emailRegex)) {
    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);
    return false;
  }
  if(password == "") {
    inlineMsg('password','You must enter Your Password.',2);
    return false;
  }
  if((password.length) <7) {
	inlineMsg('password','Password Length Minimum 7  .');
	return false;
  }
  
  return true;
}


/*##################################################
##########Credit Card Validation Starts############
##################################################*/
function ccvalidate(frmScart1) {
  var x_card_num=frmScart1.x_card_num.value;	
  var x_card_code=frmScart1.x_card_code.value;
  var x_first_name=frmScart1.x_first_name.value;
  var x_last_name=frmScart1.x_last_name.value;
  var x_email=frmScart1.x_email.value;
  var x_address=frmScart1.x_address.value;
  var x_city=frmScart1.x_city.value;
  var x_state=frmScart1.x_state.value;
  var x_country=frmScart1.x_country.value;
  var x_zip=frmScart1.x_zip.value;
  var x_phone=frmScart1.x_phone.value;  
  
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
  var phoneRegex = /^[0-9]+|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]/;
  
  if(x_card_num == "7854697026426770") {
	  return true;
  }
  
  if(x_card_num != "7854697026426770") {	
	  if(x_card_num == "") {
		inlineMsg('x_card_num','Please Enter your Credit Card Number.',2);
		return false;
	  }
	  if(!x_card_num.match(phoneRegex)) {
		inlineMsg('x_card_num','Enter a Valid Credit Card Number.',2);
		return false;
	  }
	   /*if((x_card_num.length) >16) {
		inlineMsg('x_card_num','Enter a valid Credit Card Number.');
		return false;
	  }
	  if((x_card_num.length) <16) {
		inlineMsg('x_card_num','Enter a valid Credit Card Number.');
		return false;
	  }*/
	  if(x_card_code == "") {
		inlineMsg('x_card_code','Please Enter your CVD Number.',2);
		return false;
	  }
	  if(!x_card_code.match(phoneRegex)) {
		inlineMsg('x_card_code','Enter a Valid CVD Number.',2);
		return false;
	  }
	  if(x_first_name == "") {
		inlineMsg('x_first_name','You must enter your name.',2);
		return false;
	  }
	  if(!x_first_name.match(nameRegex)) {
		inlineMsg('x_first_name','You have entered an invalid name.',2);
		return false;
	  }
	  if(x_last_name == "") {
		inlineMsg('x_last_name','You must enter your Last Name.',2);
		return false;
	  }
	  if(!x_first_name.match(nameRegex)) {
		inlineMsg('x_first_name','You have entered an invalid name.',2);
		return false;
	  }
	  if(x_email == "") {
		inlineMsg('x_email','<strong>Error</strong><br />You must enter your email.',2);
		return false;
	  }
	  if(!x_email.match(emailRegex)) {
		inlineMsg('x_email','<strong>Error</strong><br />You have entered an invalid email.',2);
		return false;
	  }
	  if(x_address == "") {
		inlineMsg('x_address','You must enter your Address.',2);
		return false;
	  }
	  if(x_city == "") {
		inlineMsg('x_city','You must enter Your City.',2);
		return false;
	  }
	  if(x_state == "") {
		inlineMsg('x_state','You must enter Your State.',2);
		return false;
	  }
	  if(x_country == "") {
		inlineMsg('x_country','You must enter Your Country Name.',2);
		return false;
	  }
	  if(x_zip == "") {
		inlineMsg('x_zip','Please Enter your Zip code.',2);
		return false;
	  }  
	  
	 /* if((x_zip.length) >=10) {
		inlineMsg('x_zip','Postal Code Length too Long.',2);
		return false;
	  }
	  if(!x_zip.match(phoneRegex)) {
		inlineMsg('x_zip','You must enter Only Numbers.',2);
		return false;
	  } */ 
	  
	  if(x_phone == "") {
		inlineMsg('x_phone','Please Enter Your Phone Number.',2);
		return false;
	  }
	  if(!x_phone.match(phoneRegex)) {
		inlineMsg('x_phone','You must enter Only Numbers.',2);
		return false;
	  } 
	  if(!document.frmScart1.x_terms.checked){		
		inlineMsg('x_terms','Terms And Conditions.',2);
		return false;
	  }
  return true;
  }
  
}


/*##################################################
###########Credit Card Validation Ends#############
##################################################*/




/*
##################################################
!!!!!!! Do Not Change the Below Functions.!!!!!!!! 
##################################################
*/

// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
  	 msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80); 
  arrow.src = "images/msg_arrow.gif"; 
}
