

	$(document).ready(function() {
		
		$('a.popup').click(function() {

			var width = 750;
			var height = 750;
			
			var url = $(this).attr('href');
			
			var left = parseInt((screen.availWidth/2) - (width/2));
			var top = parseInt((screen.availHeight/2) - (height/2));
			
			window.open(url,"popup",
			            "resizable=no,scrollbars=yes,status=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
				            					
			return false;
		});
		
		if ($('#promo').length) {
			
			flash_vars.promo.flashvars = { 
				'xmlPath': 'assets/flash/xml/pages.xml'
			};
			
			flash_vars.promo.params = {
				'menu': 'false',
				'scale': 'noScale',
				'allowFullscreen': 'true',
				'allowScriptAccess': 'always',
				'bgcolor': '#FFFFFF'				
			};
			
			flash_vars.promo.attributes = {
					"id": "XConnect"
			};
						
			swfobject.embedSWF(flash_vars.promo.swf_url, 
				"promo", "960", "250", "9.0.0", "", 
				flash_vars.promo.flashvars, 
				flash_vars.promo.params, 
				flash_vars.promo.attributes);						
				
		}
		
		if ($('#media_file').length) {
			if ( $('#media_content:has(img)').length == 0) {
				var data = {};
				data.FLVContentPath = flash_vars.media_file;
				data.FLVBufferTime = '10';
				data.FLVAutoPlay = 'yes';
				swfobject.embedSWF('assets/flash/v3.swf', 'media_content', '604', '340', '9.0.0', '', data, {'wmode': 'transparent'});
			}
		}
		
		if ($('#news').length) {
			
			$('#news div.tabs li').click(function() {
				
				var tab_name = $(this).attr('class');				
				
				$('#news div.content > div').hide()
																	.filter('div.'+tab_name+'_tab')
																	.show();

				var $tab_img = $(this).find('img');				
				var sel_src = $tab_img.attr('src');
				
				if (sel_src.indexOf('active') != -1) return false;
				
				$tab_imgs = $(this).siblings().find('img');
				
				$tab_imgs.each(function() {
					var src = $(this).attr('src');				
					$(this).attr('src', src.replace('_active', ''));					
				});
				
				var url = sel_src.substring(0, sel_src.lastIndexOf('.'))+'_active.gif';
				$tab_img.attr('src', url);
				
				return false;
				
			});
						
			$('div.newsletter input.email').focus(function() {
				if ($(this).val() == 'email@domain.com') {
					$(this).val('');
				}
			}).blur(function() {
				if ($(this).val() == '') {
					$(this).val('email@domain.com');
				}
			});	
			
			$('div.newsletter input.submit').click(function() {
				var regex = /^[a-z0-9._-]+@([a-z0-9_-]+.)+[a-z]{2,6}$/i;
				if (!regex.test($('div.newsletter input.email').val())) {
					alert('Please provide a valid email address');
					return false;
				}
				return true;
			});		
			
		}
				
		if ($('#sub_tabs').length) {
			
			$('#sub_tabs div.tabs ul li').click(function() {
				
				var tab_name = $(this).attr('class');
				
				$('#sub_tabs div.tab_content').hide();
				$('#' + tab_name).show();
				
				$tab = $(this).find('div');
				
				if ($tab.hasClass('active')) return;
				
				$tabs = $(this).siblings().find('div');
				
				$tabs.each(function() {
					$(this).removeClass('active');
				});
				
				$tab.addClass('active');
				
				return false;
				
			});
			
		}
		
		$('#search_txt').focus(function() {					  
		  if ($(this).val() == 'Search') {
		     $(this).val('');
		  }			
		}).blur(function() {
		  if ($(this).val() == '') {
		  	$(this).val('Search');
		  }
		});	
		
		var test = $(".shadow").dropShadow({left:2,top:2,blur:2,opacity:.33});
	});