//variables
var ami_vals=new Array("20px","100px","200px","300px","390px");
var navpgesel="";
var imagepage="images/bg_images/";

//jquery
$(document).ready(function(){
//popup map hide
$('div map area.close').click(function(){
	$(this).parent().parent().fadeOut();
	return false;
});
	$(window).bind("load",function(){
		$('#r_sec').cycle({
			speed: 1500,
			timeout: 8000
		});							   
	});

						   
						   
	if(readCookie('addclicked'))
	{
		$('#page_wrap').css("display","none");
	}
	else
	{
		$('#page_wrap').css("display","block");
	}
	
	
	$('#pos').hide();
	$('#neg').hide();
						   
	var w_height=$(window).height();
	var lsec_height=w_height-106;
	
	$('#l_sec').css("height",lsec_height+"px");

	$(window).resize(function(){
		w_width=$(window).width();
		w_height=$(window).height();
		lsec_height=w_height-106;
		$('#l_sec').css("height",lsec_height+"px");
	});
	
	$('#navi_con li a').mouseover(function(){
		thisid=ami_vals[$('#navi_con li a').index(this)];
	 	$('#nav_arrow').stop().animate({left: thisid}, 1500, "easeInOutExpo");
	});
	
	$('#navi_con li a').mouseout(function(){
		thisid=ami_vals[$('#navi_con li a').index(this)];
	 	$('#nav_arrow').stop().animate({left: navpgesel}, 1500, "easeInOutExpo");
	});
	
	/*if(!readCookie('addclicked')=="yes")
	{
		$('#r_sec').cycle({
			speed: 1500,
			timeout: 8000
		});
	}*/
	
	
			$('#baf').submit(function(){
				
				var baf_email = $('#email').val(); 
									  
				$.post("scripts/php/baf.php",{email: baf_email}, function(data){
					if(data == "complete") {
						
						$('#neg').hide();
						$('#pos').text("");
						$('#norm').hide();
						
						$('#pos')
						.addClass('bafreturn')
						.html("<strong>( "+ baf_email +" )</strong> was submitted successfully")
						.show('slow');						
					} else {
						
						$('#neg').text("");
						$('#pos').hide();
						$('#norm').hide();
						
						$('#neg')
						.addClass('bafreturn')
						.html("There was a problem with your submission:" + data)
						.show('slow')						
					}
				});
				return false;
			});
			
	$('#close').click(function(){
		createCookie('addclicked', 'yes',0);
		$('#page_wrap').css("display","none");
		$('#r_sec').cycle({
			speed: 1500,
			timeout: 8000
		});
	});
	
});

//javascript functions
function pnv(strinp)
{	
	$(function(){
		$('#nav_arrow').css("left",ami_vals[strinp]); 
		navpgesel=ami_vals[strinp]
	});	
}


function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}