

function ChangeDisplay(id, attribute) {		
	document.getElementById(id).style.display = attribute;
}

function ChangeCssClass(id, CssClass) {		
	id.className = CssClass;  
}

function ChangeBackgroundPosition(id, position) {		
	document.getElementById(id).style.backgroundPosition = position; 
}

function ChangeDisplayDelay(id, attribute) {	
	window.setTimeout("ChangeDisplay('" + id + "','" + attribute + "')", 500);	
}

function CharacterCount(text) {
	document.getElementById("character-count").innerHTML = "Character Count: " + text.value.length ;

	if (text.value.length >= 5)
		document.getElementById("character-count").style.color = "red";
}


var profession_index = 1;
var industry_index = 1;
var education_index = 1;
var company_index = 1;
var degreelike_index = 1;
var language_index = 1;
var address_index = 1;
var futureAddress_index = 1;
var myorganization_index = 1;


function elementHideShow(obj, pStr_name, pos) {
	var name = pStr_name + '-';
	var element_index = 0;
	var input_id = pStr_name;
	var ww = pStr_name.valueOf()=='profession' || pStr_name.valueOf()=='industry';
	
	if (ww){
		input_id = input_id + '_wordwheel';
		if (pos != 1) {
			input_id = input_id  + pos;
		}
	} else {
		input_id = input_id  + '-' + pos;
	}
	
	element_index = getIndex(pStr_name);
		
	if (obj.innerHTML.indexOf('-') > 0){
		if (ww){
			document.getElementById(input_id).value= '';
		} else {
			document.getElementById(input_id).style.display='none';
		}	

	}
	else{
		document.getElementById("add-" + name + element_index).innerHTML = "<div class='minus'>&#45;</div>"
		element_index = element_index + 1;
		document.getElementById(name + element_index).style.display = "block";
	}
	
	setIndex(pStr_name, element_index);
}

function setIndex(pStr_name, pi_index) {	
	if (pStr_name == 'profession')
		profession_index = pi_index;
	else if (pStr_name == 'industry')
		industry_index = pi_index;
	else if (pStr_name == 'education')
		education_index = pi_index;
	else if (pStr_name == 'company')
		company_index = pi_index;
	else if (pStr_name == 'degreelike')
		degreelike_index = pi_index;
	else if (pStr_name == 'language')
		language_index = pi_index;
	else if (pStr_name == 'address')
		address_index = pi_index;		
	else if (pStr_name == 'futureAddress')
		futureAddress_index = pi_index;		
	else if (pStr_name == 'myorganization')
		myorganization_index = pi_index;		
}


function getIndex(pStr_name) {	
	if (pStr_name == 'profession')
		return profession_index;
	else if (pStr_name == 'industry')
		return industry_index;
	else if (pStr_name == 'education')
		return education_index;
	else if (pStr_name == 'company')
		return company_index;
	else if (pStr_name == 'degreelike')
		return degreelike_index;
	else if (pStr_name == 'language')
		return language_index;
	else if (pStr_name == 'address')
		return address_index;
	else if (pStr_name == 'futureAddress')
		return futureAddress_index;		
	else if (pStr_name == 'myorganization')
		return myorganization_index;				
	else
		return -1;
}

var submit_event = 0;
function ifSubmit(){
	if (submit_event > 0){
		alert('Form is submitted, please wait.');
		return false;
	}
	else
		submit_event++;
	return true;
}


function associateOnOff(mode) {
    if (mode=="1") {
    	document.getElementById('associate').style.display='none';
    }
    else if (mode=="2"){
    	document.getElementById('associate').style.display='block';
    }
}


function addressOnOff(obj) {
    if (obj.checked==true) {
    	document.getElementById('paymentInfo.address').value = 
    		document.getElementById('postemployer.address1').value;
    	document.getElementById('paymentInfo.address2').value = 
    		document.getElementById('postemployer.address2').value;
    	document.getElementById('paymentInfo.city').value = 
    		document.getElementById('postemployer.city').value;
    	document.getElementById('paymentInfo.state').value = 
    		document.getElementById('postemployer.state').value;
    	document.getElementById('paymentInfo.zip').value = 
    		document.getElementById('postemployer.zip').value;
    }
    else{
    	document.getElementById('paymentInfo.address').value = '';
    	document.getElementById('paymentInfo.address2').value = '';
    	document.getElementById('paymentInfo.city').value = '';
    	document.getElementById('paymentInfo.state').value = '';
    	document.getElementById('paymentInfo.zip').value = '';
    }
}