





var common = common || {}; // setup the "namespace" and append to it if it already exists

/*
 * When passed an associative array, this method will return an array containing the keys.
 */
common.keys = function(obj) {
	var keys = new Array();
	for (var key in obj) {
		keys.push(key);
	}
	return keys;
};


common.ajaxProducts = function(productIds, allowSpecial, apOnlyPricing, apSpecialPricing,  fnc) {
	var query = "";
	for (var i in productIds) {
		if (query != "") {
			query += '&';
		}
		query = query + 'productId=' + productIds[i];
	}
	if (query != '') {
		query += '&allowspecial=' + (allowSpecial ? true : false);
		query += '&aponlypricing=' + (apOnlyPricing ? true : false);
		query += '&apspecialpricing=' + (apSpecialPricing ? true : false);
		$.getJSON('/api/products.json?' + query, fnc);
	} else {
		fnc(new Array());
	}
};


common.cvvPopUp = function() {
	var popup;
	var width = 700;
	var height = 250;
	var left = (screen.width / 2) - (width / 2);
	var top = (screen.height / 2) - (height / 2);
	popup = window.open('','Help','width=' + width + 'px,height=' + height + 'px,top=' + top + 'px,left=' + left + 'px,scollbars=no,resizable=no,menubar=no,titlebar=no,location=no,toolbar=no,status=no');
	var html = '<html><head><link  rel="stylesheet"  type="text/css"  href="/themes/sisel2009/common/sisel2009.css" />';
	html += '</head><body><p>';
	html += '<div style=\"padding-bottom: 8px;\" class=\"generic-header1 dashed-border-bottom\">Security Code</div><br/>';
	html += '<b>Security Code</b> is an anti-fraud security feature to help verify that you are in possession of your credit card. For Visa/Mastercard, the three-digit Security Code is printed on the signature panel on the back of the card immediately after the account number';
	html += '</p><p>';
	html += '<div style=\"padding-bottom: 8px;\" class=\"generic-header1 dashed-border-bottom\">Where to find your CVV number?</div><br/>';
	html += 'A 3-digit number in reverse italics on the <b>back</b> of your credit card';
	html += '</p><br/><br/>';
	html += '</body></html>';
	popup.window.document.write(html);
};


$(document).ready(function() {
	
	if (top.location == self.location) { // Not in a frame
		$(".show-in-iframe").hide();
		$(".hide-in-iframe").show();
	} else { // Inside an frame
		$(".show-in-iframe").show();
		$(".hide-in-iframe").hide();
	}
});



function popup_in_context_editing(url) {
	var width  = 650;
	var height = 600;
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	var params = 'width='+width+', height='+height;
	params += ', top='+top+', left='+left;
	params += ', toolbar=0';
	params += ', scrollbars=1';
	params += ', location=0';
	params += ', statusbar=0';
	params += ', menubar=0';
	params += ', resizable=1';
	newwindow=window.open(url, 'edit_i18n_message', params);
		if (window.focus) {newwindow.focus()}
		return false;
}

$.formatCurrency.defaultLocale = "en_US";
$.formatCurrency.defaultCurrencyCode = "USD";
$.formatDecimal.defaultLocale = "en_US";
