

// JavaScript Document


function loadCountryChooser(){
	var myObject = document.getElementById('brandMessage');
	myObject.style.MozOpacity=1;	
	myObject.style.filter="alpha(opacity="+100+")";	
			/*JSTweener.addTween(myObject.style, {
				time: 5,
      			transition: 'easeInOutSine',
				filter:0,
				prefix:{filter:"JJ"},
				suffix:{filter:")"}

//	  			onComplete:loadCountryChooser2
				// filter:"alpha(opacity=" + 0 + ")"
			});*/
			
		new Effect.Fade('brandMessage', {duration:.3});
		new Effect.Appear('countrySelector', { queue: 'end',duration:.3 });

	

}

function loadCountryChooser2(){
	var myObject = document.getElementById('countrySelector');
	var oldObject = document.getElementById('brandMessage');
	oldObject.style.display='none';
	myObject.style.display='block';
	myObject.style.MozOpacity=0;


}


function openModal(cname){
	var myObject = document.getElementById(cname);
	myObject.style.display='block';
	var myWidth=myObject.clientWidth/2;
	myObject.style.left=(document.body.clientWidth/2-myWidth)+"px";
	myObject.style.top=((document.body.clientHeight/2)-100)+"px";
	nukeModal(myObject);
	myObject.style.display='none';
	new Effect.Appear(myObject,{duration:.4 });
	new Effect.Move(myObject, {x:document.body.clientWidth/2-myWidth,  y: (document.body.clientHeight/2)-200, transition: Effect.Transitions.easeOutQuad, mode: 'absolute',duration:.6  });
	
}

function closeModal(cname){
	var myObject = document.getElementById(cname);
	fadeOut(myObject);
	}
	
function fadeOut(obj){
	
			new Effect.Fade(obj,{duration:.3});
			//new Effect.Move(obj, {x:document.body.clientWidth/2-250,  y: document.body.clientHeight-510, mode: 'absolute',duration:.3 });

}

function nukeModal(myObject){
		var myList = getElementsByClass("countryCategoryBox","div");
	for(x=0;x<myList.length;x++){
		if (myList[x]!=myObject){
			fadeOut(myList[x]);
		}
	}

}

function getElementsByClass(searchClass,tag, node) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

//alert(navigator.appName); 