// JavaScript Document for Minics

function toggle_visibility(id) { // toogles a dinamyc item bettew css display visible/hidden 
       var e = document.getElementById(id);
       if(e.style.display == 'none')
          e.style.display = 'block';
       else
          e.style.display = 'none';
    }
    
function toggle_overflow(id) { // toogles a dinamyc item bettew css display visible/hidden 
	   var e = document.getElementById(id);
       if(e.style.overflow == 'visible')
	   e.style.overflow = 'hidden';
       else
          e.style.overflow = 'visible';
    }
	
function showitem(id){ // changes the background coordinates of the Id element
	document.getElementById('reasonspreview').style.backgroundPosition="0 " + id*(-241)+"px"   ; //cambia la coordenada 'Y' del background de la imagen 'reasonspreview'
	}
	
function showprices(currency,language){
		if(currency=='dollars'){
			document.getElementById('precios-es').style.display="none";
			document.getElementById('precios-us').style.display="block";
			if(language=='es'){
				document.getElementById('coinswitcher').innerHTML="Ver precios en<br/> Euros";
			    document.getElementById('coinswitcher').href="javascript:showprices('euros','es')";	
				} else{
				document.getElementById('coinswitcher').innerHTML="Voir le prix en<br/> Euros";
			    document.getElementById('coinswitcher').href="javascript:showprices('euros','fr')";	
					}	
			
			$$("#onemonth > form input#a3")[0].value = prices["onemonth"]["dollars"];
			$$("#onemonth > form input#currency_code")[0].value 	= "USD";
			
			$$("#sixmonth > form input#a3")[0].value = prices["sixmonth"]["dollars"];
			$$("#sixmonth > form input#currency_code")[0].value 	= "USD";
			
			$$("#twelvemonth > form input#a3")[0].value = prices["twelvemonth"]["dollars"];
			$$("#twelvemonth > form input#currency_code")[0].value 	= "USD";
			
		} else { 
			document.getElementById('precios-us').style.display="none";
			document.getElementById('precios-es').style.display="block";
			if(language=='es'){
			document.getElementById('coinswitcher').innerHTML="Ver precios en <br/>D&oacute;lares americanos";
			document.getElementById('coinswitcher').href="javascript:showprices('dollars','es')";}
			else{
					document.getElementById('coinswitcher').innerHTML="Voir le prix en<br/>US Dollar";
			        document.getElementById('coinswitcher').href="javascript:showprices('dollars','fr')";
				}
			
			$$("#onemonth > form input#a3")[0].value = prices["onemonth"]["euros"];
			$$("#onemonth > form input#currency_code")[0].value 	= "EUR";
			
			$$("#sixmonth > form input#a3")[0].value = prices["sixmonth"]["euros"];
			$$("#sixmonth > form input#currency_code")[0].value 	= "EUR";
			
			$$("#twelvemonth > form input#a3")[0].value = prices["twelvemonth"]["euros"];
			$$("#twelvemonth > form input#currency_code")[0].value 	= "EUR";
		}

	}
	
//Field onfocus handling 
function clean(thefield){ //Any input textfield onfocus cleanup
		if(thefield.defaultValue==thefield.value) {
		thefield.value = "";
		}
	}

function fill(thefield){ //Any input textfield onfocus fill with its default value
    if (thefield.value == "")
	thefield.value=thefield.defaultValue
	}


function setPlayerLanguage(lang){
	 window.location ='http://play.minics.com/home/setVirtualWorldLanguage/'+lang;
}