initMoviePopup = function () {
	if(document.getElementsByTagName) {
		hrefs = document.getElementsByTagName("a");
		for(var i=0; i < hrefs.length; i++) {
			if(hrefs[i].className.match("demo")) {
				hrefs[i].onclick = function () {
					newwindow = window.open(this.href, "QADistillerDemo", "height=820,width=1100,status=no,toolbar=no,menubar=no,location=no,resize=yes");
					return false;
				}
			}
		}
	}
}



initForm = function () {

	fields = Form.getElements('downloadForm');
	
	for(i=0;i<fields.length;i++) {
	
		// CHECK IF FORM IS SUBMITTED -------------------- //
		if($('feedback')) {
			if($('feedback').hasClassName('done')) {
				fields[i].disable();
			}
		} else {
			// SET FIRST FORM ELEMENT ------------------------ //
			Form.focusFirstElement('downloadForm');
			fields[0].parentNode.lastChild.style.color = "#38992A";
			fields[0].parentNode.lastChild.style.fontWeight = "bold";
			// ----------------------------------------------- //
		}

		if(fields[i].hasClassName('required')) {
			if(fields[i].value == "") {
				fields[i].style.backgroundImage = "url(img/warning.png)";
			}
		}
	
		fields[i].onfocus = function () {
			if(this.type != "checkbox") {
				this.parentNode.lastChild.style.color = "#38992A";
				this.parentNode.lastChild.style.fontWeight = "bold";
			}
			this.style.borderColor = "#9CCC95";
			if(this.hasClassName('required')) {
				if(this.value == "") {
					this.style.backgroundImage = "url(img/warning.png)";
				} else {
					this.style.backgroundImage = "none";
				}
			}
		};
		
		fields[i].onblur = function () {
			if(this.type != "checkbox") {
				this.parentNode.lastChild.style.color = "#333333";
				this.parentNode.lastChild.style.fontWeight = "normal";
			}
			this.style.borderColor = "#FFFFFF";
			if(this.hasClassName('required')) {
				if(this.value == "") {
					this.style.backgroundImage = "url(img/warning.png)";
				} else {
					this.style.backgroundImage = "none";
				}
			}
		};
	}
}

addEvent(window, 'load', initMoviePopup);

//http://ejohn.org/projects/flexible-javascript-events/
function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj["e"+type+fn] = fn;
    obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
    obj.attachEvent( "on"+type, obj[type+fn] );
  } 
  else{
    obj.addEventListener( type, fn, false );	
  }
}