// JavaScript Document
$(document).ready(function() {
	var agent = navigator.platform;
	center_align = function(w,h) {
		//var h = parseFloat($('.movie_box').css('height'), 10);
		var d = $(window).width();
		//var w = parseFloat($('.movie_box').css('width'), 10);
		$('.frame').css('marginBottom',-(h/2));
		$('.movie_box').css('marginLeft',(d-w)/2);
		$('.movie_box').css('marginRight',(d-w)/2);
	}
	divshow = function(n) {
		$('.cover').show();
		$('.cover').css('opacity',.7);
		$('.fade').show();
		$('.frame').show();
		$('.frame').css('height',($(window).height()/2));
		switch(n) {
			case 1:
				$('.movie_box').append('<div class="close" onclick="divshow(4);"><img src="images/ide_close.png"></div><div class="video"><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/tu7ZtAxBZhA?fs=1&amp;hl=en_US&version=3&autoplay=1&rel=0&border=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/tu7ZtAxBZhA?fs=1&amp;hl=en_US&version=3&autoplay=1&rel=0&border=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385" wmode="transparent"></embed></object></div>');
			center_align(640,385);
			$('.video').hide();
			delay_video();
			delay_btn();
			$('.close').css('left',610);
			break;
			case 2:
				$('.movie_box').append('<div class="close" onclick="divshow(4);"><img src="images/ide_close.png"></div><div class="video"><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/QhSQkGNyN-s?fs=1&amp;hl=en_US&version=3&autoplay=1&rel=0&border=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/QhSQkGNyN-s?fs=1&amp;hl=en_US&version=3&autoplay=1&rel=0&border=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385" wmode="transparent"></embed></object></div>');
			center_align(640,385);
			$('.video').hide();
			delay_video();
			delay_btn();
			$('.close').css('left',610);
			break;
			case 3:
				$('.movie_box').append('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="835" height="475"><param name="movie" value="https://www.idrive.com/demo/demo_intro.swf?local=1" /><param name="allowScriptAccess" value="always" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="https://www.idrive.com/demo/demo_intro.swf?local=1" width="835" height="475" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" menu="false" allowScriptAccess="always"></embed></object>');
			center_align(835,475);
			$('.movie_box').css('visibility','visible');
			break;
			case 4:
				$('.cover').hide();
			$('.fade').hide();
			$('.frame').hide();
			$('.movie_box').empty();
			break;
			case 5:
				$('.movie_box').append('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="840" height="480"><param name="movie" value="https://www.idrive.com/mac_demo/mac_interface_index.swf?local=1" /><param name="allowScriptAccess" value="always" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="https://www.idrive.com/mac_demo/mac_interface_index.swf?local=1" width="840" height="480" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" menu="false" allowScriptAccess="always"></embed></object>');
			center_align(835,475);
			$('.movie_box').css('visibility','visible');
			break;
			/*case 6:
				$('.movie_box').append('<div class="planpop" id="popbox"><h1 class="txtheader"><br/>The Family Pack Plan <span class="popclose" onClick="divshow(4);"></span></h1><br/><br/><br/><div class="popdiv"><p>Backup upto 5 PCs / Macs to the same IDrive account.<br/><br/> <span class="txtstrong">Storage space: </span>500 GB<br /><br /><a href="https://www.idrive.com/idrivee/jsp/ide_prosignup.jsp?pln=F" target="_parent" class="lnkterms">Sign up for the Family Pack Plan</a>. Setup the IDrive client with same account credentials to the computers you wish to backup. Data backed up from each computer is visible under the same computer name. The file / folder hierarchy of the backed up data is retained for easy data restore.<br/><br/><span class="txtnote">Note:</span> You cannot backup both PC and Mac data in a single Family Pack account.</p><br /><img src="images/ide_family_new.jpg" height="200px" width="491px"></div></div>');
			center_align(835,475);
			$('.movie_box').css('visibility','visible');
			break;*/
		}
	}
	;
	//video swaping for PC, Mac and handheld devices
	$('#ide_bullet').click(function() {
		if(agent.indexOf('Win') != -1 || agent.indexOf('Mac') != -1 || agent.indexOf('Linux') != -1) {
			divshow(1);
			$(this).attr('href','javascript:void(0);');
		} else {
			$(this).attr('href','idrive_bulletproof_ad.htm');
		}
	}
	);
	$('#ide_hackernet').click(function() {
		if(agent.indexOf('Win') != -1 || agent.indexOf('Mac') != -1 || agent.indexOf('Linux') != -1) {
			divshow(2);
			$(this).attr('href','javascript:void(0);');
		} else {
			$(this).attr('href','idrive_terminator_ad.htm');
		}
	}
	);
	//demo swaping for PC and Mac
	$('#ide_demo_btn').click(function() {
		if(agent.indexOf('Mac') != -1) {
			divshow(5);
			$(this).attr('href','javascript:void(0);');
		} else if(agent.indexOf('Win') != -1) {
			divshow(3);
			$(this).attr('href','javascript:void(0);');
		} else if(agent.indexOf('Linux') != -1) {
			divshow(3);
			$(this).attr('href','javascript:void(0);');
		}
		/*else if(agent.indexOf('iPod') != -1 || agent.indexOf('iPhone') != -1 || agent.indexOf('iPad') != -1){
			$(this).attr('href','idrive-for-mac.htm');
		}*/ else {
			$(this).attr('href','online-backup-demo.htm');
		}
	}
	);
	//download page swaping for PC and Mac
	$('.ide_download').click(function() {
		if(agent.indexOf('Mac') != -1) {
			$(this).attr('href','idrive-for-mac.htm');
		} else {
			$(this).attr('href','online-backup-download.htm');
		}
	}
	);
	//demo page swaping for PC and Mac
	$('.ide_demo').click(function() {
		if(agent.indexOf('Mac') != -1) {
			$(this).attr('href','mac_demo.htm');
		} else {
			$(this).attr('href','online-backup-demo.htm');
		}
	}
	);
	//time delay for video
	delay_video = function() {
		$('.video').oneTime('1ms', function() {
			$(this).show();
		}
		);
	}
	;
	//time delay for close button in video ads
	delay_btn = function() {
		$('.video').oneTime('3s', function() {
			$('.close').fadeIn();
		}
		);
	}
	;
}
);
