//var strBase = "/sco"; // dev
var strBase = ""; // production

function EnterKeyPostBack(ctrl, e) {
  var ev = e || window.event;
  if (ev.keyCode == 13) {
	  __doPostBack(ctrl, "");
	}
}

function captureEnter(obj_field, func, e) {
  var ev = e || window.event;
  if (ev.keyCode == 13) { overwritePostBack(func); eval(func); }
}

function captureSOEnter(obj_field, func, e) {
  var ev = e || window.event;
	var target = ev.target || ev.srcElement;
  if (target.id == obj_field.id) {
    if (ev.keyCode == 13) { overwritePostBack(func); eval(func); }
	}
}

function callSeekOver(obj_searchBox) {
	if (obj_searchBox == null)
    obj_searchBox = document.getElementById("sco_masterPage__ctl0__ctl0_tbox_seekOverSearch");		
		
	var str_search = obj_searchBox.value;
	window.location = "http://www.seekover.com/search.go?page=1&source=sportcompactonly.com&homepage=0&keywords=" + escape(str_search);
}

function callSearch(str_url, str_quickSearch) {
	var obj_quickSearch;
	if (str_quickSearch != "")
    obj_quickSearch = document.getElementById(str_quickSearch);		
		
	str_url += (str_url.indexOf("?") > 0) ? "&" : "?";
	str_url += "k=" + escape(obj_quickSearch.value);

	if (str_url.substr(0, 2) == "~/") str_url = str_url.substring(2);
	
	window.location = str_url;
}

function overwritePostBack(obj_postback) {
	document.forms[0].action = "javascript:"+obj_postback;
}

function callSubscribe(str_object) {
	var str_emailAddress = document.getElementById(str_object).value;
	window.location = strBase + "/newsletter-subscribe.htm?e=" + str_emailAddress;
}

function callForgotPassword() {
	openCustomWin(strBase + "/popup-forgot-password.htm", 620, 170);
}

function callAddressEdit(int_addressId) {
	openWin(strBase + "/popup-edit-address.htm?add=" +int_addressId, 620, 575);
	//openCustomWin("popup-edit-address.aspx?a=" +int_addressId, 620, 575, "SCROLLBARS=YES,RESIZABLE=YES");
}
function callAddressEditPath(int_addressId, filePath) {
	openWin(filePath + strBase + "/popup-edit-address.htm?add=" +int_addressId, 620, 575);
	//openCustomWin("popup-edit-address.aspx?a=" +int_addressId, 620, 575, "SCROLLBARS=YES,RESIZABLE=YES");
}
function callLargeImage(str_image) {
	openCustomWin(strBase + "/popup-image.htm?i=" + str_image, 600, 360, "SCROLLBARS=YES,RESIZABLE=NO");
	//openWin("popup-image.aspx?i=" + str_image, 600, 360);
}

function callReadMore(int_productId) {
	openCustomWin(strBase + "/popup-read-more.aspx?pl=" +int_productId, 620, 300, "SCROLLBARS=YES,RESIZABLE=YES");
}

function callFinancing() {
	openCustomWin(strBase + "/popup-financing.htm", 600, 500, "SCROLLBARS=NO,RESIZABLE=NO");
}

function callAccountWhy() {
	openCustomWin(strBase + "/popup-account-why.htm", 600, 150, "SCROLLBARS=NO,RESIZABLE=NO");
}

function openWin(str_file, int_width, int_height, str_name) {
	if (str_name == "") { str_name = "blank"; }
	
  var int_maxWidth =	screen.availWidth;
  var int_maxHeight =	screen.availHeight;
	
	var int_top = (int_maxHeight - int_height) / 2;
	var int_left = (int_maxWidth - int_width) / 2;
	
	var str_settings = "TOP=" +int_top+ ",LEFT=" +int_left+ ",WIDTH=" +int_width+ ",HEIGHT=" +int_height;
	var oWin = window.open(str_file, str_name, str_settings);
	oWin.focus();
}

function openCustomWin(str_file, int_width, int_height, str_options, str_name) {
	if (str_name == "") { str_name = "blank"; }
	
  var int_maxWidth =	screen.availWidth;
  var int_maxHeight =	screen.availHeight;
	
	var int_top = (int_maxHeight - int_height) / 2;
	var int_left = (int_maxWidth - int_width) / 2;
	
	var str_settings = "TOP=" +int_top+ ",LEFT=" +int_left+ ",WIDTH=" +int_width+ ",HEIGHT=" +int_height+ "," +str_options;
	var oWin = window.open(str_file, str_name, str_settings);
	oWin.focus();
}

// Scan alert exit survey code.
var saExitPopUp = true;
function saExit() {
	if (saExitPopUp) {
		var saSurveyUrl = 'http://scanalert.com/Survey?surveyId=6930';
		var saSurveyOpt = 'LEFT=5,RIGHT=5,WIDTH=400,HEIGHT=200,LOCATION=0,TOOLBAR=0';
		window.open(saSurveyUrl,'ExitSurvey',saSurveyOpt);
	}
}

function saNoPopUp() { saExitPopUp = false; }

