
// Include function to position logo here intead of calling positionlogo.js on INDEX pages only 
// All other pages that don't have webcam use positionlogo.js

function DoRefresh() {
// document.location.href = '<? echo "/index.php" //$refreshURL; ?>';
	JSONparameters = '';
	var randomnumber=Math.floor(Math.random()*100000000)		
	$.ajax({ 
			type: "GET",
			url: "samPHPweb/rc_playing.php?r=" + randomnumber,
			data: JSONparameters,
			dataType: "html",     				
			success: function(result) {
				var playlistHTML = result;
				//$('#current_playlist').fadeOut("slow", function()	{
					//$('#current_playlist').fadeIn("slow");
					$('#current_playlist').html(playlistHTML);
				//})
				
			}
		});			

}

$(document).ready(function(){
	// Your code here
	$("#requestlink").colorbox({top: "80px !important;", width:"80%", height:"80%", iframe:true});
	
	$.get("http://www.rcradionetwork.com/getliveimagedate.php",{ camera: whichcamera}, function(data){
		//alert("Data Loaded: " + data);
		var lastModif = data;
		$('#image_modified_date').html(lastModif);			
	});
	positionLogo();
	
	var refreshID = "";
	refreshID = setInterval('DoRefresh()', 30000);	
	//DoRefresh();
	//alert($.browser.msie);
/*	if ( $.browser.msie || $browser.mozilla )	{
		$('#tr.playing_row').css({ 
			"background": "url(images/playing_row_bg.png) no-repeat 0 0", 
			"height": "95px"
		});
		$('#tr.playing_row_sm').css( { 
			"background": "url(images/playing_row_sm_bg.png) no-repeat" ,
			"height": "63px" 
		});
	} else {
		$('#tr.playing_row').css({ 
			height: "95px"
		});
		$('#tr.playing_row_sm').css( { 
			height: "63px"
		});
	}
*/
	
});
// Refress Playlist

// JAVACRIPT FOR LIVE CAM
myTimer = setInterval('rotateLiveImage()',15000);
var i_counter = 1;
var whichcamera = 1;		// specifies the camera 1 or 2
function rotateLiveImage() {
	var randomnumber=Math.floor(Math.random()*100000000)		
	
	if(whichcamera == 1)	{
		$("#webcam").attr("src","/images/live_images/webcam1.jpg?mtime=" + randomnumber);
		whichcamera = 2;
	} else {
		$("#webcam").attr("src","/images/live_images/camera2.jpg?mtime=" + randomnumber);
		whichcamera = 1;
	}
	$.get("http://www.rcradionetwork.com/getliveimagedate.php",{ camera: whichcamera}, function(data){
			//alert("Data Loaded: " + data);
			var lastModif = data;
			$('#image_modified_date').html(lastModif);
	});
}

// Function to position logo in center of page on load and resize
function positionLogo()	{
	var x  = ($(document).width()/2) - 112;
	var y = 72;     // spacing from top of page         
	var cssObj = {
		"top": y,
		"left" : x,
		"display" : "block"
    }
	$("#mainlogo").css(cssObj);
	
	// set hot area for home page click on house image in top banner
	var x  = ($(document).width()/2) + 414;
	var y = 142;     // spacing from top of page         
	var cssObj = {
		"top": y,
		"left" : x,
		"display" : "block"
    }
	$("#homehotarea").css(cssObj);
}

window.onresize = function() { 
	positionLogo();
}
