//<![CDATA[
// Default test for older browsers
if (!document.getElementById  && document.location.href.indexOf("browerr.php") == -1) {
	document.location.href="<? echo($pathURL); ?>browerr.php";
}
var curr_tab = ''; 
var idevice = false;
var appData = new Array();
appData[0] = new Array();
appData[0]['body'] =  "Chipper entertains while playfully educating children about nature and the great outdoors. Download award winning movies, books, music, games, and more easily for everyday fun on-the-go.";
appData[1] = new Array();
appData[1]['body'] =  "On the go fun that is educational and entertaining. Camping, hiking, or outdoor fun Chipper playfully teaches good character and a love for the environment. Download now.";
appData[2] = new Array();
appData[2]['body'] =  "No mess, no fuss with Chipper&#039;s coloring pages that are playful and easy-to-follow. Select, swipe on the color, and save or start all over again. Download now.";

var bookData = new Array();
bookData[0] = new Array();
bookData[0]['title'] = "Break it Down with Bruce";
bookData[0]['body'] =  "Slide into the great outdoors and learn about nature&#039;s favorite composter – Bruce the banana slug. It&#039;s silly and slimy and inspires conscientiousness in kids, parents and educators.";
bookData[0]['link_buy'] =  "http://store.letsgochipper.com/Product47";

bookData[1] = new Array();
bookData[1]['title'] = "Let&#039;s Stroll Crissy Field";
bookData[1]['body'] =  "Come play by the Bay. Chipper takes the bus through San Francisco to meet Elroy, an egret, at a national park in a city! Learn about habitats, and more. A give back book!";
bookData[1]['link_buy'] =  "http://store.letsgochipper.com/Product46";

bookData[2] = new Array();
bookData[2]['title'] = "Out to Sea with Sally Book";
bookData[2]['body'] =  "Join Chipper as he goes under the surface with Sally to learn about the life of a salmon. Colorful, educational story that excites curiosity. Includes activity and coloring pages.";
bookData[2]['link_buy'] =  "http://store.letsgochipper.com/Product29";

bookData[3] = new Array();
bookData[3]['title'] = "Into the Great Outdoors";
bookData[3]['body'] =  "Excite curiosity while playfully educating children about the importance of taking care of nature in this story & activity book. Parent&#039;s Choice winner!  Ages 2-6. Correlated for schools.";
bookData[3]['link_buy'] =  "http://store.letsgochipper.com/Product11Direct";

bookData[4] = new Array();
bookData[4]['title'] = "Get Ready to Fly";
bookData[4]['body'] =  "Let Chipper prepare your young traveler before you even pack a bag. Activity book and crayons all nestled into a pillow back-pack and stored in a reusable tote perfect for travel.";
bookData[4]['link_buy'] =  "http://store.letsgochipper.com/Product8";

var appIdx = 0;
var bookIdx = 0;

function changeBook(type) {
	if (type != null) {
		switch (type) {
			case 'next':
				bookIdx++;
				break;
			case 'prev':
				bookIdx--;
				break;
		}
	}
	if (bookIdx < 0) { bookIdx = (bookData.length - 1); }
	else if (bookIdx >= bookData.length) { bookIdx = 0; }
	var content = '<h5>'+ bookData[bookIdx]['title'] +'</h5>';
	content += '<p>'+ bookData[bookIdx]['body'] +'</p>';
	if (bookData[bookIdx]['link_buy'] != '') content += '<p><a target="_blank" href="'+ bookData[bookIdx]['link_buy'] +'">Buy now!</a></p>';
	$('#book_content').html(content);
	Cufon.replace('#book_content h5');
}
function changeApp(type) {
	if (type != null) {
		switch (type) {
			case 'next':
				appIdx++;
				break;
			case 'prev':
				appIdx--;
				break;
		}
	}
	if (appIdx < 0) { appIdx = (appData.length - 1); }
	else if (appIdx == appData.length) { appIdx = 0; }
	$('#app_body').html('<p>'+ appData[appIdx]['body'] +'</p>');
}
function changeTab(new_tab) {
	if (new_tab != null && new_tab != curr_tab) {
		$('#center_'+new_tab).css('display','block');
		btnMOver.switchImg(new_tab,'On');
		if (curr_tab != '') {
			$('#center_'+curr_tab).css('display','none');
			btnMOver.switchImg(curr_tab,'Off');
		}
		curr_tab = new_tab;
		var boxHeight = '400px';
		if (new_tab == "videos")
			boxHeight = '650px';
		else if (new_tab == 'app')
			boxHeight = '335px';
		else if (new_tab == 'books')
			boxHeight = '325px';
		$('div.center_wrap').css('min-height',boxHeight);
	}
}
function ytplayer_loadvideo( tab, id  ) {
	if (!idevice) {
		var o = document.getElementById( 'ytplayer_object_' + tab );
		if( o ) {
			o.loadVideoById( id );
		}
	}
}

function isIDevice() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf('iphone') != -1 || agt.indexOf('iphod') != -1 || agt.indexOf('ipad') != -1) {
		return idevice = true;
	} else {
		return idevice = false;
	}
}

$(document).ready(function() {
	//alert($('#appItem').cycle());				   		
	// NAV FUNCTIONS
	if(from == "home"){
	$('#appItem').cycle({
		timeout: 0,
		fx:      'scrollHorz',
		easing:  'easeInOutCubic',
		prev:    '#appPrev',
		next:    '#appNext',
		pager:	 '#app_select',
		pagerClick: function(zeroBasedSlideIndex, slideElement) { appIdx = zeroBasedSlideIndex; changeApp(); },
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#"><img src="' + slide.src + '" width="108"  height="62" border="0" alt="" title="" /></a></li>';
		} 
	});
	$('#appItem').cycle('pause');
	$('#appPrev').click( function () { changeApp('prev'); });
	$('#appNext').click( function () { changeApp('next'); });
	$('#bookPrev').click( function () { changeBook('prev'); return false; });
	$('#bookNext').click( function () { changeBook('next'); return false; });
	$('#bookItem').cycle({
		timeout: 0,
		fx:      'scrollHorz',
		easing:  'easeInOutCubic',
		prev:    '#bookPrev',
		next:    '#bookNext'
	});
	//$('li[rel=app]').click( function () {	changeTab('app'); return false; });
	//$('li[rel=books]').click( function () { changeTab('books'); return false; });
	//$('li[rel=videos]').click( function () { changeTab('videos'); return false; });
	//$('li[rel=more]').click( function () { changeTab('more'); });
	//$('li[rel=tips]').click( function () { changeTab('tips'); });
	//$('li[rel='+ curr_tab +']').addClass('active');
	changeTab('app');
	Cufon.replace('h5');
	$('#bookItem').cycle('pause');	
	}
});
//]]>
