/*
 * cssjs
 * written by Christian Heilmann (http://icant.co.uk)
 * eases the dynamic application of CSS classes via DOM
 * parameters: action a, object o and class names c1 and c2 (c2 optional)
 * actions: swap exchanges c1 and c2 in object o
 *			add adds class c1 to object o
 *			remove removes class c1 from object o
 *			check tests if class c1 is applied to object o
 * example:	cssjs('swap',document.getElementById('foo'),'bar','baz');
 */

function cssjs(a,o,c1,c2)
{
	switch (a){
		case 'swap':
			o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;
		case 'add':
			if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
			var rep=o.className.match(' '+c1)?' '+c1:c1;
			o.className=o.className.replace(rep,'');
		break;
		case 'check':
			return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}

function setRegion(region)
{
	var others = new Array();
	var price = new Array();
	
	switch (region)
	{
		case "World":  others = new Array("Eu",    "Sweden");
					   price  = new Array("World", "Eu");
					   break;
		case "Eu":     others = new Array("Sweden", "World");
					   price  = new Array("Eu", "World");
					   break;
		case "Sweden": others = new Array("Eu", "World");
					   price  = new Array("Eu", "World");
					   break;
		default: return;
	}
	
	returnObjById('vatNoText').style.display = (region == 'Eu') ? 'inline' : 'none';
	returnObjById('locationInput').value = region;
	returnObjById('map').src = 'images/Map'+region+'.png';
	returnObjById(price[0]+'PriceTable').style.display = 'block';	
	returnObjById(price[1]+'PriceTable').style.display = 'none';
	returnObjById(others[0]+'Flag').src = "images/Region"+others[0]+"Off.jpg";	
	returnObjById(others[1]+'Flag').src = "images/Region"+others[1]+"Off.jpg";
	returnObjById(region+'Flag').src = "images/Region"+region+"On.jpg";
	cssjs('remove',returnObjById(others[0]+'Price'),'activeRegion','');
	cssjs('remove',returnObjById(others[1]+'Price'),'activeRegion','');
	cssjs('add',returnObjById(region+'Price'),'activeRegion','');
}
