	(function() {
		// 
		notEmpty = function() {
			return this.value.replace(/\s/g,'').length != 0;
		}
		validEmail = function() {
			return !!this.value.match(/^\s*[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\s*$/);
		}
		//common Omniture object and mandatory fields list
		var s = s_gi('oberonblaze'),
			mandatory = {
				'pp-name': notEmpty, 
				'pp-company': notEmpty, 
				'pp-email': validEmail 
			};

		// hide omniture image
		var om_img =  document.images[document.images.length-1];
			om_img.style.position = 'absolute';
			om_img.style.bottom = '0';
		
		// simple shorthand for d.gEbI
		function _(id) {
			return document.getElementById(id);
		}

		// open popup
		popupOpen = function(num) {
			var num = num || 0,
				options = _('popup').getElementsByTagName('option');
				
			if (num==-1) {
				//show thank you page
				_('popup').className = 'thankyou';
			}
			else {
				// IE7 fix
				_('pp-send').style.zoom = '1';
			
				// show regular form
				options[num].selected = "selected";
			}

			// calculate new top coordinate
			var cHeight = window.innerHeight || document.documentElement.clientHeight,
				sTop = document.documentElement.scrollTop || document.body.scrollTop,
				top = Math.max((cHeight - 644)/2, 20);
			_('popup').style.top = sTop + top + 'px';

			// show popup
			_('overlay').style.display = _('popup').style.display = 'block';
			
			return false;
		}

		// close popup
		popupClose = function() {
			_('overlay').style.display = _('popup').style.display = 'none';
			_('popup').className = '';
			
			return false;
		}

		// generating email
		sendEmail = function() {
			var result = true;
			for(var field in mandatory) {
				if (!_(field).validate()) {
					result = false;
					_(field).className += ' incorrect';
				}
			}
			if (!result)
				alert('Please fill in the mandatory fields.');

			return result;
		}

		_('pp-submit').onclick = sendEmail;
		_('pp-close').onclick = popupClose;
		_('overlay').onclick = popupClose;
		_('c-launch').onclick = function() {
			popupOpen(1);
			s.tl(this, 'o', 'partner');
			return false;
		}
		_('c-publish').onclick = function() {
			popupOpen(0);
			s.tl(this, 'o', 'partner');
			return false;
		}
		_('c-adv').onclick = function() {
			popupOpen(2);
			s.tl(this, 'o', 'ads');
			return false;
		}
		_('c-other').onclick = function() {
			popupOpen(3);
			s.tl(this, 'o', 'footer');
			return false;
		}
		for(var field in mandatory) {
			_(field).validate = mandatory[field];
			_(field).onblur = function() {
				if (this.validate()) 
					this.className = this.className.replace(/\sincorrect/, '');
			}
		}
		window.onload = function(evt) {
			if (location.hash == '#thankyou') popupOpen(-1);
		}
		
		// register SWF Object
		swfobject.embedSWF("Blaze_1c.swf", "flash-promo", "970", "315", "9.0.0", false, false, {wmode: 'opaque'});

	})();
