/**
*	COMMON SCRIPTS FOR RBN
*/

function jumpToState (state) {
	window.location.href = document.stateselector.rebatestate.options[state].value;
	RBNTracking('Rebate Finder (' + document.stateselector.rebatestate.options[state].text + ')');
}

var newwin;

function launchwin(winurl,winname,win_width,win_height,win_scroll) {
	if (win_scroll != 'yes') {
		var win_scroll = 'no';
	}
	
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	newwin = window.open(winurl,winname,'width=' + win_width + ',height= ' + win_height + ',fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=' + win_scroll + ',resizable=yes');
	try {
		if(javascript_version > 1.0) {
			//delay a bit here because IE4 encounters errors
			//when trying to focus a recently opened window
			setTimeout('newwin.focus();',250);
		}
	}
	catch(ex){}
}

function validatePwd() {
	if (document.UserForm.UserPassword1.value != document.UserForm.UserPassword2.value) {
		alert ("You did not enter the same new password twice. Please re-enter your password.");
		return false;
	} else if (document.UserForm.UserFirstName.value == "") {
		alert ("Please enter your first name");
		return false;
	} else if (document.UserForm.UserLastName.value == "") {
		alert ("Please enter your last name");
		return false;
	}
}

bkLib.onDomLoaded(nicEditors.allTextAreas);

$(document).ready( function() {
	$("#PageRebateFinder").selectbox();	
	$("#SectionSelector").selectbox();	
	$("#StateSelector").selectbox();
	$("#HomeEventSelector").selectbox();
	$("#title").selectbox();
	$("#state").selectbox();
	$("#other").selectbox();
	//initFileUploads();
});

$(function(){
	try {
		// find all the input elements with title attributes
		$('input[title!=""]').hint();
	} catch(ex){}
});

$(function() {
	try {
		$("#event_start_date").datepicker({dateFormat: 'yy-mm-dd'});
		$("#event_end_date").datepicker({dateFormat: 'yy-mm-dd'});
	} catch(e){}
});

function codeEditor () {
	$("textarea").html("<textarea class=\"codebox\"");
}

function RBNTracking (str) {
	pageTracker._trackEvent('Link', 'Click', str);
	//alert(str);
}

function flashROI(roistr) {
	document.getElementById('roitag').innerHTML = '<iframe src="' + roistr + '" HEIGHT=1 WIDTH=1 FRAMEBORDER=0></iframe>';
}

function heroResize(state) {    
	if (state=='shrink') {
		var anim = new YAHOO.util.Anim('flashContent', { height: { to: 575 } }, 1, YAHOO.util.Easing.easeOut);
		anim.animate();
	} else {
		var anim = new YAHOO.util.Anim('flashContent', { height: { to: 707 } }, 0.5, YAHOO.util.Easing.easeOut);
		anim.animate();
	}
	//return void(0);
}
