
var W3CDOM1 = (document.getElementById && document.getElementsByTagName);
document.curV  = -1;

if(W3CDOM1){
	var jsStyle = "";
	
	jsStyle += '<style type="text/css">';
	jsStyle += 'div.order div.hideThis {display:none;}\n';
	jsStyle += 'div.formE div.fileInput input.file {text-align:right;\n margin:0 0 5px 0 !important;\n width:226px !important; visibility:hidden;\n position: absolute;\n!important;\n z-index:2;\n left:10px;\n top 0;\n font-size:14px;height:20px;}';
	jsStyle += '</style>';
	
	document.write(jsStyle);
}

function onLoadFx() {
	if(document.getElementById('supermodelForm') && W3CDOM1){ supermodelForm(); }
	searchFocus();
	selectedFolder();
	selectedAcs();
	slideShow();
	formElements();
	if(document.getElementById('nltStep1')){ nltForm(); }
	if(document.getElementById('orderForm') && W3CDOM1){ orderForm(); }	
}



//###################################################################################
function supermodelForm() {
	var iFile = document.getElementById('supermodelForm').getElementsByTagName('input');
	for(var ifCn = 0; ifCn < iFile.length; ifCn++){
		if(iFile[ifCn].type != 'file') continue;
		
		var ifHolder = iFile[ifCn].parentNode;
		ifHolder.style.postion = 'relative';
		
		iFile[ifCn].style.opacity = 0;
		iFile[ifCn].style.filter = 'alpha(opacity=0)';
		iFile[ifCn].style.visibility = 'visible';
		iFile[ifCn].id = "file" + ifCn;
		
		var fkIn = ifHolder.appendChild(document.createElement('div'));
		fkIn.id = "fakefile" + ifCn;
		fkIn.innerHTML = "";
		fkIn.className = "fakeInput";
		
		var fkImg = ifHolder.appendChild(document.createElement('img'));
		fkImg.className = "fakeInBtn";
		fkImg.src = '/Static/images/gui/si/btn_image_select.gif';
		fkImg.id = 'fkImg' + ifCn;
		
		var fkClrBtn = document.createElement('input');
			fkClrBtn.type = "button";			
			fkClrBtn.className = "fakeClearBtn";
			fkClrBtn.id = "e" + ifCn;
			
		var fkClr = ifHolder.appendChild(fkClrBtn);
		
		iFile[ifCn].onchange = function () {
			var x = new Array();
			x = this.value.split(/\\/);
			var i = x.length - 1;
			var imgName = x[i];
			document.getElementById("fake" + this.id).innerHTML = imgName;
		}
		
		iFile[ifCn].onmouseover = function () {
			var idNum = this.id.replace(/file/, '');
			document.getElementById('fkImg' + idNum).style.opacity = 0.7;
			document.getElementById('fkImg' + idNum).style.filter = 'alpha(opacity=70)';
			//console.log(idNum);
		}
		iFile[ifCn].onmouseout = function () {
			var idNum = this.id.replace(/file/, '');
			document.getElementById('fkImg' + idNum).style.opacity = 1;
			document.getElementById('fkImg' + idNum).style.filter = 'alpha(opacity=100)';
			//console.log(idNum);
		}
		
		fkClr.onclick = function () {
			var finp = document.getElementById("fil" + this.id);
			var finId = finp.id;
			var finName = finp.name;
			this.parentNode.removeChild(finp);
			var inFile = document.createElement('input');
				inFile.id = finId;
				inFile.type = "file";
				inFile.name = finName;
			var thisInFile = this.parentNode.appendChild(inFile);
				thisInFile.className = "file";
				thisInFile.style.visibility = "visible";
				thisInFile.style.opacity = 0;
				thisInFile.style.filter = 'alpha(opacity=0)';
				
				thisInFile.onchange = function () {
					var x = new Array();
					//if(this.value.match('\\')){
						x = this.value.split('\\');
					/*} else if (this.value.match('/')){
						x = this.value.split('/');
					}*/
					var i = x.length - 1;
					var imgName = x[i];
					document.getElementById("fake" + this.id).innerHTML = imgName;
				}
				thisInFile.onmouseover = function () {
					var idNum = this.id.replace(/file/, '');
					document.getElementById('fkImg' + idNum).style.opacity = 0.7;
					document.getElementById('fkImg' + idNum).style.filter = 'alpha(opacity=70)';
				}
				thisInFile.onmouseout = function () {
					var idNum = this.id.replace(/file/, '');
					document.getElementById('fkImg' + idNum).style.opacity = 1;
					document.getElementById('fkImg' + idNum).style.filter = 'alpha(opacity=100)';
				}
			document.getElementById("fake" + finId).innerHTML = '';
		}
		
		if(iFile[ifCn].className.match(/error/)) {
			fkIn.style.borderColor = "#E2017B";
		}
		
	}
}

//###################################################################################
function orderForm() {	
	inputs = new Array();
	divs = new Array();
	inputs = document.getElementById('orderForm').getElementsByTagName('input');
	divs = document.getElementById('orderForm').getElementsByTagName('div');
	document.globDivs = divs;
	for(var inCn = 0; inCn < inputs.length; inCn++){
		if(!((inputs[inCn].type == 'radio') || (inputs[inCn].type == 'checkbox'))) continue;
		
		for(diCn = 0; diCn < divs.length; diCn++){
			
			if(('rel_' + inputs[inCn].id) != divs[diCn].id) continue;
			if(inputs[inCn].type == 'checkbox'){
				if(inputs[inCn].checked) cbClicked(inputs[inCn]);
				inputs[inCn].onclick = function () {
					var sd, hd;
					if(this.checked){
						if(sd = document.getElementById('rel_' + this.id))sd.style.display = "block";
						if(hd = document.getElementById('hide_' + this.id))hd.style.display = "none";
					}else {
						if(sd = document.getElementById('rel_' + this.id))sd.style.display = "none";
						if(hd = document.getElementById('hide_' + this.id))hd.style.display = "block";
					}
				}
			} else {
				myRadios = new Array();
				myRadios = document.getElementsByName(inputs[inCn].name);
				for(mrCn = 0; mrCn < myRadios.length; mrCn++){
					var sd, hd;
					if(sd = document.getElementById('rel_' + this.id)){}
					if(hd = document.getElementById('hide_' + this.id)){}
					myRadios[mrCn].onclick = function () {
						for(var mr2Cn = 0; mr2Cn < myRadios.length; mr2Cn++){
							if(myRadios[mr2Cn] == this){
								if(sd) sd.style.display = "block";
								if(hd) hd.style.display = "none";
							} else {
								if(sd) sd.style.display = "none";
								if(hd) hd.style.display = "block";
							}
						}
						if(myRadios[mrCn].checked) radioClicked(myRadios[mrCn]);
					//END.onclick 
					}
					
				}	
			}
		}
	}
}
function cbClicked (selectedCb) {
	var sd, hd;
	if(selectedCb) {
		thisss = new Object();
		thisss = selectedCb;
		if(sd = document.getElementById('rel_' + thisss.id)){}
		if(hd = document.getElementById('hide_' + thisss.id)){}
		if(thisss.checked){
			if(sd) sd.style.display = "block";
			if(hd) hd.style.display = "none";
		}else {
			if(sd) sd.style.display = "none";
			if(hd) hd.style.display = "block";
		}
	}
}
function radioClicked (selectedRadio) {
	thiss = new Object();
	if(selectedRadio){
		thiss = selectedRadio;
	
		for(mr2Cn = 0; mr2Cn < myRadios.length; mr2Cn++){
			if(myRadios[mr2Cn] == thiss){
				if(document.getElementById('rel_' + thiss.id))
					document.getElementById('rel_' + thiss.id).style.display = "block";
				if(document.getElementById('hide_' + thiss.id))
					document.getElementById('hide_' + thiss.id).style.display = "none";
			} else {
				if(document.getElementById('rel_' + myRadios[mr2Cn].id))
					document.getElementById('rel_' + myRadios[mr2Cn].id).style.display = "none";
				if(document.getElementById('hide_' + myRadios[mr2Cn].id))
					document.getElementById('hide_' + myRadios[mr2Cn].id).style.display = "block";
			}
		}
	}
}

//###################################################################################
function nltForm() {
	document.getElementById('nltStep1').style.display = "block";
	document.nltForm.onsubmit = checkNltForm;
}
function checkNltForm() {
	
	
	var mf = document.nltForm;
	var email = document.getElementById('eInput');
	backBtn = document.getElementById('eBack');
	conf = document.getElementById('eConfirm').checked;
	var ret = false;
	var emailValid = false;
	
	backBtn.onclick = function () {
		if(this.style.visibility == "visible"){
			document.getElementById('errorText').style.display = "none";
			document.getElementById('nltStep1').style.display = "block";
			document.getElementById('nltStep2').style.display = "none";
			document.getElementById('nltEmailInput').style.display = "block";
			document.getElementById('nltCbConfirm').style.display = "none";
			document.getElementById('errorText').innerHTML = "";
			document.getElementById('eConfirm').checked = false;
			this.style.visibility = "hidden";
		}
	}
	
	if(email.value){
		var emailAr2 = new Array();
		var emailAr = new Array();

		if(email.value.match("\@")){
			emailAr = email.value.split("\@");
			if(emailAr[0] && emailAr[1]){
				emailAr2 = emailAr[1].split("\.");
				if((emailAr2[0].length > 2) && (emailAr2[1].length > 1)){
					var emailValid = true;
				} else {
					var emailValid = false;
				}
			} else {
				var emailValid = false;
			}
		} else {
			var emailValid = false;
		}
		var errorTxt = document.getElementById('errorMessageIncorrectMail').innerHTML;
	} else {
		var emailValid = false;
		var errorTxt = document.getElementById('errorMessageNoMail').innerHTML;
	}
	
	if(emailValid) {
		document.getElementById('errorText').style.display = "none";
		document.getElementById('nltStep1').style.display = "none";
		document.getElementById('nltStep2').style.display = "block";
		document.getElementById('nltEmailInput').style.display = "none";
		document.getElementById('nltCbConfirm').style.display = "block";
		backBtn.style.visibility = "visible";
		if(conf){
			ret = true;
		}
		
	} else {
		document.getElementById('errorText').style.display = "block";
		document.getElementById('nltStep1').style.display = "block";
		document.getElementById('nltStep2').style.display = "none";
		document.getElementById('nltEmailInput').style.display = "block";
		document.getElementById('nltCbConfirm').style.display = "none";
		document.getElementById('errorText').innerHTML = errorTxt;
		conf = false;
	}
	
	return ret;
}



//###################################################################################
function formElements() {
	if (document.getElementsByTagName('input')) {
		var inputs = document.getElementsByTagName('input');
		for (var inCn = 0; inCn < inputs.length; inCn++) {
			if((inputs[inCn].type == "submit") || (inputs[inCn].type == "button")) {
				inputs[inCn].style.cursor = "pointer";
				inputs[inCn].onmouseover = function () {
					this.style.opacity = 0.7;
					this.style.filter = 'alpha(opacity=70)'
				}
				inputs[inCn].onmouseout = function () {
					this.style.opacity = 1;
					this.style.filter = 'alpha(opacity=100)'
				}
			}
		}
	}
}



//###################################################################################
function searchFocus() {
	
	if (document.getElementById('searchIssues')){
	
		document.siDefVal = document.getElementById('searchIssues').value;
		
		document.getElementById('searchIssues').onfocus = function () {
			if(document.siDefVal == this.value) {
				this.value = "";
			}
			this.style.color = "#000000";
		}
		document.getElementById('searchIssues').onblur = function () {
			if(this.value == ""){
				this.value = document.siDefVal;
				this.style.color = "#555555";
			} else {
				this.style.color = "#000000";
			}
		}
	}	
}



//###################################################################################
function selectedFolder() {
	if(document.sf){
		if(document.getElementById('sub'+document.sf)) {
			document.getElementById('sub'+document.sf).style.visibility = "visible";
			document.getElementById('f'+document.sf).style.color = "#E2017B";
			document.curV = document.sf;
		}
	}
}
function selectedAcs() {
	if(document.acs){
		document.getElementById('acsPrev'+document.acs).className = 'selected';
	}
}
function showSub(submId) {
	var submId;
	if(0 <= document.curV){
		document.getElementById('sub'+document.curV).style.visibility = "hidden";
	}
	document.getElementById('sub'+submId).style.visibility = "visible";
	document.curV = submId;
}



//###################################################################################
function showModelPopup(ppuId, tof) {
	var ppuId, tof;
	var ppup = document.getElementById('modelPopup'+ppuId);
	if(tof == 1){
		ppup.style.display = 'block';
	}else if(tof == 0){
		ppup.style.display = 'none';
	}
}


	