// -- Overridable params
var jbb_cong_days = "1";
var jbb_cong_country = "";
var jbb_cong_exam = "";
var jbb_cong_width = 200;  // Default width in pixels
var jbb_cong_whiteBackground = true; // by dafault, white. If false, transparent (attention to the belt images that have a white background).
var jbb_cong_showBorder = false;
var jbb_cong_extraTextCssColor = "555";
var jbb_cong_lang = "en";

// -- DO NOT OVERRIDE
var jbb_base_url = "http://www.javablackbelt.com";    //"http://localhost:8080/JavaBlackBelt"     
//var jbb_base_url = "http://localhost:8080/JavaBlackBelt"  

/*
 * API method : use this.
 */
function jbb_congrat(){
    /* We need to put an iFrame because our JavaScript is going to send an ajax request to our server (a different server than the embedding page and firefox/ie would not allow it without an iFrame) */
	document.write('<script language="JavaScript1.1" src="'+jbb_buildJsUrl()+'"><\/script>');
	document.write("</iframe>");
}

/*
 * private : not to use directly (may change)
 */
function jbb_addParamsToGongratUrl(congratUrl){
	congratUrl+='?days='+jbb_cong_days;
	if(jbb_cong_country != ""){
		congratUrl+='&countryCode='+jbb_cong_country;
	}
	if(jbb_cong_exam != ""){
		congratUrl+='&questPublicId='+jbb_cong_exam;
	}
	if(jbb_cong_extraTextCssColor != ""){
		congratUrl+='&titleCssColour='+jbb_cong_extraTextCssColor;
	}
	if(jbb_cong_showBorder){
		congratUrl+='&showBorder=true';
	}
	if(jbb_cong_lang != ""){
		congratUrl+='&request_locale=' + jbb_cong_lang;  /* Caught by the I18nInteceptor of Struts2 (overriding Action.getLocale does not affect <s:text...> tag  --- John 2008-11  */
	}
	congratUrl+='&boxWidth=' + jbb_cong_width;
	congratUrl+='&whiteBackground=' + jbb_cong_whiteBackground;
	
	return congratUrl;
}

/*
 * private : not to use directly (may change)
 */
function jbb_buildJsUrl(){
	var url = jbb_base_url + '/RemoteCongratulation!js.wwa';
	return jbb_addParamsToGongratUrl(url);
}

/*
 * private : not to use directly (may change)
 */
function jbb_buildFrameUrl(){
	var url = jbb_base_url + '/RemoteCongratulation.wwa';
	url = jbb_addParamsToGongratUrl(url);
	return url;
}


/*
 * @deprecated : Use jbb_congrat instead
 */
function congrat(){
	jbb_cong_showBorder = true;
	jbb_congrat();
}
