if (typeof pec == "undefined") pec = {}

pec.dirtyForm = false;

pec.changeCulture = function(culture) {
	if (pec.culture == culture) return;
	if (pec.dirtyForm == true) {
		if( !confirm( pec.dirtyFormWarning ) ) {
			return;
		}
	}
	url = document.location.href;
	var reStr = pec.root.replace(/\//ig, "\\/");
	var re = new RegExp(reStr, "ig");
	url = url.replace(re, "").replace(/^(en|fr)?/, "");
	document.location.href = pec.root + culture + url;
}

pec.showError = function(message,options) {
  var $errorDiv = jQuery("#errordiv");

  //-- for backward comaptibility
  if ( typeof(options) != "object" ) {
    options = { height: options };
  }

  //-- Allow an optional width to be set
  if ( !options.width ) {
    options.width = '320px';
  }
  $errorDiv.find('div').width(parseInt(options.width, 10)-15);

  $errorDiv.find("#errorcontents").html(message);
  $.blockUI({
      css: $.extend({
          width: '320px',
          allowBodyStretch: true,
          border: '17px solid #7FD0EF',
          backgroundColor: 'transparent'
      }, options),
      centerFull: true,
      message: $errorDiv
  });

}

pec.showOfferDetails = function(id) {
    $.blockUI({
        css: {
            width: '518px',
            height: '348px',
            allowBodyStretch: true,
            border: '17px solid #c2dfc2',
            backgroundColor: 'transparent'
        },
        centerFull: true,
        message: $("#offerDetails"+id)});
}

$(function() {
    $("a.tooltip").tooltip({
        bodyHandler: function() {
            return $($(this).attr("href")).html();
        },
        showURL: false
    });
})

