var shoutbox_request = 1;
var sb_interval;
sb_interval = setInterval("shoutbox_display()", 7500);

function menu_close()
{
	$("#menu-display-container").fadeOut("fast", function(){
				$("#content").html("");						
				$("#content2").html("");			
	});
}

function menu_open(url)
{
	$("#content").show();						
	$("#content2").show();	
	$("#menu-display-container").fadeIn("slow", function(){
		if(url == "maps.php")
		{
			$("#content").hide();
			$("#content2").load(url + "?" + Math.random());
		}
		else
		{
			$("#content2").hide();
			$("#content").load(url + "?" + Math.random());
		}
	});
}

function menu_send_to_friend()
{
	$("#menu-display-container").fadeIn("slow", function(){
		$("#content").load("sendtofriend.php?" + Math.random());
	});
}

function chk_frm_send_to_friend()
{
	var from = $("#txtEmail");
	var to = $("#txtEmailTo");
	var message = $("#txtMessage");
	if(to.val() == "")
	{
		alert("Please, Enter recipient's email.");
		to.focus();
		return false;
	}
	else if(from.val() == "")
	{
		alert("Please, Enter your email.");
		from.focus();
		return false;
	}
	else if(message.val() == "")
	{
		alert("Please, Enter message.");
		message.focus();
		return false;
	}
	else
	{
		$.ajax({
				type: "POST",
				url: "send.php",
				data: "to=" + to.val() + "&from=" + from.val() + "&message=" + message.val(),
				dataType: "html",
				cache: false, 
				error: function() { 
					alert('Sorry, The Send mail system is inconvience.');
				},
				success: function(data) {
					if(data == "Success!!")
					{
						alert('Thank you for using our service.');
						menu_close();
					}
					else
					{
						alert('Sorry, The Send mail system is inconvience.');
						menu_close();
					}
				}
			});
		return false;
	}
}

function menu_video(url)
{
	$("#menu-display-container").fadeIn("slow", function(){
		$("#content2").hide();
		$("#content").load(url + "?" + Math.random(), function(){
			$("#video-player").flash({
				swf: 'flash/player-viral.swf',
				params: {
					wmode: 'transparent',
					allowfullscreen: 'true'
				},
				flashvars: {
					file: 'http://www.route66club.com/event/E00034/video/video.flv',
					autostart: true
				},
				width: 288,
				height: 230
			});							   
		});										  
	});
}

function video_player(path)
{
	$('#video-player').html('');
	$("#video-player").flash({
				swf: 'flash/player-viral.swf',
				params: {
					wmode: 'transparent',
					allowfullscreen: 'true'
				},
				flashvars: {
					file: path,
					autostart: true
				},
				width: 288,
				height: 230
			});
}
function frmShoutboxSubmit(){
	if(document.frmShoutBox.onsubmit()){
	document.frmShoutBox.submit();
	}
}

function frmSendToFriendSubmit()
{
	if(document.frmSendToFriend.onsubmit()){
	document.frmSendToFriend.submit();
	}
}
function language(lan)
{
	$.ajax({
				type: "POST",
				url: "language.php",
				data: "language=" + lan,
				dataType: "html",
				cache: false, 
				error: function() { 
					alert('Error Something');
				},
				success: function(data) {
					window.location.reload();
				}
			});
}

function photo_theme(gid)
{
	$.ajax({
				type: "POST",
				url: "photo.php",
				data: "gid=" + gid,
				dataType: "html",
				cache: false, 
				error: function() { 
					alert('Error Something');
				},
				success: function(data) {
					$("#content").html(data);		
				}
			});
}

function video_theme(gid)
{
	$.ajax({
				type: "POST",
				url: "video.php",
				data: "gid=" + gid,
				dataType: "html",
				cache: false, 
				error: function() { 
					alert('Error Something');
				},
				success: function(data) {
					$("#content").html(data);		
				}
			});
}

function chk_frm_shoutbox(){
		var sb_frm = document.frmShoutBox;
		var sb_name = sb_frm.sb_name;
		var sb_email = sb_frm.sb_email;
		var sb_message = sb_frm.sb_message;
		if(sb_name.value == ""){
			alert("Please, Enter your name.");
			sb_name.focus();
			return false;
		}
		else if(sb_email.value == ""){
			alert("Please, Enter your email.");
			sb_email.focus();
			return false;
		}
		else if(sb_email.value.indexOf('@') == -1){
			alert("Please, Enter valid email.");
			sb_email.value = "";
			sb_email.focus();
			return false;
		}
		else if(sb_email.value.indexOf('.') == -1){
			alert("Please, Enter valid email.");
			sb_email.value = "";
			sb_email.focus();
			return false;
		}
		else if(sb_message.value == ""){
			alert("Please, Enter your message.");
			sb_message.focus();
			return false;
		}
		else{
			$.ajax({
				type: "POST",
				url: "shoutbox.php",
				data: "action=post&name=" + sb_name.value + "&email=" + sb_email.value + "&message=" + sb_message.value,
				dataType: "html",
				cache: false, 
				error: function() { 
					alert('Error Something');
				},
				success: function(data) {
					sb_name.value = ""
					sb_email.value = "";
					sb_message.value = "";
					shoutbox_display();
				}
			});
			return false;
		}
}

function shoutbox_display()
{
	shoutbox_request = 1;
	$.ajax({
		type: "POST",
		url: "shoutbox.php",
		data: "action=get",
		dataType: "html",
		cache: false, 
		success: function(data)
		{
			$("#shoutbox-display").html(data);
			shoutbox_request = 0;
		}
	});
}

$(document).ready(shoutbox_display);
$(document).ready(function(){
	$(document).pngFix();
	/*
	$("#menu-display-container").click(function(){
			$(this).fadeOut("fast", function(){
				$("#content").html("");		
			});
	});
		*/
	$('#main-flash').flash({
			swf: 'flash/main.swf?' + Math.random(),
			width: 995,
			height: 635
	});
	
	$("#shoutbox-container").hover(
		function(){
			shoutbox_display();
		},
		function(){

		}
	);

	$("#shoutbox-marquee").marquee("cursor").mouseover(function () {
		$(this).trigger("stop");
	}).mouseout(function () {
		$(this).trigger("start");
	}).mousemove(function (event) {
		if ($(this).data("drag") == true) {
			this.scrollTop = $(this).data("scrollY") + ($(this).data("y") - event.clientY);
		}
	}).mousedown(function (event) {
		$(this).data("drag", true).data("y", event.clientY).data("scrollY", this.scrollTop);
	}).mouseup(function () {
		$(this).data("drag", false);
	});
});