$(function() {
	$('li span').each(function() {
		var title = $(this).attr('title');
		if (!title)
			return;
		var tooltip = title.split(': ');
		$(this).css('cursor', 'help').hover(function() {
			box_new_tooltip.show(this, tooltip[1], tooltip[0], {
				show_delay : 1000
			});
		}, box_new_tooltip.hide).removeAttr('title');
	});
});

var slideshow = {
	current_slide : 0,
	slide_count : 6,
	blocker : undefined,
	popup : undefined,
	firstrun : false,
	_init : function() {
		if (this.firstrun)
			return true;
		this.firstrun = true;
		this.blocker = $('<div id="presentation_blocker"></div>').appendTo(
				document.body).hide();
		this.popup = $('#slideshow');
		var _this = this;
		var collapse = function() {
			_this.blocker.hide();
			_this.popup.hide();
			return false;
		}
		this.blocker.click(collapse);
		$('a.popup-slideshow-button-close').click(collapse);
		var thumbs = $('a.popup-slideshow-scrollbar-thumb').click(
				function() {
					var slide_id = $(this).attr('id').replace(
							'slideshow_scrollbar_thumb_', '');
					_this._switch(slide_id);
					return false;
				});
		this.slide_count = thumbs.length;
		$('a.popup-slideshow-scrollbar-next').click(function() {
			return _this._rotate('next');
		});
		$('a.popup-slideshow-scrollbar-prev').click(function() {
			return _this._rotate('prev');
		});
		return true;
	},
	_rotate : function(type) {
		var el;
		var current_slide = this.current_slide;
		if (type == 'next') {
			current_slide++;
			el = $('#slideshow_slide_' + current_slide);
			if (!el.get(0)) {
				current_slide = 0;
			}
		}
		if (type == 'prev') {
			current_slide--;
			el = $('#slideshow_slide_' + current_slide);
			if (!el.get(0)) {
				current_slide = this.slide_count - 1;
			}
		}
		this._switch(current_slide);
		return false;
	},
	_switch : function(slide_id) {
		$('#slideshow_slide_' + this.current_slide)
				.removeClass('slide-visible');
		$('#slideshow_scrollbar_thumb_' + this.current_slide).removeClass(
				'thumb-current');
		this.current_slide = slide_id;
		$('#slideshow_slide_' + this.current_slide).addClass('slide-visible');
		$('#slideshow_scrollbar_thumb_' + this.current_slide).addClass(
				'thumb-current');
	},
	open : function(slide_id) {
		this._init();
		this._switch(slide_id);
		var height = Math.max($(window).height(), $(document).height());
		var width = Math.max($(window).width(), $(document).width());
		this.blocker.height(height).width(width).show();
		if ($.browser.msie && $.browser.version == '6.0') {
			this.popup.addClass('popup-slideshow-ie');
		}
		Common_Global.set_center_position(this.popup.show().get(0), 60);
	}
}
$(function() {
	$('a.popup-slideshow-plus').click(function() {
		var slide_id = $(this).attr('id').replace('slideshow_plus_', '');
		slideshow.open(slide_id);
		return false;
	});
});





var box_presentation = {
	_presentation_blocker_resize : function(blocker) {
		var height = Math.max($(window).height(), $(document).height());
		var width = Math.max($(window).width(), $(document).width());
		blocker.height(height).width(width);
	},
	_show_media : function(params) {
		
		// ////////////
		
		if (params.type == 'video_demo') {
			$('#presentation_content_video')
			.html('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" WIDTH="800" HEIGHT="622"><PARAM NAME=movie VALUE="' + params['file'] + '"><PARAM NAME=quality VALUE="high"><EMBED src="' + params['file'] + '" quality="high" WIDTH="800" HEIGHT="622" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>');
		}
	
		 return;
		
		///////////////
		
		
		
		var identifier;
		var file_name;
		if (params.type == 'product_videos') {
			var files = {
				v1 : 'IcjgqQTPFx4',
				v2 : 'PRFDSRcj5HM',
				v3 : 'rkY7MGilQZY',
				v4 : 'H_KnRwoKbJs',
				v5 : 'Gqbka1dtHOY',
				v6 : 'RNMBvZWL0Pw'
			}
			identifier = files[params['file']];
		} else if (params.type == 'developers') {
			var files = {
				v1 : 'Nd6E82FcgMQ',
				v2 : 'I0EjSGg1nFM',
				v3 : '5AtPW4q3wqA'
			}
			identifier = files[params['file']];
		} else if (params.type == 'customer_testimonals') {
			var files = {
				v1 : 'GE2WZv2mzLU',
				v2 : '0QJPsZt-_WA',
				v3 : 'R-mQROC2t0Q',
				v4 : 'Eu3sjQn9nT0',
				v5 : 'gmPDqx09plQ',
				v6 : '7ssquYK0Qg0'
			}
			identifier = files[params['file']];
		} else if (params.type == 'marketing_campaigns') {
			var files = {
				v1 : 'cFFw-0qH1Hs',
				v2 : 's-AwAvQD_F0',
				v3 : 'oHam8glLuj4',
				v4 : 's-ptXaRsE-8',
				v5 : 'YzQZmzFZ1UM'
			}
			identifier = files[params['file']];
		} else if (params.type == 'enterprise') {
			file_name = 'Admin_Demo_Video.flv';
		} else if (params.type == 'openbox') {
			identifier = '5AtPW4q3wqA';
		} else {
			if (document.location.protocol == "https:") {
				file_name = 'Main_Demo_Video.flv';
			} else {
				identifier = 'IcjgqQTPFx4';
			}
			
		}
		
		
		if (identifier) {
			var video_params = '&hl=en&fs=1&hd=1&autoplay=1';
			var encoded_video_params = escape(video_params);
			var eloqua_redirect_to_youtube = '/elqNow/elqRedir.htm?ref=http://www.youtube.com/v/'
					+ identifier + encoded_video_params
			$('#presentation_content_video')
					.html(
							'<iframe id="gallery_content_frame" src="' + eloqua_redirect_to_youtube + '" style="width: 623px; height: 368px;" name="frameName" frameborder="0"></iframe>');
		} else {
			var params = {
				allowfullscreen : 'true',
				allowscriptaccess : 'always',
				wmode : 'opaque',
				bgcolor : '#333333'
			}
			var flashvars = {
				autostart : true,
				screencolor : '#333333',
				file : flash_folder + file_name
			}
			swfobject.embedSWF(flash_url + "player.swf",
					"presentation_content_video", "621", "367", "9", null,
					flashvars, params);
		}
	},
	show_presentation : function(params) {
		params = params || {};
		var dim = $('<div id="presentation_blocker"></div>').appendTo(
				document.body);
		$(window).resize(function() {
			box_presentation._presentation_blocker_resize(dim);
		});
		var div;
		if (params.type == 'enterprise') {
			div = $(
					'<div id="presentation_content" class="vid" style="width: 624px"><div><div class="presentation-content_header_small"><a href="#" class="close"><!-- --></a></div><div id="presentation_content_video"></div></div></div>')
					.appendTo(document.body);
			box_presentation._show_media(params);
		} else if (params.type == 'developers') {
			div = $(
					'<div id="presentation_content" class="vid"><div><div class="presentation-content-header"><a href="#" class="close"><!-- --></a><a href="/developers/services" class="start-developing">Start Developing</a><h1>Learn more about OpenBox and our APIs</h1><p>Questions? Read our <a href="http://developers.box.net">OpenBox Documentation</a></p></div><div id="presentation_content_video"></div></div></div>')
					.appendTo(document.body);
			box_presentation._show_media(params);
		} else if (params.type == 'quote_salesforce_page') {
			div = $(
					'<div id="presentation_content" class="vid"><div><div class="presentation-content-header"><a href="#" class="close"><!-- --></a><a href="/salesforce" class="start-developing">Talk to us</a><h1>Learn how Box.net works with Salesforce CRM.</h1><p>Interested? Call 1-866-495-0635 or <a href="/salesforce">Request More Information</a></p></div><div id="presentation_content_video"></div></div></div>')
					.appendTo(document.body);
			box_presentation._show_media(params);
		} else if (params.type == 'file_preview') {
			div = $(
					'<div id="presentation_content" class="vid"><div><div class="presentation-content-header"><a href="#" class="close"><!-- --></a><a href="/salesforce" class="start-developing">Talk to us</a><h1>Instantly view files without leaving your browser.</h1><p>Interested? Call 1-866-495-0635 or <a href="/quote">Request More Information</a></p></div><div id="presentation_content_video"></div></div></div>')
					.appendTo(document.body);
			box_presentation._show_media(params);
		} else if (params.type == 'features_popup') {
			div = $(
					'<div id="presentation_content"><div class="chart_wrap"><a href="#" class="close chart"><!-- --></a><div class="cols big"><p>Call us for volume discounts <br/> 1-877-729-4269</p><table cellspacing="8" id="feature_list"><tbody><tr><td>Price</td></tr><tr><td>Web-Storage</td></tr><tr><td>File size limit</td></tr><tr><td>File sharing links</td></tr><tr><td>Mobile app access</td></tr><tr><td><strong>Expanded sharing</strong></td></tr><tr><td>Password protected sharing</td></tr><tr><td>Faster uploads</td></tr><tr><td><strong>Enhanced collaboration</strong></td></tr><tr><td>Full-text search</td></tr><tr><td> Download stats and tracking</td></tr><tr><td>Sync desktop files</td></tr><tr><td>User administrative console</td></tr><tr><td>Document version history</td></tr><tr><td>Google Apps integration</td></tr><tr><td><strong>Secure & scalable content management</strong></td></tr><tr><td>Encrypted storage & transfer</td></tr><tr><td>Full Custom branding</td></tr><tr><td>Role-based access control</td></tr><tr><td>Salesforce.com integration</td></tr><tr><td>Dedicated support</td></tr><tbody></table></div><div class="cols small"><h2>Lite</h2><a class="button_pop" href="/signup/lite" onclick="log_ab_test_event(\'POPUP_CLICK_LITE\')">Signup</a><ul><li>Free</li><li>1 GB</li><li>25 MB</li></ul></div><div class="cols small"><h2>Individual</h2><a class="button_pop" href="/signup/individual" onclick="log_ab_test_event(\'POPUP_CLICK_INDIVIDUAL\')">Start Free Trial</a><ul><li>$9.95/month</li><li>10 GB</li><li>1 GB</li></ul></div><div class="cols small"><h2>Business</h2><a class="button_pop" href="/signup/business" onclick="log_ab_test_event(\'POPUP_CLICK_BUSINESS\')">Start Free Trial</a><ul><li>$15/user/month</li><li>15 GB/user</li><li>2 GB</li></ul></div><div class="cols small"><h2>Enterprise</h2><a class="button_pop" href="/quote/enterprise" onclick="log_ab_test_event(\'POPUP_CLICK_ENTERPRISE\')">Get in Touch</a><ul><li>Call for pricing</li><li>Unlimited</li><li>2 GB</li></ul></div></div></div>')
					.appendTo(document.body);
		} else if (params.type == 'google_features_popup') {
			div = $(
					'<div id="presentation_content"><div class="google_chart"><a href="#" class="close chart"><!-- --></a><div class="cols big"><p>Call us for volume discounts <br/> 1-877-729-4269</p><table cellspacing="8" id="feature_list"><tbody><tr><td>Price</td></tr><tr><td>Web-Storage</td></tr><tr><td>File size limit</td></tr><tr><td>File sharing links</td></tr><tr><td>Mobile app access</td></tr><tr><td><strong>Expanded sharing</strong></td></tr><tr><td>Password protected sharing</td></tr><tr><td>Faster uploads</td></tr><tr><td><strong>Enhanced collaboration</strong></td></tr><tr><td>Full-text search</td></tr><tr><td> Download stats and tracking</td></tr><tr><td>Extended file previewing</td></tr><tr><td>User administrative console</td></tr><tr><td>Document version history</td></tr><tr><td>Google Apps integration</td></tr><tr><td><strong>Secure & scalable content management</strong></td></tr><tr><td>Encrypted storage & transfer</td></tr><tr><td>Full Custom branding</td></tr><tr><td>Role-based access control</td></tr><tr><td>Salesforce.com integration</td></tr><tr><td>Dedicated support</td></tr><tbody></table></div><div class="cols small"><h2>Individual</h2><a class="button_pop" href="/signup/individual" onclick="log_ab_test_event(\'POPUP_CLICK_INDIVIDUAL\')">Start Free Trial</a><ul><li>$9.95</li><li>10 GB</li><li>1 GB</li></ul></div><div class="cols small"><h2>Professional</h2><a class="button_pop" href="/signup/professional" onclick="log_ab_test_event(\'POPUP_CLICK_\')">Start Free Trial</a><ul><li>$19.95/month</li><li>15 GB</li><li>1 GB</li></ul></div><div class="cols small"><h2>Business</h2><a class="button_pop" href="/signup/business" onclick="log_ab_test_event(\'POPUP_CLICK_BUSINESS\')">Start Free Trial</a><ul><li>$15/user/month</li><li>15 GB/user</li><li>2 GB</li></ul></div><div class="cols small"><h2>Enterprise</h2><a class="button_pop" href="/quote/enterprise" onclick="log_ab_test_event(\'POPUP_CLICK_ENTERPRISE\')">Get in Touch</a><ul><li>Call for pricing</li><li>Unlimited</li><li>2 GB</li></ul></div></div></div>')
					.appendTo(document.body);
		} else if (params.type == 'benefits_popup') {
			div = $(
					'<div id="presentation_content"><div class="list_wrap"><a href="#" class="close list"><!-- --></a><div class="popup_column med"><h2>Individual<br/><span>$9.95/month</span></h2><ul class="top_spec"><li><strong>10 GB</strong> of web-storage</li><li><strong>1 GB</strong> file size limit</li></ul><a class="pricing_plan-button" href="/signup/individual" onclick="log_ab_test_event(\'POPUP_CLICK_INDIVIDUAL\')">Start Free Trial</a><p class="plan-options-titles ex-storage">Expanded sharing &amp; storage</p><ul class="plan-options"><li>Premium OpenBox applications</li><li>Faster uploads</li><li>Email/phone support</li></ul></div><div class="popup_column large"><h2>Business<br/><span>$15/user/month</span></h2><ul class="top_spec"><li><strong>15 GB</strong> of web-storage per user</li><li><strong>2 GB</strong> file size limit</li></ul><a class="pricing_plan-button" href="/signup/business" onclick="log_ab_test_event(\'POPUP_CLICK_BUSINESS\')">Start Free Trial</a><p class="plan-options-titles collaborations">Enhanced collaboration</p><ul class="plan-options"><li>Complete version history</li><li>Comprehensive full-text search</li><li>Invite others to edit or add files</li></ul><p class="plan-options-titles management">Simple project management</p><ul class="plan-options"><li>Assign tasks to update files</li><li>Professional co-branding</li><li>User administrative console</li></ul><p class="plan-options-titles files">Online file system</p><ul class="plan-options"><li>File download insight & tracking</li><li>Password protected file sharing</li><li>Expanded user permission types</li></ul><p class="d">Dedicated customer service</p></div><div class="popup_column med2"><h2>Enterprise<br/><span>Call for pricing</span></h2><ul class="top_spec"><li><strong>Unlimited</strong> web-storage</li><li><strong>2 GB</strong> file size limit</li></ul><a class="pricing_plan-button" href="/quote/enterprise" onclick="log_ab_test_event(\'POPUP_CLICK_ENTERPRISE\')">Get in Touch</a><p class="plan-options-titles cloud">Secure cloud for your company</p><ul class="plan-options"><li>Encrypted storage and transfer</li><li>Group based permissioning</li><li>Complex password enforcement</li></ul><p class="plan-options-titles content">Scalable content management</p><ul class="plan-options"><li>Full Custom branding</li><li>Full reporting and activity history</li><li>All enhanced collaboration features</li></ul><p class="plan-options-titles intergration">Custom integration</p><ul class="plan-options"><li>API access for custom integrations</li><li><a href="http://www.box.net/salesforce">Salesforce.com integration</a></li><li>Premium OpenBox applications</li></ul><p class="d">Dedicated account management</p><ul class="plan-options"><li>Fast-start services</li></ul></div></div></div>')
					.appendTo(document.body);
		} else if (params.type == 'security') {
			div = $(
					'<div id="presentation_content"><a href="#" class="close close_security"><!-- --></a><img id="security_popup" src="/img/sales/security_diagram_lrg.jpg" /></div>')
					.appendTo(document.body);
		} else if (params.type == 'QR_code') {
			div = $(
					'<div id="presentation_content"><div class="qr_wrapper"><h3>Install Box for Android with this QR code:<a href="#" class="close qr"><!-- --></a></h3><img src="http://blog.box.net/qrcode.png" alt="qrcode"/><a href="http://blog.box.net/boxforandroid.apk">Download Box for Android</a></div></div>')
					.appendTo(document.body);
		} else if (params.type == 'video_demo') {
			div = $(
					'<div id="presentation_content" class="vid"><div><div id="presentation_content_video"></div></div></div>')
					.appendTo(document.body);
			box_presentation._show_media(params);
		} else {
			div = $(
					'<div id="presentation_content" class="vid"><div><div class="presentation-content-header"><a href="#" class="close"><!-- --></a><a href="/pricing" class="try-box"><!-- --></a><h1>Learn how Box.net makes sharing simple.</h1><p>Questions? Call 1-877-729-4269 or <a href="/quote">Request More Information</a></p></div><div id="presentation_content_video"></div></div></div>')
					.appendTo(document.body);
			box_presentation._show_media(params);
		}
		$('#presentation_content a.close, #presentation_blocker').click(
				function() {
					$('#presentation_content').remove();
					$('#presentation_blocker').remove();
					$(window).unbind('resize');
					return false;
				});
		if (params['no_signup']) {
			$('#presentation_content .signup').hide();
		} else {
			$('#presentation_content .signup').show();
		}
		Common_Global.set_center_position($('#presentation_content').get(0),
				params.type == 'enterprise' ? 60 : 30);
		box_presentation._presentation_blocker_resize(dim);
	}
};



