window.addEvent('domready', function() {  
		
			// Facebook & Twitter Tooltips //
			
			var customTips = $$('.tooltip');
			var toolTips = new Tips(customTips, {
				offsets: {
					'x': -140,       //default is 16
					'y': 10        //default is 16
				},
				fixed: true

			});
		
			// Blog Logo Text Box //
						
			var revealText = function() {
				$('asterisk_block').tween('margin-left', '300px');
			}
			var hideText = function() {
				$('asterisk_block').tween('margin-left', '-36px');
			}
		 	
			if($('blog_logo')){
		 		$('blog_logo').addEvent('mouseenter',revealText);
				$('blog_logo').addEvent('mouseleave',hideText);
			}
			
			// Home Page Toggle Switches //
			
			var toggleDown = function(switchToFlip) {
				$(switchToFlip).setStyle('margin-top', '75px');
			}
			
			var toggleUp = function(switchToFlip) {
				$(switchToFlip).setStyle('margin-top', '15px');
			}
			
			var hideHomeText = function() {
				$$('.home_text').setStyle('display','none');
			}
			
			var showHomeText = function(textToShow){
				hideHomeText();
				$(textToShow).setStyle('display','block');
			}
			
			var hideHomeContent = function() {
				$$('.home_dvd').setStyle('display','none');
			}
			
			var showHomeContent = function(contentToShow){
				hideHomeContent();
				$(contentToShow).setStyle('display','block');
			}
			
			if($('home_toggles')){
			
				$$('.toggle_switch').each(function(theSwitch){
					theSwitch.addEvent('click', function(e){
						
						var thisId = theSwitch.get('id');
						var TopMarg = theSwitch.getStyle('margin-top');
						if (TopMarg == '15px') {
							$$('.toggle_switch').each(function(sw){
								toggleUp(sw);
							});
							toggleDown(theSwitch);
							switch (thisId){
								case "switch1":
									showHomeText('home_text_1');
									showHomeContent('home_dvd_0');
									soundManager.play('switch_l');	
									break;
								case "switch2":
									showHomeText('home_text_2');
									showHomeContent('home_dvd_1');
									soundManager.play('switch_c');	
									break;
								case "switch3":
									showHomeText('home_text_3');
									showHomeContent('home_dvd_2');
									soundManager.play('switch_r');	
									break;
								default : null;
							}
						}
												
					});
				});

			}
			
			
			// A Little Peek Boxes //
			
			if ($('peek_box_1')) {
				
				$$('.peek_box_block').each(function(theBox){
					theBox.addEvent('mouseenter', function(e){
						e.stop();
						$(theBox).setStyle('display','none');
						if(theBox.get('id') == 'box_1') {
							$('video_1').setStyle('display','block');
							soundManager.play('peek_left');
						} else {
							$('video_2').setStyle('display','block');
							soundManager.play('peek_right');
						}
					});
									
				});
				
				/*
				$$('.peek_box').each(function(theBox){
					theBox.addEvent('mouseleave', function(e){
						e.stop();
						$(theBox).getElement('.peek_box_block').setStyle('display','block');
					
					});
									
				});
				*/
				
				
				
			}
			
			// Praise Actions //
			
			var showPraiseArticle = function(articletoshow) {
				$$('.praise_post').setStyle('display','none');
				$(articletoshow).setStyle('display', 'block');
			}
			
			var highlightTitle = function(titletohighlight) {
				$$('.praise_title_active').setProperty('class','praise_title');
				$(titletohighlight).setProperty('class','praise_title_active');
			}
			
			
			if ($('praise_content')) {
			
				$$('.praise_title').each(function(theTitle){
					theTitle.addEvent('mouseenter', function(e){
						if(theTitle.getProperty('class') == 'praise_title_active') {
							//do nothing
						} else {
							$(theTitle).setProperty('class','praise_title_on');
						}
						
						//$(theTitle).setStyle('background-image','url(images/praise_arrow.gif) no-repeat');
					});
					
					theTitle.addEvent('mouseleave', function(e){
						e.stop();
						if(theTitle.getProperty('class') == 'praise_title_active') {
							//do nothing
						} else {
							$(theTitle).setProperty('class','praise_title');
						}
					});
					
					var idName = theTitle.getProperty('id');
					var idNum = idName.split('-')
					var articleId = "praise_post-"+idNum[1];
					
					theTitle.addEvent('click', function(e){
						e.stop();
						showPraiseArticle(articleId);
						highlightTitle(idName);
					});
				
				});
			
				$$('.praise_post').each(function(thePost){
					if (thePost.getStyle('display') == 'block') {
						idName = thePost.getProperty('id');
						idNum = idName.split('-');
						var titleId = 'praise_title-'+idNum[1];
						
						$(titleId).setProperty('class','praise_title_active');
					}
				
				});
			
			
			}
			
			
			
			//      Faq Accordian      //
			
			var accordion = new Accordion($$('.faq_question'), $$('.faq_entry'), {
				
				opacity: 0,
				onActive: function(toggler, element){
					
				},
				onBackground: function(toggler, element){
					
				},

				alwaysHide: true,
				//display: 0
				start: 'all-closed'
			
					
			
			});
			
			
			
			//      Contact Form        //
			
			function displayContact(which) {
				$$('.contact_holder').setStyle('display','none');
				$(which).setStyle('display','block');
			}
			
			function allOff(which){
				$$('.contact_button').set('class','contact_button');
				$(which).set('class','contact_button contact_on');
			}
			
			if($('contact_buttons')){
				
				var param = ""+window.location;
				var whichOne = param.split('#');
				
				if (whichOne[1] != null) {
					allOff("contact_"+whichOne[1]);
					displayContact("contact_holder_"+whichOne[1]);
				}
				
				$$('.contact_button').each(function(theButton){
										
					theButton.addEvent('click',function(e){
						e.stop();
												
						var btnName = theButton.getProperty('id');
						var btnNum = btnName.split('_');
						var secName = 'contact_holder_'+btnNum[1];
						
						
						displayContact(secName);
						allOff(theButton);
						soundManager.play(btnName);
					
					});
				
				});
				
				
				$('contact_holder_thanks').addEvent('click', function(e){
					e.stop();
					displayContact('contact_holder_general');
					allOff('contact_general');
				
				});
				
				$$('.contact-submit').each(function(theSend){
				
					theSend.addEvent('mouseenter', function(e){soundManager.play('contact_send');});
				
				});
				
				
			}
		
			
		
			//     Order Logic    //
			
			function getNum(numText) {
				var numNum;
				if (numText == '-') {
					numNum = 0;
				} else {
					numNum = parseFloat(numText);
				}
				
				return numNum;
			}
			
			function totalIt(){
				var col_1 = getNum($('col_1_sub').get('html'));
				var col_2 = getNum($('col_2_sub').get('html'));
				var col_b = getNum($('col_b_sub').get('html'));
				
				var subtotal = col_1 + col_2 + col_b;
				//var subtotal_nice = subtotal+".00";
				
				//var shipping = getNum($('order_shipping').get('html'));
				
				//var total = subtotal + shipping;
				//var total = subtotal_nice;
				
				var total = subtotal.toFixed(2);
				//$('order_subtotal').set('html', subtotal_nice);
				$('order_total').set('html', total);
				
				//<a id="outerorder_link" href="http://weeseeworld.com/order/index.php/checkout/cart/add/?product=167&qty=2&related_product=168,169&related_qty=3,5"><span>order</span></a>
				buildLink();
			}
			
			function buildLink(){
				var qty = new Array();
				
				var col_1 = '167';
				var qty_1 = $('qty_1_selector').value;
				
				if (qty_1 > 0) {
					qty.push([col_1, qty_1]);
				}
				
				var col_2 = '168';
				var qty_2 = $('qty_2_selector').value;
				
				if (qty_2 > 0) {
					qty.push([col_2, qty_2]);
				}
				
				var col_b = '169';
				var qty_b = $('qty_b_selector').value;
				
				if (qty_b > 0) {
					qty.push([col_b, qty_b]);
				}
				
				var linkString = "";
				
				if (qty.length > 0) {
					
					linkString = "<a href=\"https://secure60.inmotionhosting.com/~weesee5/order/index.php/checkout/cart/add/?product=";	
					//linkString = "<a href=\"http://weeseeworld.com/order/index.php/checkout/cart/add/?product=";	
					linkString += qty[0][0];
					linkString += "&qty=";
					linkString += qty[0][1];
					
					if (qty.length == 2) {
						linkString += "&related_product=";
						linkString += qty[1][0];
						linkString += "&related_qty=";
						linkString += qty[1][1];
					} else if (qty.length == 3){
						linkString += "&related_product=";
						linkString += qty[1][0]+","+qty[2][0];
						linkString += "&related_qty=";
						linkString += qty[1][1]+","+qty[2][1];
					}
					linkString += "\"<span></span></a>";
				}
				
				if (linkString != "") {
					$('outerproceed').set('html',linkString);
				} else {
					$('outerproceed').set('html','<a href=\"#\"><span>proceed to checkout</span></a>');
				}
				
			}
		
			if ($('order_container')){
				$('qty_1_selector').addEvent('change', function(e){
						//e.stop();
						var cur_val = $('qty_1_selector').value;
						var sub_total = cur_val * 20.00;
						var sub_nice;
						if (sub_total == 0) {
							sub_nice = "-";
						} else {
							sub_nice = sub_total.toFixed(2);
						}
						
						$('col_1_sub').set('html',sub_nice);
						
						totalIt();
				});
				
				$('qty_2_selector').addEvent('change', function(e){
						//e.stop();
						var cur_val = $('qty_2_selector').value;
						var sub_total = cur_val * 20.00;
						var sub_nice;
						if (sub_total == 0) {
							sub_nice = "-";
						} else {
							sub_nice = sub_total.toFixed(2);
						}
						
						$('col_2_sub').set('html',sub_nice);
						
						totalIt();
				});
				
				$('qty_b_selector').addEvent('change', function(e){
						//e.stop();
						var cur_val = $('qty_b_selector').value;
						var sub_total = cur_val * 35.00;
						var sub_nice;
						if (sub_total == 0) {
							sub_nice = "-";
						} else {
							sub_nice = sub_total.toFixed(2);
						}
						
						$('col_b_sub').set('html',sub_nice);
						
						totalIt();
						
				});
			}
			
			if($('page_container')) {
				$('outerorder').addEvent('mouseenter', 		function(e){	soundManager.play('nav_order');			});
				$('outerdvd').addEvent('mouseenter', 		function(e){	soundManager.play('nav_thedvds');		});
				$('outerpeek').addEvent('mouseenter', 		function(e){	soundManager.play('nav_littlepeek');	});
				$('outerpraise').addEvent('mouseenter', 	function(e){	soundManager.play('nav_praise');		});
				$('outerresources').addEvent('mouseenter', 	function(e){	soundManager.play('nav_resources');		});
				$('outerblog').addEvent('mouseenter', 		function(e){	soundManager.play('nav_blog');			});
				$('outerfaq').addEvent('mouseenter', 		function(e){	soundManager.play('nav_faq');			});
				$('outerwhoweare').addEvent('mouseenter', 	function(e){	soundManager.play('nav_whoweeare');		});
				$('outercontactus').addEvent('mouseenter',	function(e){	soundManager.play('nav_contactus');		});
				$('outerfindastore').addEvent('mouseenter',	function(e){	soundManager.play('nav_findastore');	});
				$('outertheater').addEvent('mouseenter',	function(e){	soundManager.play('nav_theater');		});
				 
				
			}
		
			
			
			
			/*   Who Wee Are Squeezebox*/
			
			SqueezeBox.assign($$('a[rel=boxed]'));
			
			
			SqueezeBox.assign($$('a.boxed'), {
				parse: 'rel'
			});

			
			


			
		
});

// functions

	function LaunchRelax(){
		var randomnumber=Math.floor(Math.random()*4)
		var whichAnim = 'http://weeseeworld.com/theater/anim_'+randomnumber+'.html';
		newWindow=window.open(whichAnim,'Relax','top=0,left=0,width=screen.width,height=screen.height,scrollbars=0,toolbar=0,menubar=0,resizeable=0,alwaysRaised=yes');
		newWindow.focus(); 
		void(0);
	} 
	
	function isIntro(){
		var homeurl = location.href;
		homeurl = homeurl.split('#');
		if (homeurl.length > 1) {
			if (homeurl[1] == 'intro'){
				return true;
			} else {
				return false;
			}
		}
	}
	
	function getUrlBase() {
		var url2 = ""+window.location;
		var noHttp = url2.split('//');
		var comWWW = noHttp[1].split('/');
		var urlBase = "";
		if (comWWW.length > 3){
			var ups = comWWW.length - 3;
			for (var i=0; i<ups; i++ ) {
				urlBase += "../";
			}
		};
		return urlBase;
	}
	var urlBase = getUrlBase();

soundManager.url = urlBase+'wp-content/themes/weesee/sound/'; // directory where SM2 .SWFs live

// Note that SounndManager will determine and append the appropriate .SWF file to the URL.

// disable debug mode after development/testing..
soundManager.debugMode = false;


// Option 2: More flexible createSound method (recommended)

soundManager.onload = function() {
	// nav sounds
	var order		= soundManager.createSound({id: 'nav_order',		url: urlBase+'wp-content/themes/weesee/sound/nav_order_button.mp3' });
	var thedvds 	= soundManager.createSound({id: 'nav_thedvds', 		url: urlBase+'wp-content/themes/weesee/sound/nav_thedvds.mp3' });
	var littlepeek 	= soundManager.createSound({id: 'nav_littlepeek',	url: urlBase+'wp-content/themes/weesee/sound/nav_little_peek.mp3' });
	var praise	 	= soundManager.createSound({id: 'nav_praise',		url: urlBase+'wp-content/themes/weesee/sound/nav_praise.mp3' });
	var resources 	= soundManager.createSound({id: 'nav_resources',	url: urlBase+'wp-content/themes/weesee/sound/nav_resources.mp3' });
	var blog	 	= soundManager.createSound({id: 'nav_blog',			url: urlBase+'wp-content/themes/weesee/sound/nav_blog.mp3' });
	var faq		 	= soundManager.createSound({id: 'nav_faq',			url: urlBase+'wp-content/themes/weesee/sound/nav_faq.mp3' });
	var whoweeare 	= soundManager.createSound({id: 'nav_whoweeare', 	url: urlBase+'wp-content/themes/weesee/sound/nav_whoweeare.mp3' });
	var contactus 	= soundManager.createSound({id: 'nav_contactus',	url: urlBase+'wp-content/themes/weesee/sound/nav_contactus.mp3' });
	var findastore 	= soundManager.createSound({id: 'nav_findastore',	url: urlBase+'wp-content/themes/weesee/sound/nav_findastore.mp3' });
	var theater 	= soundManager.createSound({id: 'nav_theater',		url: urlBase+'wp-content/themes/weesee/sound/nav_weeseetheater.mp3' });
	
	
	// peek sounds
	var peekright 	= soundManager.createSound({id: 'peek_right',		url: urlBase+'wp-content/themes/weesee/sound/little_peek_right.mp3' });
	var peekleft 	= soundManager.createSound({id: 'peek_left',		url: urlBase+'wp-content/themes/weesee/sound/little_peek_left.mp3' });
	
	// contact page sounds
	var ct_general 	= soundManager.createSound({id: 'contact_general',	url: urlBase+'wp-content/themes/weesee/sound/contact_general.mp3' });
	var ct_press 	= soundManager.createSound({id: 'contact_press',	url: urlBase+'wp-content/themes/weesee/sound/contact_press.mp3' });
	var ct_feedback	= soundManager.createSound({id: 'contact_feedback',	url: urlBase+'wp-content/themes/weesee/sound/contact_feedback.mp3' });
	var ct_custserv	= soundManager.createSound({id: 'contact_customer',	url: urlBase+'wp-content/themes/weesee/sound/contact_custserv.mp3' });
	var ct_send		= soundManager.createSound({id: 'contact_send',		url: urlBase+'wp-content/themes/weesee/sound/contact_send_rollover.mp3' });	
	
	// homepage sounds
	var hp_switch_l	= soundManager.createSound({id: 'switch_l',			url: urlBase+'wp-content/themes/weesee/sound/homepage_switch_L.mp3' });	
	var hp_switch_c	= soundManager.createSound({id: 'switch_c',			url: urlBase+'wp-content/themes/weesee/sound/homepage_switch_C.mp3' });	
	var hp_switch_r	= soundManager.createSound({id: 'switch_r',			url: urlBase+'wp-content/themes/weesee/sound/homepage_switch_R.mp3' });
	var dvds_reveal = soundManager.createSound({id: 'dvds_reveal',		url: urlBase+'wp-content/themes/weesee/sound/dvds_page_reveal.mp3' });

	
	if(isIntro()) {
		soundManager.play('dvds_reveal');	
	}
	
}

