//top

function CurrencyPopup(QueryString)
{
	var currencyWindow = window.open ('', 'currencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600');
	currencyWindow.focus();
	currencyWindow.location.href = 'http://www.xe.net/ecc/input.cgi?Template=sw&' + QueryString;
}

function LoadShopDropsA()
{
	var sf = document.top_search_form.s.value;
	var opt_idx = 1;
   
	switch (sf) {
		case '1':  opt_idx = 0;  break; /* USD */
//		case '2':  opt_idx = 1;  break; /* GBP */
		case '4':  opt_idx = 1;  break; /* EUR */
		case '8':  opt_idx = 2;  break; /* GBP */
	}   
   
	document.top_search_form.csa.selectedIndex = opt_idx;
	document.bottom_dummy_form.csd.selectedIndex = opt_idx;
	
	if (document.side_dummy_form) {
		if (document.side_dummy_form.csb) {
			document.side_dummy_form.csb.selectedIndex = opt_idx;
		}
		if (document.side_dummy_form.csc) {
			document.side_dummy_form.csc.selectedIndex = opt_idx;
		}
	}

	if (document.cat_buy_form) {
		if (document.cat_buy_form.currency_changer) {
			document.cat_buy_form.currency_changer.selectedIndex = opt_idx;
		}
	}
}

function LoadShopDropsB()
{
	var sf = document.top_search_form.s.value;
	var opt_idx = 1;

	switch (sf) {
		case '1':  opt_idx = 0;  break; /* USD */
		case '4':  opt_idx = 1;  break; /* EUR */
		case '8':  opt_idx = 2;  break; /* GBP */
	}   

	document.cat_search_form.csa.selectedIndex = opt_idx;
	document.bottom_dummy_form.csd.selectedIndex = opt_idx;
}


function SwitchToShop(droper)
{
	var page;
	var page_basename;
	var new_shop_flag;
	new_shop_flag = droper.options[droper.selectedIndex].value;

	if (new_shop_flag != document.top_search_form.s.value)
	{
		page = String(window.location.href);
		page_basename = page.slice(page.lastIndexOf('/'), page.indexOf('?')).toLowerCase();

		if (page_basename == '/gateway.php') {
			document.cookie = "force_s=" + new_shop_flag;
			location.reload(true);

		} else if (page_basename == '/help.php') {
			location = window.location.pathname + '?s=' + new_shop_flag;

		} else if (page.indexOf('/cat-') > -1) {
			page = page.substring(page.lastIndexOf('/'));
			switch (new_shop_flag) {
				case '1': self.location = '../cat-usa-usd' + page;  break;
//				case '2': self.location = '../cat-uk-gbp'  + page;  break;
				case '4': self.location = '../cat-eu-eur'  + page;  break;
				case '8': self.location = '../cat-gb-gbp'  + page;  break;
			}
		} else {
			switch (new_shop_flag) {
				case '1': self.location = 'http://www.rockngothshop.com/v5/cat-usa-usd/index.html';  break;
				case '4': self.location = 'http://www.rockngothshop.com/v5/cat-eu-eur/index.html';  break;
				case '8': self.location = 'http://www.rockngothshop.com/v5/cat-gb-gbp/index.html';  break;
			}
		}
	}
}


function FixAllProductImageSizes() {
	var imgs = new Array();
	var x, h, w;

	if (document.getElementsByTagName) {
		imgs = document.getElementsByTagName('IMG');
	}

	for (x=0; x < imgs.length; x++) {
		if (String(imgs[x].src).indexOf('rockngothshop.com/product-img/tn_w/') != -1) {
			h = imgs[x].height;
			w = imgs[x].width;
//			if (w > h) {
				if (w > 182) {
					imgs[x].width = 182;
					imgs[x].height = (h / w) * 182
				}
//			} else {
//				if (h > 182) {
//					imgs[x].height = 182;
//					imgs[x].width = (w / h) * 182
//				}
//			}
		}

		if (String(imgs[x].src).indexOf('rockngothshop.com/product-img/qw/') > -1) {
			h = imgs[x].height;
			w = imgs[x].width;
			if (w > 350) {
				imgs[x].width = 350;
				imgs[x].height = (h / w) * 350
			}
		}
	}
}

