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.01
  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 && d.getElementById) x=d.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 Member(value){
	if(value=="1"){
		document.registration1.frmSelectSchool.disabled = false; 
		document.registration1.frmSelectSchool[0].style.color = "#000000";
	}else{
		document.registration1.frmSelectSchool.disabled = true; 
		document.registration1.frmSelectSchool[0].selected = true;
		document.registration1.frmSelectSchool[0].style.color = "#333333";
	}
}

function trim(s) {
    return s.replace(/^\s*|\s*$/g,"");
}

function couleur(obj) {
     obj.style.backgroundColor = "#FFFFFF";
}

function CheckForm1(){
	
	var erreur = false;
	var myFrm = document.registration1;

	if(document.getElementById("radioButtonYes").checked == true){
		if(myFrm.frmSelectSchool.value == ""){
			/*myFrm.frmSelectSchool[0].style.color= "red";
			myFrm.frmSelectSchool[0].style.fontWeight='bold';*/
			document.getElementById("mySchool").style.backgroundColor = "#8ecbd9";
		}else{
			myFrm.submit();
		}
		
	}else{
		myFrm.submit();
	}
}
function verifMail(email){
	var exp = new RegExp("^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,3}$","g");
	return (exp.test(email));
}
function CheckForm2(){
	
	var erreur = false;
	var myFrm = document.registration2;
	var bgColor = "#8ecbd9";
	
	//check first name
	if(trim(myFrm.frmFirstName.value) ==""){
		myFrm.frmFirstName.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//check last name
	if(trim(myFrm.frmLastName.value) ==""){
		myFrm.frmLastName.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//check email
	if(myFrm.frmEmailTeam0.value !=""){
		if(verifMail(trim(myFrm.frmEmailTeam0.value))==false){
			myFrm.frmEmailTeam0.style.backgroundColor = bgColor;
			erreur = true;
		}
	}else{
		myFrm.frmEmailTeam0.style.backgroundColor = bgColor;
		erreur = true;
	}
	//check phone
	if(trim(myFrm.frmPhone.value) ==""){
		myFrm.frmPhone.style.backgroundColor = bgColor;
		erreur = true;
	}
	//check phone
	/*if(trim(myFrm.frmPhone.value) ==""){
		myFrm.frmPhone.style.backgroundColor = bgColor;
		erreur = true;
	}*/
	
	//check mobile
	/*if(trim(myFrm.frmMobile.value) ==""){
		myFrm.frmMobile.style.backgroundColor = bgColor;
		erreur = true;
	}*/
	
	
	if(myFrm.frmMember.value==0){
		//frmSchoolName
		if(trim(myFrm.frmSchoolName.value)==""){
			myFrm.frmSchoolName.style.backgroundColor = bgColor;
			erreur = true;
		}
		//frmSchoolAddress
		if(trim(myFrm.frmSchoolAddress.value)==""){
			myFrm.frmSchoolAddress.style.backgroundColor = bgColor;
			erreur = true;
		}
		//frmSchoolCity
		if(trim(myFrm.frmSchoolCity.value)==""){
			myFrm.frmSchoolCity.style.backgroundColor = bgColor;
			erreur = true;
		}
		//frmSchoolZipCode
		if(trim(myFrm.frmSchoolZipCode.value)==""){
			myFrm.frmSchoolZipCode.style.backgroundColor = bgColor;
			erreur = true;
		}
		//frmSchoolCountry
		if(myFrm.frmSchoolCountry.value == ""){
			/*myFrm.frmSelectSchool[0].style.color= "red";
			myFrm.frmSelectSchool[0].style.fontWeight='bold';*/
			document.getElementById("myCountry").style.backgroundColor = "#8ecbd9";
			document.getElementById("myCountry2").style.backgroundColor = "#8ecbd9";
			erreur = true;
		}
	}
	
	//check First Name academic advisor
	if(trim(myFrm.frmFirstName2.value) ==""){
		myFrm.frmFirstName2.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//check last name academic advisor
	if(trim(myFrm.frmLastName2.value) ==""){
		myFrm.frmLastName2.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//check email academic advisor
	if(trim(myFrm.frmEmail2.value) !=""){
		if(verifMail(trim(myFrm.frmEmail2.value))==false){
			myFrm.frmEmail2.style.backgroundColor = bgColor;
			erreur = true;
		} 
	}else{
		myFrm.frmEmail2.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//phone school
	if(trim(myFrm.frmSchoolPhone.value) ==""){
		myFrm.frmSchoolPhone.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//check approval
	if(myFrm.frmApproval.checked == false){
		document.getElementById("Approval").style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//frmTeamName
	if(trim(myFrm.frmTeamName.value) ==""){
		myFrm.frmTeamName.style.backgroundColor = bgColor;
		erreur = true;
	}
	
	//check mail frmEmailTeam1
	if(trim(myFrm.frmEmailTeam1.value) !=""){
		if(verifMail(trim(myFrm.frmEmailTeam1.value))==false){
			myFrm.frmEmailTeam1.style.backgroundColor = bgColor;
			erreur = true;
		}
	}
	
	//check mail frmEmailTeam2
	if(trim(myFrm.frmEmailTeam2.value) !=""){
		if(verifMail(trim(myFrm.frmEmailTeam2.value))==false){
			myFrm.frmEmailTeam2.style.backgroundColor = bgColor;
			erreur = true;
		}
	}
	
	//check mail frmEmailTeam3
	if(trim(myFrm.frmEmailTeam3.value) !=""){
		if(verifMail(trim(myFrm.frmEmailTeam3.value))==false){
			myFrm.frmEmailTeam3.style.backgroundColor = bgColor;
			erreur = true;
		}
	}
	
	//check mail frmEmailTeam4
	if(trim(myFrm.frmEmailTeam4.value) !=""){
		if(verifMail(trim(myFrm.frmEmailTeam4.value))==false){
			myFrm.frmEmailTeam4.style.backgroundColor = bgColor;
			erreur = true;
		}
	}
	
	//check mail frmEmailTeam5
	if(trim(myFrm.frmEmailTeam5.value) !=""){
		if(verifMail(trim(myFrm.frmEmailTeam5.value))==false){
			myFrm.frmEmailTeam5.style.backgroundColor = bgColor;
			erreur = true;
		}
	}
		
	if(erreur == true){
		document.getElementById("instructionForm").style.color= "red";
		document.getElementById("instructionForm").style.fontWeight='bold';
	}else{
		myFrm.submit();
	}
}

function VerifProfileMember(){
	var erreur = false;
	var myFrm = document.registration2;
	var bgColor = "#8ecbd9";
	
	
}
function ValidateDeleteMembers(myForm){
	if(confirm("Are you sure you want to delete this?")){
		document.getElementById(myForm).submit();
	 }else { return false }
	 //alert("ok");
	
}

function AddMemberTeam(toHide, toShow){
	document.getElementById(toHide).visibility='hidden';
	document.getElementById(toHide).style.display='none';
	document.getElementById(toShow).style.visibility='visible';
	document.getElementById(toShow).style.display='block';
}
var showHide = 0;
function ShowHide(myTarget){
	if(showHide==0){
		document.getElementById(myTarget).style.visibility='visible';
		document.getElementById(myTarget).style.display='block';
		showHide=1;
	}else{
		document.getElementById(myTarget).visibility='hidden';
		document.getElementById(myTarget).style.display='none';
		showHide=0;
	}
	
}
function ShowHide2(myTarget){
	$(".toggled").css("display", "none");
	$("#"+myTarget).css("display", "block");
}
function writeEmail(nom, domaine, suffix, txt, myStyle){

document.write('<a href="' + 'mailto:' + nom + '@' + domaine + '.' + suffix + '"'+ myStyle +'>' + txt + '</a>');

}

function CampaignLink(redirectLink){
	document.getElementById("toUpdateRedirect").value=redirectLink;
	document.getElementById("updateCampaign").submit();
}

function Compter(chaine, formulaire, limit, countWordName) {
	chaine= document.getElementById(chaine).value;
	var exp=new RegExp("[a-zA-Z0-9éèêëàáâäóòôöíìîïçÉÈÊËÀÁÂÄÒÓÔÖÌÍÎÏÇ-]+","g");
	var tabNom=chaine.match(exp);
	//alert(document.getElementById("frmBackground").value);
	if (tabNom==null) {document.getElementById(countWordName).value = 0;} 
	else {
		var affichage=tabNom.length;
		if(affichage>=limit){
			alert("limit reached !");
		}
		if(countWordName!=""){
			document.getElementById(countWordName).value = affichage;
		}
	}
}

function CheckAddMember(){
	var bgColor = "#8ecbd9";
	var erreur = false;
	var myFrm = document.addMembers;

	for (i=1; i<=document.getElementById('numberAddMember').value; i++){
		if(trim(myFrm["frmEmailTeam"+i].value) !=""){
			if(verifMail(trim(myFrm["frmEmailTeam"+i].value))==false){
				myFrm["frmEmailTeam"+i].style.backgroundColor = bgColor;
				erreur = true;
			}
		}
	} 
	if (erreur==true){
		alert("Please check your email!");	
	}
	else{
		document.addMembers.submit();
	}
}
// progress bar
function DoUpload() {
	theFeats = "height=120,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	theUniqueID = (new Date()).getTime() % 1000000000;
	window.open("member_progressbar.asp?ID=" + theUniqueID, theUniqueID, theFeats);
	document.myform.action = "member_progressupload.asp?ID=" + theUniqueID;
	document.myform.submit();
}
function confirmDeleteFile(myTarget,myFile,myType) {

if(confirm("Are you sure you want to delete this? " + myTarget +","+myFile+","+myType)){

 self.location.href="member_campaign7.asp?deleteId=" + myTarget + "&df="+myFile+"&dtf="+myType;

 }/*else{
 return false;
}*/
}






