var addthis_config = {
	ui_cobrand: "Raytheon",
	ui_header_color: "#ffffff",
	ui_header_background: "#cf1024"/*,
	data_ga_property: 'UA-12588159-1',
	data_track_clickback: true*/
}
var default_values = new Array();

Shadowbox.init({
	//skipSetup: true,viewportPadding: 5,
	language:   "en",
	players:    ["iframe","html"/*,"img"*/],
	modal: false,
	overlayColor: "#e61937",
	overlayOpacity: .9,
	useSizzle: false
});


$(function() {

	$('#regform input#fm_fname,input#fm_fname2').val("* first name:");
	$('#regform input#fm_lname,input#fm_lname2').val("* last name:");
	$('#regform input#fm_email,input#fm_email2').val("* e-mail:");
	$('#regform input#fm_phone,input#fm_phone2').val("phone:");
	$('#regform input#fm_ind,input#fm_ind2').val("industry conferences attended:");
	
	$('.signupForm input[type="text"]').addClass("idleField");

	$('.signupForm input[type="text"]').each(function() {
		if (!default_values[this.id]) { default_values[this.id] = this.value; }
	});

	$('.signupForm input[type="text"]').focus(function() {
													 
		if (!default_values[this.id]) { default_values[this.id] = this.value; }
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == default_values[this.id]) { this.value = ''; }
		if (this.value != default_values[this.id]) { this.select(); }
	});
	$('.signupForm input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == '') { this.value = (default_values[this.id] ? default_values[this.id] : ''); }
	});
	
	$('div.scrollable').scrollable({vertical:true, keyboard: false, circular: true, mousewheel: false, speed: 900}).navigator().autoscroll({autoplay: true,interval: 8000});
	$('#flowpanes').scrollable({ keyboard: false,circular: true,mousewheel: false, speed:1200 }).navigator({navi:'.flowbtns'}).autoscroll({autoplay: true,interval: 9000});

});

var spInit = function() {
	$('#inst span[class^="sl"]').tooltip({ effect: 'slide'});
	$('#inst span.curr').animate({color:"#CE1126"}, 1000 ).animate({color:"#000000"}, 800 )
	.animate({color:"#CE1126"}, 1000 ).animate({color:"#000000"}, 800 )
	.animate({color:"#CE1126"}, 1000 ).animate({color:"#000000"}, 800 )
	.animate({color:"#CE1126"}, 1000 ).animate({color:"#000000"}, 800 )
	.animate({color:"#CE1126"}, 1000 ).animate({color:"#000000"}, 800 )
	.animate({color:"#CE1126"}, 1000 ).animate({color:"#000000"}, 800 );
};

var reminderPopup = function(initDelay, secondDelay, pBorderColor,pBkndColor) {
	if (initDelay == null || initDelay == "") {initDelay = 0;}
	if (secondDelay == null || secondDelay == "") {secondDelay = 6000;}
	if (pBorderColor == null || pBorderColor == "") {pBorderColor = '#73909E';}//'#CE1126'
	if (pBkndColor == null || pBkndColor == "") {pBkndColor = '#bad2de';}//ba2d21
	$('#signupremind')
	.hide()
	.delay(initDelay)
	.fadeIn(300)
	.animate({top: '-=50'}, {duration:2000, easing: 'easeOutBounce'})
	.delay(secondDelay)
	.fadeOut(1500);
	
	$('#regform')
	.delay(initDelay)
	.animate({borderColor:pBorderColor, backgroundColor:pBkndColor},2000)
	.delay(secondDelay)
	.animate({borderColor:'#ffffff', backgroundColor:'#ffffff'},1500);
};



function isBlank(str) { return !str || !/\S/.test(str); }
// http://stackoverflow.com/questions/1667565/validate-text-boxes-against-custom-set-variable
function isInteger(s) { 
	var i;
	for (i = 0; i < s.length; i++) {
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag) { 
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++) {
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function newPopup(txtCopy) {
	Shadowbox.open({
		content:	txtCopy,
		player:		"html",
		width: 		375,
		height:		250,
		options: 	{onClose: null}
	});		
}

function validateSignup(iVal) {
	var alertTxt = "";
	if ($("#fm_fname"+iVal).val() == "" || $("#fm_fname"+iVal).val() == default_values["fm_fname"+iVal])  {alertTxt+="<li>Enter your First Name</li>";}
	if ($("#fm_lname"+iVal).val() == "" || $("#fm_lname"+iVal).val() == default_values["fm_lname"+iVal])  {alertTxt+="<li>Enter your Last Name</li>";}
	if ($("#fm_email"+iVal).val() == "" || $("#fm_email"+iVal).val() == default_values["fm_email"+iVal])  {alertTxt+="<li>Enter your Email Address</li>";}		
	if ($("#fm_state"+iVal).val() == "")  {alertTxt+="<li>Choose a state</li>";}
	//if ($("#regform"+iVal+" input[@name='US Citizen']:checked").val() == null) {alertTxt+="<li>Select if you are or are not a US Citizen</li>";}
	if (alertTxt == "") { return true; } 
	else {
		newPopup("<h3>Please provide the following information</h3><ul>"+alertTxt+"</ul>");
		return false; 
	}
}
