/////////////////////////////////////////////////////////
// base.js
// Taco Bell - Base JS functions/declarations
//
// author: Rayman Wong
// contact: rayman.wong@gmail.com
// created on: 7/20/2011
// last modified: 8/25/2011
//
// dependencies: 
// jQuery (1.4.2), jquery.simplemodal-1.3.3
//
// comments: still work in progress
/////////////////////////////////////////////////////////

/*** CONSTANTS ***/
// SITE_IMG_PATH - this should be the absolute path to the main images folder
var SITE_IMG_PATH = tacoBell.imagePath;
var SITE_ASSETS_PATH = '/tb_files';

// dayTimeValues - settings for the time ranges of the day parts
var dayTimeValues = {
	'morning': [ '04:00', '10:59:59'],
	'midday': [ '11:00', '14:59:59'],
	'afternoon': [ '15:00', '16:59:59'],
	'evening': [ '17:00', '20:59:59'],
	'latenight': [ '21:00', '03:59:59']
};
/*** END CONSTANTS ***/

$(document).ready( function(){
	
});

// getTimeOfDay() - finds the correct day part for the client machine viewing site
function getTimeOfDay(){
	var today = new Date();
	var dateStr = (today.getMonth()+1) + "/" + today.getDate() + "/" + today.getFullYear();
	var timeOfDay = "";
	
	$.each(dayTimeValues, function(key, val) {
		var startTime = new Date(dateStr + " " + val[0]);
		var endTime = (key == 'latenight') ? new Date((dateStr+1) + " " + val[1]) : new Date(dateStr + " " + val[1]);
		
		if( (today >= startTime) && (today <= endTime) ){ 
			timeOfDay = key;
			
			// break out of each loop
			return false;
		}
	});
	
	return timeOfDay;
}

/*** Cross-site Functions ***/

// showModal() - site wide fn to display modal links/pop-ups
function showModal(el){
	var obj = '';
	switch(typeof el){
		case 'object':
			obj = $(el);
			break;
		case 'string':
			// assume el is id
			obj = $('#'+el);
			break;
		default:
	}
	
	obj.modal({overlayClose:true});
	
	// make sure link does not return
	//return false;
}

// setupCarousel()
// for possible configuration settings see:
// http://sorgalla.com/projects/jcarousel/#Configuration
function setupCarousel(el, config){
	// return jQuery object
	return el.jcarousel(config);
}

// Border radius browser test
// adapted from: http://www.cssnewbie.com/test-for-border-radius-support/
/* Example use:
	if($.support.borderRadius) { 
		alert('I can do rounded corners!'); 
	} else { 
		alert('No rounded corners for me!'); 
	}
*/
jQuery(function() {
	jQuery.support.borderRadius = false;
	jQuery.each(['borderRadius','BorderRadius','MozBorderRadius','WebkitBorderRadius','OBorderRadius','KhtmlBorderRadius'], function() {
		if(document.body.style[this] !== undefined) jQuery.support.borderRadius = true;
		return (!jQuery.support.borderRadius);
	});
});

// playBong() plays audio file when called
// must have empty span (<span id="bongHolder"></span>) somewhere on html page
function playBong(){
	$('#bongHolder').html(
		"<embed src=\"assets/sounds/tb_bong.wav\" hidden=\"true\" autostart=\"true\" loop=\"false\">"
	);
}

/*** END Cross-site Functions ***/

