var id = 1;
var id1 = 1;
var id2 = 1;
var count = 0;
var count1 = 0;
var count2 = 0;

function CollapseAll() {
	document.getElementById('BasicInformation0').style.display = 'none'; document.getElementById('BasicInformation1').style.padding = '0 0 0 10px';
	document.getElementById('ProfilePicture0').style.display = 'none'; document.getElementById('ProfilePicture1').style.padding = '0 0 0 10px';
	document.getElementById('EducationWork0').style.display = 'none'; document.getElementById('EducationWork1').style.padding = '0 0 0 10px';
	document.getElementById('Art0').style.display = 'none'; document.getElementById('Art1').style.padding = '0 0 0 10px';
	document.getElementById('Philosophy0').style.display = 'none'; document.getElementById('Philosophy1').style.padding = '0 0 0 10px';
	document.getElementById('Entertainment0').style.display = 'none'; document.getElementById('Entertainment1').style.padding = '0 0 0 10px';
	document.getElementById('ActivitiesInterests0').style.display = 'none'; document.getElementById('ActivitiesInterests1').style.padding = '0 0 0 10px';
	document.getElementById('ContactInformation0').style.display = 'none'; document.getElementById('ContactInformation1').style.padding = '0 0 0 10px';

	return true;
}

function calcHeight(frame) {
	var theHeight = document.getElementById(frame).contentWindow.document.body.scrollHeight;

	document.getElementById(frame).height = theHeight + 45;
	
	return true;
}

function submitFrame(myvar) {
	var myframe = document.getElementById(myvar).contentWindow.document;
	
	myframe.getElementById('myform').submit();
	
	return false;
}

function verifyData(myvar,username) {
	var myframe = document.getElementById(myvar).contentWindow.document;
	var error = '';
	
	if(myvar == 'BasicInformation') {
		if((myframe.getElementsByName('username')[0].value != username) && (!myframe.getElementsByName('username')[0].value.match(/^[-a-zA-Z_]{1,15}$/))) error='Your username must be letters only and be 2 to 15 characters.';
		if(!myframe.getElementsByName('email')[0].value.match(/^[-.0-9a-zA-Z_]+@[-.0-9a-zA-Z]+$/)) error='You must provide a legitimate e-mail.';
		if((myframe.getElementsByName('password1')[0].value != 'nochange') && (myframe.getElementsByName('password1')[0].value != '')) {
			if(!myframe.getElementsByName('password1')[0].value.match(/(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/)) error='Error:  Weak Password!\r\n\r\nYour password must contain at least one upper-case letter, one lower-case letter, and a number or special character.  Your password must be at least 8 characters long.';
			else if(myframe.getElementsByName('password1')[0].value != myframe.getElementsByName('password2')[0].value) error='Your passwords do not match!  Please type the same password in both password boxes.';
		}
		if(!myframe.getElementsByName('name_first')[0].value.match(/^[-A-Z a-z]{2,32}$/)) error='Your first name must be letters only and be 2 to 32 characters.';
		if(!myframe.getElementsByName('name_last')[0].value.match(/^[-A-Z a-z]{2,16}$/)) error='Your last name must be letters only and be 2 to 16 characters.';
		if(!myframe.getElementsByName('sex')[0].value.match(/^[A-Z a-z,]{0,32}$/)) error='You must choose either Male or Female.\r\n\r\nNOTE:  You can still hide your gender by selecting \'hide\' to the right.';
		if((myframe.getElementsByName('birthdate_month')[0].value < 1) ||
			(myframe.getElementsByName('birthdate_month')[0].value > 12)) error='You must select the month you were born.\r\n\r\nNOTE:  You can still hide your birthdate by selecting \'hide\' to the right.';
		if((myframe.getElementsByName('birthdate_date')[0].value < 1) ||
			(myframe.getElementsByName('birthdate_month')[0].value > 31)) error='You must select the day you were born.\r\n\r\nNOTE:  You can still hide your birthdate by selecting \'hide\' to the right.';
		if((myframe.getElementsByName('birthdate_year')[0].value < 1930) ||
			(myframe.getElementsByName('birthdate_year')[0].value > 2000)) error='You must select the year you were born.\r\n\r\nNOTE:  You can still hide your birthdate by selecting \'hide\' to the right.\r\n\r\nIn addition, you must be 13 years or older to use this site.';
		if(!myframe.getElementsByName('hometown')[0].value.match(/^[A-Z a-z,]{0,32}$/)) error='Your hometown must be letters only and be 32 characters max.';
		if(!myframe.getElementsByName('city')[0].value.match(/^[A-Z a-z]{0,16}$/)) error='Your current city must be letters only and be 16 characters max.';
		if(!myframe.getElementsByName('languages')[0].value.match(/^[-A-Z a-z,]{0,64}$/)) error='Your languages must be letters only and be 64 characters max.';
		if(!myframe.getElementsByName('relationship')[0].value.match(/^[A-Za-z]{0,8}$/)) error='Invalid relationship data.';
		if(!myframe.getElementsByName('profession')[0].value.match(/^[A-Z a-z,.]{0,32}$/)) error='Your profession must be letters only and be 32 characters max.';
		if(!myframe.getElementsByName('biography')[0].value.match(/^[-A-Z a-z0-9,\"\',.!@$%^*:;()_=/\r\n]{0,2048}$/)) error='Your biography is either too long or contains an illegal character.  Max length is 2,048 characters.\r\n\r\nNOTE:  You may not use HTML.';	
	}
	
	if(myvar == 'ProfilePicture') {
		if(myframe.getElementsByName('data')[0].value.length == 0) {
			error='You must select a file to upload.';
			myframe.getElementById('fakeButton').display = 'none';
			myframe.getElementById('realButton').display = 'block';
		}
	}
	
	if(myvar == 'EducationWork') {
		if(!myframe.getElementsByName('employer')[0].value.match(/^[A-Z a-z-,.]{0,64}$/)) error='Your employer must be letters only and be 64 characters max.';
		if(!myframe.getElementsByName('position')[0].value.match(/^[A-Z a-z-,.()]{0,64}$/)) error='Your position must be letters only and be 64 characters max.';
		if(!myframe.getElementsByName('highschool')[0].value.match(/^[A-Z a-z,.]{0,64}$/)) error='Your high school must be letters only and be 64 characters max.';
		if((myframe.getElementsByName('highschool')[0].value != '') && (!myframe.getElementsByName('highschool_gradyear')[0].value.match(/^[1-2]{1}[0|9]{1}[0-9]{2}$/))) error='Your high school graduation year must be a valid four-digit year.';
		for(var i = 1; i < id+1; i++) {
			if((myframe.getElementsByName('college'+i)[0].value.length != 0) && (!myframe.getElementsByName('college'+i)[0].value.match(/^[A-Z a-z\(\)]{0,64}$/))) { error='Your university must be letters only.  Max 64 letters.'; break; }
			if((myframe.getElementsByName('college'+i)[0].value.length != 0) && (!myframe.getElementsByName('college_gradyear'+i)[0].value.match(/^[1-2]{1}[0|9]{1}[0-9]{2}$/))) { error='Your university graduation year must be a valid four-digit year.'; break; }
			if((myframe.getElementsByName('college'+i)[0].value.length != 0) && (!myframe.getElementsByName('degree'+i)[0].value.match(/^[A-Z a-z',.()]{0,64}$/))) { error='Your university degree must be letters only.  Max 64 letters.'; break; }
		}
	}
	
	if(myvar == 'Art') {
		if(!myframe.getElementsByName('art_styles')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your art styles must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('favourite_art_style')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your favourite art styles must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('tools_of_the_trade')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your art tools of the trade must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('favourite_artists')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your favourite artists must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('favourite_writer')[0].value.match(/^[A-Z a-z,]{0,32}$/)) error='Your writer must be letters only and be 32 characters max.';
		if(!myframe.getElementsByName('favourite_photography_style')[0].value.match(/^[A-Z a-z,]{0,32}$/)) error='Your favourite photography style must be letters only and be 32 characters max.';
		if(!myframe.getElementsByName('favourite_characters')[0].value.match(/^[A-Z a-z,.]{0,128}$/)) error='Your favourite characters must be letters only and be 128 characters max.';
	}
	
	if(myvar == 'Philosophy') {
		if(!myframe.getElementsByName('religion')[0].value.match(/^[A-Z a-z\\(\\)]{0,32}$/)) error='Religion must be letters only and be 32 characters max.';
		if(!myframe.getElementsByName('political_views')[0].value.match(/^[A-Z a-z\\(\\)]{0,32}$/)) error='Political views must be letters only and be 32 characters max.';
		if(!myframe.getElementsByName('inspiration')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your inspiration must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('favourite_quotes')[0].value.match(/^[-0-9A-Z a-z,.?!:;\"\'\\(\\)\r\n]{0,1024}$/)) error='Your quotes must be letters and basic punctuation only and be 1,024 characters max.';
	}
	
	if(myvar == 'Entertainment') {
		if(!myframe.getElementsByName('favourite_music')[0].value.match(/^[A-Z a-z0-9,]{0,256}$/)) error='Your favourite music must be letters only and be 256 characters max.';
		if(!myframe.getElementsByName('favourite_books')[0].value.match(/^[-A-Z a-z:,]{0,256}$/)) error='Your favourite books must be letters only and be 256 characters max.';
		if(!myframe.getElementsByName('favourite_movies')[0].value.match(/^[-A-Z a-z0-9:,]{0,256}$/)) error='Your movies must be letters only and be 256 characters max.';
		if(!myframe.getElementsByName('favourite_television_shows')[0].value.match(/^[-A-Z a-z0-9:,]{0,256}$/)) error='Your favourite television shows must be letters only and be 256 characters max.';
		if(!myframe.getElementsByName('favourite_games')[0].value.match(/^[-A-Z a-z0-9:,]{0,256}$/)) error='Your favourite games must be letters only and be 256 characters max.';
		if(!myframe.getElementsByName('sports')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your sports must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('favourite_teams')[0].value.match(/^[A-Z a-z0-9,]{0,128}$/)) error='Your favourite teams must be letters only and be 128 characters max.';
		if(!myframe.getElementsByName('favourite_athletes')[0].value.match(/^[A-Z a-z,]{0,128}$/)) error='Your favourite athletes must be letters only and be 128 characters max.';
	}
	
	if(myvar == 'ActivitiesInterests') {
		if(!myframe.getElementsByName('activities')[0].value.match(/^[A-Z a-z0-9!.,\"\'\\(\\)]{0,1024}$/)) error='Your activities must be letters and/or numbers only and be 1,024 characters max.';
		if(!myframe.getElementsByName('interests')[0].value.match(/^[A-Z a-z0-9!.,\"\'\\(\\)]{0,1024}$/)) error='Your interests must be letters and/or numbers only and be 1,024 characters max.';
	}
	
	if(myvar == 'ContactInformation') {
		if(!myframe.getElementsByName('address')[0].value.match(/^[A-Z a-z0-9,\\(\\)]{0,255}$/)) error='Your address must be letters and numbers only and be 255 characters max.';
		if(!myframe.getElementsByName('state')[0].value.match(/^[A-Z a-z]{0,16}$/)) error='Your state/province must be letters only and be 16 characters max.';
		if(!myframe.getElementsByName('country')[0].value.match(/^[A-Za-z]{0,2}$/)) error='Your country code must be letters only and be 2 characters max.';
		if(!myframe.getElementsByName('zip')[0].value.match(/^[-A-Z a-z0-9]{0,16}$/)) error='Your zip must be letters only and be 16 characters max.';
		if(!myframe.getElementsByName('neighborhood')[0].value.match(/^[A-Z a-z]{0,16}$/)) error='Your neighborhood must be letters only and be 16 characters max.';
		if(!myframe.getElementsByName('website')[0].value.match(/^[-a-zA-Z_.:\/]{0,255}$/)) error='Your website MUST be in this format:  \'http://www.website.com/whatever_else\'  Max 128 characters.';
		if(!myframe.getElementsByName('city')[0].value.match(/^[A-Z a-z]{0,16}$/)) error='Your city must be letters only and be 16 characters max.';
		for(var i = 1; i < id+1; i++) {
			if((myframe.getElementsByName('email'+i)[0].value.length != 0) && (!myframe.getElementsByName('email'+i)[0].value.match(/^[-.0-9a-zA-Z_]+@[-.0-9a-zA-Z]+$/))) { error='Your e-mail must be valid or blank.  Max 64 characters.'; break; }
		}
		for(i = 1; i < id1+1; i++) {
			if((myframe.getElementsByName('im'+i)[0].value.length != 0) && (!myframe.getElementsByName('im'+i)[0].value.match(/^[A-Za-z0-9@.-]{0,32}$/))) { error='Your instant messenger account must be letters only.  Max 32 characters.'; break; }
			if((myframe.getElementsByName('im'+i)[0].value.length != 0) && (!myframe.getElementsByName('im_engine'+i)[0].value.match(/^[A-Za-z]{1,16}$/))) { error='You must select a valid instant messenger client.'; break; }
		}
		for(i = 1; i < id2+1; i++) {
			if((myframe.getElementsByName('phone'+i)[0].value.length != 0) && (!myframe.getElementsByName('phone'+i)[0].value.match(/^[+]{0,1}[0-9-\(\)]{0,24}$/))) { error='Your phone number must be numbers only (parenthesis and + is allowed).  Max 15 numbers.'; break; }
			if((myframe.getElementsByName('phone'+i)[0].value.length != 0) && (!myframe.getElementsByName('phone_engine'+i)[0].value.match(/^[A-Za-z]{1,12}$/))) { error='You must select a valid phone type.'; break; }
		}
	}

	if(error != '') {
		alert(error);
		
		return false;
	}
	
	return true;
}				

function addCollegeInput(recordId, college, gradYear, degree) {
	var myString;
	
	if(college == undefined) college = '';
	if(gradYear == undefined) gradYear = '';
	if(degree == undefined) degree = '';
	if(recordId == undefined) recordId = 0;
	
	if(count > 2) return true;
	
	if(id == 1) myString = '';
	if(id > 1) myString = "<br id='bra"+ id +"'/>";
	myString += "<input type='text' id='college"+ id +"' name='college"+ id +"' value='"+ college +"'> <input id='college_gradyear"+ id +"' type='text' name='college_gradyear"+ id +"' value='"+ gradYear +"' style='width : 50px;'><br id='brb" + id +"'/>";
	if(degree != '') myString += "<input type='text' id='degree" + id +"' name='degree" + id +"' value=\"" + degree +"\" style='width : 210px;'> ";
	else if(degree == '') myString += "<input type='text' id='degree"+ id +"' name='degree"+ id +"' style='width : 210px;'> ";
	if(recordId > 0) myString += "<input type='hidden' name='college_record"+ id +"' value='"+ recordId + "'>";
	else if(recordId == 0) myString += "<input type='hidden' name='college_record"+ id +"' value='0'>";
	//myString += "<a href='#' onclick='addCollegeInput();' id='collegeAdd"+ id +"' style='font-weight : normal;'>[Add]</a> ";
	//myString += "<a href='#' onclick='deleteCollegeInput("+ id +");' id='collegeDelete"+ id +"' style='font-weight : normal;'>[Remove]</a>";

	document.getElementById('collegeControl').innerHTML += myString; 

	//if(document.getElementById('college' + id) == '') document.getElementById('college' + id).value = 'College';
	//if(document.getElementById('college_GradYear' + id) == '') document.getElementById('college_GradYear' + id).value = 'Grad Year';
	//if(document.getElementById('degree' + id) == '') document.getElementById('degree' + id).value = 'Degree';
	
	parent.calcHeight('EducationWork');
	
	id++;
	count++;

	return true;
}

function deleteCollegeInput(id0) {
	var exists = 0;
	
	if(count == 1) return true;
	
	for(i = 1; i < id0; i++) {
		if(document.getElementById('college'+id0).style.display != 'none') {
			exists = 1;
			break;
		}
	}
	
	document.getElementById('college'+id0).style.display = 'none';
	document.getElementById('college_gradyear'+id0).style.display = 'none';
	document.getElementById('degree'+id0).style.display = 'none';
	document.getElementById('collegeAdd'+id0).style.display = 'none';
	document.getElementById('collegeDelete'+id0).style.display = 'none';
	document.getElementById('college'+id0).value = '';
	if(document.getElementById('bra'+id0) != null) document.getElementById('bra'+id0).style.display = 'none';
	if(document.getElementById('brb'+id0) != null) document.getElementById('brb'+id0).style.display = 'none';
	
	if(exists == 0) {
		for(var i = id0; i < id+1; i++) {
			if(document.getElementById('bra'+i) != null) {
				if(document.getElementById('bra'+i).style.display != 'none') {
					document.getElementById('bra'+i).style.display = 'none';
				
					break;
				}
			}
		}
	}
	
	count--;
	
	parent.calcHeight('EducationWork');
	
	return true;
}

function addEmailInput(recordId, email) {
	var myString;
	
	if(email == undefined) email = '';
	if(recordId == undefined) recordId = 0;
	
	if(count > 2) return true;
	
	if(id == 1) myString = '';
	if(id > 1) myString = "<br id='bra"+ id +"'/>";
	myString += "<input type='text' id='email"+ id +"' name='email"+ id +"' value='"+ email +"'> ";
	if(recordId > 0) myString += "<input type='hidden' name='email_record"+ id +"' value='"+ recordId + "'>";
	else if(recordId == 0) myString += "<input type='hidden' name='email_record"+ id +"' value='0'>";
	//myString += "<a href='#' onclick='addEmailInput();' id='emailAdd"+ id +"' style='font-weight : normal;'>[Add]</a> ";
	//myString += "<a href='#' onclick='deleteEmailInput("+ id +");' id='emailDelete"+ id +"' style='font-weight : normal;'>[Remove]</a>";

	document.getElementById('emailControl').innerHTML += myString; 
	
	parent.calcHeight('ContactInformation');
	
	id++;
	count++;

	return true;
}

function deleteEmailInput(id0) {
	var exists = 0;
	
	if(count == 1) return true;
	
	for(i = 1; i < id0; i++) {
		if(document.getElementById('email'+id0).style.display != 'none') {
			exists = 1;
			break;
		}
	}
	
	document.getElementById('email'+id0).style.display = 'none';
	document.getElementById('emailAdd'+id0).style.display = 'none';
	document.getElementById('emailDelete'+id0).style.display = 'none';
	document.getElementById('email'+id0).value = '';
	if(document.getElementById('bra'+id0) != null) document.getElementById('bra'+id0).style.display = 'none';
	
	if(exists == 0)
	{
		for(var i = id0; i < id+1; i++) {
			if(document.getElementById('bra'+i) != null) {
				if(document.getElementById('bra'+i).style.display != 'none') {
					document.getElementById('bra'+i).style.display = 'none';
			
					break;
				}
			}
		}
	}
	
	count--;
	
	parent.calcHeight('ContactInformation');
	
	return true;
}

function addImInput(recordId, account, service) {
	var myString;
	
	if(account == undefined) account = '';
	if(service == undefined) service = '';
	if(recordId == undefined) recordId = 0;
	
	if(count1 > 6) return true;
	
	if(id1 == 1) myString = '';
	if(id1 > 1) myString = "<br id='brb"+ id1 +"'/>";
	myString += "<input type='text' id='im"+ id1 +"' name='im"+ id1 +"' value='"+ account +"'>  " +
				"<select id='im_engine"+ id1 +"' name='im_engine"+ id1 +"'>" +
				"<option value=''>Please select</option>" +
				"<option value='AOL'"; if(service == 'AOL') myString += " selected='selected'"; myString += ">AIM - AOL Instant Messenger</option>" +
				"<option value='ICQ'"; if(service == 'ICQ') myString += " selected='selected'"; myString += ">ICQ - I Seek You</option>" +
				"<option value='Microsoft'"; if(service == 'Microsoft') myString += " selected='selected'"; myString += ">MSN - Microsoft Network</option>" +
				"<option value='Skype'"; if(service == 'Skype') myString += " selected='selected'"; myString += ">Skype</option>" +
				"<option value='Yahoo'"; if(service == 'Yahoo') myString += " selected='selected'"; myString += ">YIM - Yahoo Instant Messenger</option>" +
				"<option value='Google'"; if(service == 'Google') myString += " selected='selected'"; myString += ">Google - Google Chat</option>" +
				"<option value='Jabber'"; if(service == 'Jabber') myString += " selected='selected'"; myString += ">Jabber - Jabber/XMPP</option>" +
				"</select> ";
	if(recordId > 0) myString += "<input type='hidden' name='im_record"+ id1 +"' value='"+ recordId + "'>";
	else if(recordId == 0) myString += "<input type='hidden' name='im_record"+ id1 +"' value='0'>";
	//myString += "<a href='#' onclick='addImInput();' id='imAdd"+ id1 +"' style='font-weight : normal;'>[Add]</a> ";
	//myString += "<a href='#' onclick='deleteImInput("+ id1 +");' id='imDelete"+ id1 +"' style='font-weight : normal;'>[Remove]</a>";

	document.getElementById('imControl').innerHTML += myString; 
	
	parent.calcHeight('ContactInformation');
	
	id1++;
	count1++;

	return true;
}

function deleteImInput(id0) {
	var exists = 0;
	
	if(count1 == 1) return true;
	
	for(i = 1; i < id0; i++) {
		if(document.getElementById('im'+id0).style.display != 'none') {
			exists = 1;
			break;
		}
	}
	
	document.getElementById('im'+id0).style.display = 'none';
	document.getElementById('im_engine'+id0).style.display = 'none';
	document.getElementById('imAdd'+id0).style.display = 'none';
	document.getElementById('imDelete'+id0).style.display = 'none';
	document.getElementById('im'+id0).value = '';
	if(document.getElementById('brb'+id0) != null) document.getElementById('brb'+id0).style.display = 'none';
	
	if(exists == 0) {
		for(var i = id0; i < id1+1; i++) {
			if(document.getElementById('brb'+i) != null) {
				if(document.getElementById('brb'+i).style.display != 'none') {
					document.getElementById('brb'+i).style.display = 'none';
				
					break;
				}
			}
		}
	}
	
	count1--;
	
	parent.calcHeight('ContactInformation');
	
	return true;
}

function addPhoneInput(recordId, phone, type) {
	var myString;
	
	if(phone == undefined) phone = '';
	if(type == undefined) type = '';
	if(recordId == undefined) recordId = 0;
	
	if(count2 > 2) return true;
	
	if(id2 == 1) myString = '';
	if(id2 > 1) myString = "<br id='brc"+ id2 +"'/>";
	myString += "<input type='text' id='phone"+ id2 +"' name='phone"+ id2 +"' value='"+ phone +"'>  " +
				"<select id='phone_engine"+ id2 +"' name='phone_engine"+ id2 +"'>" +
				"<option value=''>Please select</option>" +
				"<option value='Landline'"; if(type == 'Landline') myString += " selected='selected'"; myString += ">Landline</option>" +
				"<option value='Cellphone'"; if(type == 'Cellphone') myString += " selected='selected'"; myString += ">Cellphone</option>" +
				"<option value='Fax'"; if(type == 'Fax') myString += " selected='selected'"; myString += ">Fax</option>" +
				"</select> ";
	if(recordId > 0) myString += "<input type='hidden' name='phone_record"+ id2 +"' value='"+ recordId + "'>";
	else if(recordId == 0) myString += "<input type='hidden' name='phone_record"+ id2 +"' value='0'>";
	//myString += "<a href='#' onclick='addPhoneInput();' id='phoneAdd"+ id2 +"' style='font-weight : normal;'>[Add]</a> ";
	//myString += "<a href='#' onclick='deletePhoneInput("+ id2 +");' id='phoneDelete"+ id2 +"' style='font-weight : normal;'>[Remove]</a>";

	document.getElementById('phoneControl').innerHTML += myString; 
	
	parent.calcHeight('ContactInformation');
	
	id2++;
	count2++;

	return true;
}

function deletePhoneInput(id0) {
	var exists = 0;
	
	if(count2 == 1) return true;
	
	for(i = 1; i < id0; i++) {
		if(document.getElementById('phone'+id0).style.display != 'none') {
			exists = 1;
			break;
		}
	}
	
	document.getElementById('phone'+id0).style.display = 'none';
	document.getElementById('phone_engine'+id0).style.display = 'none';
	document.getElementById('phoneAdd'+id0).style.display = 'none';
	document.getElementById('phoneDelete'+id0).style.display = 'none';
	document.getElementById('phone'+id0).value = '';
	if(document.getElementById('brc'+id0) != null) document.getElementById('brc'+id0).style.display = 'none';

	if(exists == 0) {
		for(var i = id0; i < id2+1; i++) {
			if(document.getElementById('brc'+i) != null) {
				if(document.getElementById('brc'+i).style.display != 'none') {
					document.getElementById('brc'+i).style.display = 'none';
			
					break;
				}
			}
		}
	}
		
	count2--;
	
	parent.calcHeight('ContactInformation');
	
	return true;
}

