function initCollapsed(){
var a = document.getElementsByTagName('div');
	for(var k=0;k<a.length;k++){
		if(a[k].className.indexOf('collapsible') != -1){
			var n = a[k].firstChild;
			while(n.nodeName.toLowerCase() != 'h1'){n = n.nextSibling;}
			a[k].tween = new Tween(a[k],"height",n.scrollHeight,a[k].scrollHeight,250,'px');
			a[k].style.height = n.scrollHeight+'px';
			n.onclick = function(){
				if(!this.parentNode.tween.playing){
					this.style.backgroundImage = "url("+(this.parentNode.tween.position == 0?"/images/ui/minus.gif":"/images/ui/plus.gif")+")";
					this.parentNode.tween.play();
				}
				
			}
		}
	}	
}

function popup(url, attributes) {
	window.open(url,"_blank",attributes);
	return false;
}

function findLinks(){
	var a = document.getElementsByTagName('a');
	for(var k=0;k<a.length;k++){
		if( a[k].className.indexOf('external') != -1){
			a[k].href = '/us/external_site.html?url=' + a[k].href;
		} else if(/webinar-form/.test(a[k].className)){
			a[k].onclick = function(){
				/*if(/MSIE 7/.test(navigator.userAgent)){
					window.open(this.href,"_blank","width=480,height=684");
				} else {*/
				this.rpu = new RegisterPopUp(this); 
				this.rpu.display();
				//}
				return false;
			}
		} else if(a[k].className.indexOf('pdf') != -1){
			a[k].onclick = function(){
				dcsMultiTrack('DCS.dcsuri',this.href);	
			}
		}
	}
}

function init(){
	if(arguments.callee.doOnce){return;}
	arguments.callee.doOnce=true;
	if(document.getElementById('contact-form')){
		document.getElementById('contact-form').onsubmit = function(){
			var valid = true;
			var errorMsg = document.getElementById('contact-errorMsg');
			while(errorMsg.hasChildNodes()){
				errorMsg.removeChild(errorMsg.firstChild);	
			}
			if(document.getElementById('First_Name').value == ""){
				valid = false;
				li = document.createElement('li');
				li.appendChild(document.createTextNode("-- Please enter your first name."));
				errorMsg.appendChild(li);
			}
			if(document.getElementById('Last_Name').value == ""){
				valid = false;
				li = document.createElement('li');
				li.appendChild(document.createTextNode("-- Please enter your last name."));
				errorMsg.appendChild(li);
			}
			
			if(!/\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}\b/.test(document.getElementById('email-address').value.toLowerCase())){
				valid = false;
				li = document.createElement('li');
				li.appendChild(document.createTextNode("-- Please enter a valid e-mail address."));
				errorMsg.appendChild(li);
			}
			
			if(document.getElementById('company-name').value == ""){
				valid = false;
				li = document.createElement('li');
				li.appendChild(document.createTextNode("-- Please enter your company name."));
				errorMsg.appendChild(li);
			}
			
			if(document.getElementById('phone').value == ""){
				valid = false;
				li = document.createElement('li');
				li.appendChild(document.createTextNode("-- Please enter your phone number."));
				errorMsg.appendChild(li);
			}
			
			if(!(document.getElementById('how1').checked||document.getElementById('how2').checked||document.getElementById('how3').checked||document.getElementById('how4').checked||document.getElementById('how5').checked||document.getElementById('how6').checked||document.getElementById('how7').checked)){
				valid = false;
				li = document.createElement('li');
				li.appendChild(document.createTextNode("-- Please enter how you heard about us."));
				errorMsg.appendChild(li);
			}
			
			if(!valid){
				document.location = "#";	
			}
			return valid;
		}
	}
	findLinks();
	initCollapsed();
}
if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,null);}
window.onload=init;
