// JavaScript Document
function pgltPopUp(mypage, myname, w, h, scroll, tool, resize, loc, menubar){
if (navigator.appVersion.indexOf('Mac') != -1 && navigator.appVersion.indexOf('Safari') != -1){
    h+= 9;
    w+= 1;
}
if (navigator.appVersion.indexOf('Mac') != -1 && navigator.appVersion.indexOf('MSIE') != -1){
    h-= 15;
    w-= 15;
}
    var PopUpWin;
    var leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    var topPosition = (screen.height) ? (screen.height-h)/2 : 0;
    var settings = "height = " + h + " ,width = " + w + " ,top = " + topPosition + " ,left = " + leftPosition;
    settings += " ,scrollbars = " + scroll + " ,toolbar = " + tool + " ,resizable = " + resize + " ,location = " + loc + " ,menubar = " + menubar;
    PopUpWin = window.open(mypage, myname, settings);
    //PopUpWin = window.focus();
}
// function for collapsible reference links
function show(list, item_num){
	if (document.getElementById && document.createTextNode){
		m = document.getElementById(list);
		new_display = m.getElementsByTagName("div").item(item_num).style.display;
		if (new_display == "block"){
			new_display="none";
		}else if (new_display=="" || new_display=="none"){
			new_display="block";
		}
		
		m.getElementsByTagName("div").item(item_num).style.display=new_display;
		var	highlighttext = "-";
		var	normaltext = "+";
		
		t=m.getElementsByTagName("b").item(item_num);
		h=t.getElementsByTagName("a").item(0).firstChild;
		if (new_display == "none"){
			h.nodeValue = h.nodeValue.replace(highlighttext,normaltext);
		}else{
			h.nodeValue = h.nodeValue.replace(normaltext,highlighttext);
		}
	}
}





function check_contact_form(){

var eval_ques_arr = ['name', 'email', 'subject', 'message'];
var eval_ques_txt_len = [ 2, 2, 2, 2];
var eval_questitles_arr = ['- Your Name', '- Email', '- Subject', '- Message'];
var ques_total_1 = 0;
var ques_max_1 = eval_ques_arr.length;
var error_msg = "Please complete the following form fields.\nYou missed the following:\n";
	for(a = 0; a < eval_ques_arr.length; a++){
		//
		var check_form_obj = String(eval_ques_arr[a]);
		//alert("form element = " + check_form_obj);
		if(a != 1){
			var notify = check_txt_form(check_form_obj, eval_ques_txt_len[a]);
		}else{
			var notify = check_email_txt(check_form_obj);
		}
		
		if(notify){
			ques_total_1++;
			//alert(check_form_obj + " is checked!");
		}else{
			error_msg = error_msg + String(eval_questitles_arr[a]) + "\n";
		}
	}
	
	if(ques_max_1 == ques_total_1){
		//alert("All user information is complete!!!");
		return status_txt_1 = "complete";
	}else{
		alert(error_msg);
		return status_txt_1 = "incomplete";
	}
}

function contact_validation(){
	// form.submit(); //can be used to manually submit the form if need be
	// status is returned by this function
	check_contact_form();
	// uncomment for testing phase
	// alert("stop to validate this form - " + status);
	
	if(status_txt_1 == "complete"){
		//alert(status_txt_1);
		return true;
	}else{
		return false;
	}

}




function check_request_edu_form(){

var eval_ques_arr = ['your_dis', 'email', 'tressa_sales_person', 'salon_name', 'salon_contact', 'salon_phone', 'salon_address', 'message'];
var eval_ques_txt_len = [ 2, 2, 2, 2, 2, 2, 2, 2];
var eval_questitles_arr = ['- Your Distributor', '- Email', '- Tressa Sales Person', '- Salon Name', '- Salon Contact', '- Salon Phone', '- Salon Address', '- Message'];
var ques_total_1 = 0;
var ques_max_1 = eval_ques_arr.length;
var error_msg = "Please complete the following form fields.\nYou missed the following:\n";
	for(a = 0; a < eval_ques_arr.length; a++){
		//
		var check_form_obj = String(eval_ques_arr[a]);
		//alert("form element = " + check_form_obj);
		if(a != 1){
			var notify = check_txt_form(check_form_obj, eval_ques_txt_len[a]);
		}else{
			var notify = check_email_txt(check_form_obj);
		}
		
		if(notify){
			ques_total_1++;
			//alert(check_form_obj + " is checked!");
		}else{
			error_msg = error_msg + String(eval_questitles_arr[a]) + "\n";
		}
	}
	
	if(ques_max_1 == ques_total_1){
		//alert("All user information is complete!!!");
		return status_txt_1 = "complete";
	}else{
		alert(error_msg);
		return status_txt_1 = "incomplete";
	}
}

function request_edu_validation(){
	// form.submit(); //can be used to manually submit the form if need be
	// status is returned by this function
	check_request_edu_form();
	// uncomment for testing phase
	// alert("stop to validate this form - " + status);
	
	if(status_txt_1 == "complete"){
		//alert(status_txt_1);
		return true;
	}else{
		return false;
	}

}




function check_be_educator_form(){

var eval_ques_arr = ['name', 'email', 'phone', 'message'];
var eval_ques_txt_len = [ 2, 2, 2, 2];
var eval_questitles_arr = ['- Your Name', '- Email', '- Phone', '- Message'];
var ques_total_1 = 0;
var ques_max_1 = eval_ques_arr.length;
var error_msg = "Please complete the following form fields.\nYou missed the following:\n";
	for(a = 0; a < eval_ques_arr.length; a++){
		//
		var check_form_obj = String(eval_ques_arr[a]);
		//alert("form element = " + check_form_obj);
		if(a != 1){
			var notify = check_txt_form(check_form_obj, eval_ques_txt_len[a]);
		}else{
			var notify = check_email_txt(check_form_obj);
		}
		
		if(notify){
			ques_total_1++;
			//alert(check_form_obj + " is checked!");
		}else{
			error_msg = error_msg + String(eval_questitles_arr[a]) + "\n";
		}
	}
	
	if(ques_max_1 == ques_total_1){
		//alert("All user information is complete!!!");
		return status_txt_1 = "complete";
	}else{
		alert(error_msg);
		return status_txt_1 = "incomplete";
	}
}

function be_educator_validation(){
	// form.submit(); //can be used to manually submit the form if need be
	// status is returned by this function
	check_be_educator_form();
	// uncomment for testing phase
	// alert("stop to validate this form - " + status);
	
	if(status_txt_1 == "complete"){
		//alert(status_txt_1);
		return true;
	}else{
		return false;
	}

}

function check_reg_salon_form(){

var eval_ques_arr = ['salon_name', 'address_1', 'city', 'state', 'zip', 'country', 'phone'];
var eval_ques_txt_len = [ 2, 2, 2, 2, 2, 2, 2];
var eval_questitles_arr = ['- Your Salon Name', '- Address', '- City', '- State (Territory)', '- Zip (Postal Code)', '- Country', '- Phone'];
var ques_total_1 = 0;
var ques_max_1 = eval_ques_arr.length;
var error_msg = "Please complete the following form fields.\nYou missed the following:\n";
	for(a = 0; a < eval_ques_arr.length; a++){
		//
		var check_form_obj = String(eval_ques_arr[a]);
		//alert("form element = " + check_form_obj);
		var notify = check_txt_form(check_form_obj, eval_ques_txt_len[a]);
		
		if(notify){
			ques_total_1++;
			//alert(check_form_obj + " is checked!");
		}else{
			error_msg = error_msg + String(eval_questitles_arr[a]) + "\n";
		}
	}
	
	if(ques_max_1 == ques_total_1){
		//alert("All user information is complete!!!");
		return status_txt_1 = "complete";
	}else{
		alert(error_msg);
		return status_txt_1 = "incomplete";
	}
}

function reg_salon_validation(){
	// form.submit(); //can be used to manually submit the form if need be
	// status is returned by this function
	check_reg_salon_form();
	// uncomment for testing phase
	// alert("stop to validate this form - " + status);
	
	if(status_txt_1 == "complete"){
		//alert(status_txt_1);
		return true;
	}else{
		return false;
	}

}





function check_txt_form(ques, txt_len){
var text_value = false;
	for(b = 0; b < this.document.form.elements.length; b++){
		if(this.document.form.elements[b].name == ques){
			//alert("found " + ques);
			if((this.document.form.elements[b].value.length >= txt_len) && (this.document.form.elements[b].value != "")){
				//alert(ques + " checked");
				return text_value = true;
				break;
			}else{
				//alert("nothing in here " + ques);
			}
		}
	}
}

function check_email_txt(field){
	for(b = 0; b < this.document.form.elements.length; b++){
		if(this.document.form.elements[b].name == field){
			with (field){
			apos=this.document.form.elements[b].value.indexOf("@");
			dotpos=this.document.form.elements[b].value.lastIndexOf(".");
			lastpos=this.document.form.elements[b].value.length-1;
				if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2){
				//if (apos<1||dotpos-apos<2){
					return false;
				}else{
					return true;
				}
			}
		}
	}
}