
function profilesInit(){
	document.profilesPath = "/images/doors/profiles/";
	document.doorProfileImage = document.getElementById('doorProfileImage');
	
	document.profilesParent = document.getElementById('profileStickingOptions');
	document.profilesOptions = document.profilesParent.getElementsByTagName("p");
	document.profiles = new Array();
	
	for(i=0;i<=document.profilesOptions.length-1;i++){
		inputChildObj = document.profilesOptions[i].getElementsByTagName("input");
		inputChildVal = inputChildObj[0].value;
		
		textChildObj = document.profilesOptions[i].getElementsByTagName("span");
		textChildVal =	textChildObj[0].innerHTML;
		document.profiles[inputChildVal] = textChildVal;
		
		}
	}

	



function swapProfile(elName,elVal){
		
	if(elName == "panelOptions"){
		oppositeElName = "stickingOptions";
		}
	else{
		oppositeElName = "panelOptions";
		}	
		
	otherOptionBlock = document.getElementsByName(oppositeElName);
	for(i=0;i<=otherOptionBlock.length-1;i++){
		
			if(otherOptionBlock[i].checked == true){
				otherOptionVal = otherOptionBlock[i].value;
				}

		}
		
	profileImg = new Image();	
	(oppositeElName == "stickingOptions") ? profileImg.src = document.profilesPath + elVal + "-" + otherOptionVal + ".jpg" : profileImg.src = document.profilesPath +  otherOptionVal + "-" + elVal  + ".jpg";	
		
	document.doorProfileImage.src = profileImg.src;
	
	
	document.doorPanelTextParent = document.getElementById("selectedPanelOption");
	document.doorPanelTextParentSpans = document.doorPanelTextParent.getElementsByTagName("span");
	document.doorPanelTextParentSpan = document.doorPanelTextParentSpans[0];
	document.doorPanelText = document.doorPanelTextParentSpan.innerHTML;
	
	document.doorStickingTextParent = document.getElementById("selectedStickingOption");
	document.doorStickingTextParentSpans = document.doorStickingTextParent.getElementsByTagName("span");
	document.doorStickingTextParentSpan = document.doorStickingTextParentSpans[0];
	document.doorStickingText = document.doorStickingTextParentSpan.innerHTML;

	
	if(oppositeElName == "stickingOptions"){
		if(document.doorPanelText != document.profiles[elVal]){
			newSpan = document.createElement("span");
			newText = document.createTextNode(document.profiles[elVal]);
			newSpan.appendChild(newText);
			
			document.doorPanelTextParent.replaceChild(newSpan,document.doorPanelTextParentSpan);
			
			}
			
		if(document.doorStickingText != document.profiles[otherOptionVal]){
			newSpan = document.createElement("span");
			newText = document.createTextNode(document.profiles[otherOptionVal]);
			newSpan.appendChild(newText);
			
			document.doorStickingTextParent.replaceChild(newSpan,document.doorStickingTextParentSpan);
			}	
			
		}
	else{
		if(document.doorPanelText != document.profiles[otherOptionVal]){
			newSpan = document.createElement("span");
			newText = document.createTextNode(document.profiles[otherOptionVal]);
			newSpan.appendChild(newText);
			
			document.doorPanelTextParent.replaceChild(newSpan,document.doorPanelTextParentSpan);
			
			}
			
		if(document.doorStickingText != document.profiles[elVal]){
			newSpan = document.createElement("span");
			newText = document.createTextNode(document.profiles[elVal]);
			newSpan.appendChild(newText);
			
			document.doorStickingTextParent.replaceChild(newSpan,document.doorStickingTextParentSpan);
			}	
			
		}	
	}	



