var language = "en";
var requestinfo = "";

function changelanguage(key) {
  language = key;
  var url = "languages.php";
  url = url + "?dummy=" + new Date().getTime();
  request.open("GET", url, true);
  request.onreadystatechange = updatePage;
  request.send(null);
}


function updatePage() {
	  
  if (request.readyState == 4) {
    if (request.status == 200) {
      //alert(request.responseText);					
      // Update the page with new language bundles
      var store = document.getElementById("shop");
      var exhibition = document.getElementById("exhibition");
      var magazine = document.getElementById("magazine");
      var community = document.getElementById("community");
      var artists = document.getElementById("artists");
      var newtext = document.getElementById("newtext");
      var about = document.getElementById("about");
      var contact = document.getElementById("contact");
	  
      var title = document.getElementById("titletext");	  
	  if(getText(title).length>3){
		 if(requestinfo == 'about')aboutUs();
		 else if(requestinfo == 'contact')contactUs();
		 else if(requestinfo == 'shop')artistShop();
		 else if(requestinfo == 'community')artistCommunity();
		 else if(requestinfo == 'magazine')artistMagazine();
	  }
			 
	  switch (language) {
		case 'fr':
			 replaceText(store, "Magasin");
			 replaceText(magazine, "Actualité");
			 replaceText(community, "Communauté d'Artiste");
			 replaceText(newtext, "tout bientôt");
			 replaceText(about, "A Propos");
			 replaceText(artists, "Nos Artistes");
			 replaceText(contact, "Contactez Nous");
			 break;
			 
		
		case 'es':
			 replaceText(store, "Visit our store");
			 replaceText(magazine, "Magazine");
			 replaceText(community, "Artist Community");
			 replaceText(newtext, "coming soon");
			 replaceText(about, "About Us");
			 replaceText(artists, "Nos Artistes");
			 replaceText(contact, "Contacts");
			 break;
		
		case 'it':
			 replaceText(store, "Visit our store");
			 replaceText(magazine, "Magazine");
			 replaceText(community, "Artist Community");
			 replaceText(newtext, "coming soon");
			 replaceText(about, "About Us");
			 replaceText(artists, "Nos Artistes");
			 replaceText(contact, "Contacts");
			 break;
		
		case 'de':
			 replaceText(store, "Visit our store");
			 replaceText(magazine, "Magazine");
			 replaceText(community, "Artist Community");
			 replaceText(newtext, "coming soon");
			 replaceText(about, "About Us");
			 replaceText(artists, "Nos Artistes");
			 replaceText(contact, "Contacts");
			 break;
		
		default:
			 replaceText(store, "Visit our store");
			 replaceText(magazine, "Magazine");
			 replaceText(community, "Artist Community");
			 replaceText(newtext, "coming soon");
			 replaceText(about, "About Us");
			 replaceText(artists, "Nos Artistes");
			 replaceText(contact, "Contacts");
			 break;
		}

    } else {
      var message = request.getResponseHeader("Status");
      if ((message.length == null) || (message.length <= 0)) {
        alert("Error! Request status is " + request.status);
      } else {
        alert(message);
      }
    }
  }
}





function contactUs(){
	requestinfo = "contact";
    var title = document.getElementById("titletext");
	var info = document.getElementById("infotext");
	
	 
	  switch (language) {
		case 'en':
			 replaceText(title, "Contact Us");
			 var txt = "The Pickin'Art team is always available for your questions.<br>";
			 txt += "Please please feel free to contact us either by Phone or eMail at:<br><br>";
			 txt += "eMail: mail@pickinart.com<br>";
			 txt += "phone: +33(0)6 3762 1652<br>";
			 info.innerHTML = txt;
			 break;
			 
		case 'fr':
			 replaceText(title, "Contactez Nous");
			 var txt = "L'équipe de Pickin'Art est toujours disponible pour vos questions.<br>";
			 txt += "SVP sentez-vous libre pour nous contacter par téléphone ou email à :<br><br>";
			 txt += "eMail: mail@pickinart.com<br>";
			 txt += "téléphone: +4122 534 9092<br>";
			 info.innerHTML = txt;
			 break;
		
		case 'es':
			 replaceText(title, "Contacto");
			 var txt = "El equipo de Pickin'Art está siempre disponible para sus preguntas.<br>";
			 txt += "Siéntase por favor libre entrarnos en contacto con por Phone o el email en:<br><br>";
			 txt += "eMail: mail@pickinart.com<br>";
			 txt += "phone: +4122 534 9092<br>";
			 info.innerHTML = txt;
			 break;
		
		case 'it':
			 replaceText(title, "Contatto");
			 var txt = "La squadra di Pickin'Art è sempre disponibile per le vostre domande.<br>";
			 txt += "Prego riten libero mett in contatto con noi il telefono o email:<br><br>";
			 txt += "eMail: mail@pickinart.com<br>";
			 txt += "telefono: +4122 534 9092<br>";
			 info.innerHTML = txt;
			 break;
		
		case 'de':
			 replaceText(title, "Kontakt");
			 var txt = "Die Pickin'Art Mannschaft ist immer für Ihre Fragen vorhanden.<br>";
			 txt += "Fühlen Sie bitte frei, mit uns entweder durch Phone oder email an in Verbindung zu treten:<br><br>";
			 txt += "eMail: mail@pickinart.com<br>";
			 txt += "phone: +4122 534 9092<br>";
			 info.innerHTML = txt;
			 break;
			 
		default:
			 replaceText(title, "Contact Us");
			 var txt = "The Pickin'Art team is always available for your questions.<br>";
			 txt += "Please please feel free to contact us either by Phone or eMail at:<br><br>";
			 txt += "eMail: mail@pickinart.com<br>";
			 txt += "phone: +4122 534 9092<br>";
			 info.innerHTML = txt;
			 break;
		}
}


function aboutUs(){
	requestinfo = "about";
    var title = document.getElementById("titletext");
	var info = document.getElementById("infotext");
	
	
	  switch (language) {
		case 'fr':
			 var txt = "Le concept Pickin'Art permettra aux artistes de se connecter à  ";
			 txt += "une communauté d’autre artiste et de gens passionner de l’art pour ";
			 txt += "discuter de ses sujets, de partager leurres idées et nous espérons profiter ";				 
			 txt += "de l'expérience d'autres artistes.<br><br>";				 
			 txt += "De plus nous sommes un moyen de vente d’art original en ligne. Si vous ne parvenez ";				 
			 txt += "pas à vendre vos œuvres a’ travers des galléries traditionnel ou si vous voulez tous ";				 
			 txt += "simplement exhiber vos créations sans tous les problèmes associâtes laissez-nous donc ";				 
			 txt += "vous aider. En utilisant Pickin’Art vous auriez immédiatement accès à une très ";				 
			 txt += "grande base de visiteurs et don de clients potentiel.<br><br>";				 
			 txt += "Notre principale raison d’être est de voir les artistes réussir dans la vie. ";				 
			 txt += "Natalie Thomas, l'un des deux fondateurs est un artiste de talent, mais est devenu ";				 
			 txt += "frustré de la façon dont il peut être difficile d'organiser des expositions ";				 
			 txt += "et faire des ventes. Voila tout simplement d’où est née l’idée pour Pickin’Art.<br><br>";				 
			 txt += "L'autre fondateur, Alex Thomas, son frère, est un informaticien ayant travaillé ";				 
			 txt += "pour de grandes sociétés comme Lucent Technologies et un certain nombre ";			 
			 txt += "de petites start-up dans le domaine des télécoms. Il gère tout les trucs sur le site.";
			 
			 replaceText(title, "Au sujet de Pickin'Art");
			 info.innerHTML = txt;
			 break;
		
		default:
			 var txt = "The Pickin'Art concept will allow artists to connect to a community of peers to discuss topics, ";
			 txt += "share ideas and hopefully benefit from the experience of other artists.<br><br>";
			 txt += "Furthermore we provide an active sales channel into the market place. If you are having ";
			 txt += "trouble selling your works, or simply don't enjoy that side of being an artist, ";
			 txt += "then let us help you. By placing your original paintings for sale at Pickin'Art ";
			 txt += "you will immediately have access to a huge customer base and a much greater ";
			 txt += "chance of seeing that red dot next to your painting.<br><br>";
			 txt += "Our principal reason for building Pickin’Art is to see artists succeed in life.  ";
			 txt += "Natalie Thomas, one of the two founders is a talented artist but has become ";
			 txt += "frustrated at how difficult it can be to organize exhibitions and make sales.  ";
			 txt += "It Is from her that the idea for Pickin’Art was born.<br><br>";
			 txt += "The other founder, Alex Thomas, her brother, is an IT professional ";
			 txt += "having worked for big companies such as Lucent Technologies and ";
			 txt += "a number of small start-ups in the telecoms area.  He’s doing ";
			 txt += "all the web site stuff";
			 
			 replaceText(title, "About Us");
			 info.innerHTML = txt;
			 break;
		}
}

function artistShop(){
	requestinfo = "shop";
    var title = document.getElementById("titletext");
	var info = document.getElementById("infotext");
	
	
	  switch (language) {
		case 'fr':
			 replaceText(title, "Magasin De Peintures Original");
			 var txt = "Here artists can create an account and post as much information about themselves ";
			 txt += "as they feel comfortable with and where they can upload pictures of themselves and ";
			 txt += "pictures of any past and present work they have done to create their own homepage ";
			 txt += "on our site.  The idea here is to help them become known as artists.<br><br>";
			 txt += "Furthermore, they can mark any of these paintings for sale.  Visitors to the ";
			 txt += "site will then have the option of buying the artwork directly from the artist or ";
			 txt += "through us.<br><br>";
			 txt += "There is no commitment to go through us, nor is there any commitment to work ";
			 txt += "exclusively through us.  We will not make you sign any contract. Artists keep their ";
			 txt += "own work and can have arrangements with other galleries and dealers.<br><br>";
			 txt += "All work marked for sale on our site will have a mark-up of around 40-50% above ";
			 txt += "the artists asking price that covers our commission (30%), taxes and shipping. ";
			 txt += "Our commission rate is already considerably lower than traditional galleries ";
			 txt += "but we aim to cut this down even further to 20% as soon as we are properly up ";
			 txt += "and running.<br><br>";
			 txt += "";
			 info.innerHTML = txt;
			 break;
		
		   
		default:
			 replaceText(title, "Original Paintings Store");
			 var txt = "Here artists can create an account and post as much information about themselves ";
			 txt += "as they feel comfortable with and where they can upload pictures of themselves and ";
			 txt += "pictures of any past and present work they have done to create their own homepage ";
			 txt += "on our site.  The idea here is to help them become known as artists.<br><br>";
			 txt += "Furthermore, they can mark any of these paintings for sale.  Visitors to the ";
			 txt += "site will then have the option of buying the artwork directly from the artist or ";
			 txt += "through us.<br><br>";
			 txt += "There is no commitment to go through us, nor is there any commitment to work ";
			 txt += "exclusively through us.  We will not make you sign any contract. Artists keep their ";
			 txt += "own work and can have arrangements with other galleries and dealers.<br><br>";
			 txt += "All work marked for sale on our site will have a mark-up of around 40-50% above ";
			 txt += "the artists asking price that covers our commission (30%), taxes and shipping. ";
			 txt += "Our commission rate is already considerably lower than traditional galleries ";
			 txt += "but we aim to cut this down even further to 20% as soon as we are properly up ";
			 txt += "and running.<br><br>";
			 txt += "";
			 info.innerHTML = txt;
			 break;
		}
}


function artistCommunity(){
	requestinfo = "community";
    var title = document.getElementById("titletext");
	var info = document.getElementById("infotext");
	
	
	  switch (language) {
		case 'fr':
			 replaceText(title, "Pickin'Arts Artist Community");
			 var txt = "We aim to build an open forum where artists can discuss their ideas on a wide variety of ";
			 txt += "subjects.  They can join in with a community of other artists with similar goals and ";
			 txt += "problems from all sorts of backgrounds and perspectives.  The idea is to create an ";
			 txt += "environment where everyone can benefit from the exchange and sharing of ideas and ";
			 txt += "experiences.<br><br>";
			 txt += "Another aspect of our site will be the option to ask questions to the community at large, ";
			 txt += "much like the questions and answers pages on Yahoo.  The difference is the answers you ";
			 txt += "receive are far more likely to be relevant and useful. ";
			 txt += "";
			 info.innerHTML = txt;
			 break;
		
		default:
			 replaceText(title, "Pickin'Arts Artist Community");
			 var txt = "We aim to build an open forum where artists can discuss their ideas on a wide variety of ";
			 txt += "subjects.  They can join in with a community of other artists with similar goals and ";
			 txt += "problems from all sorts of backgrounds and perspectives.  The idea is to create an ";
			 txt += "environment where everyone can benefit from the exchange and sharing of ideas and ";
			 txt += "experiences.<br><br>";
			 txt += "Another aspect of our site will be the option to ask questions to the community at large, ";
			 txt += "much like the questions and answers pages on Yahoo.  The difference is the answers you ";
			 txt += "receive are far more likely to be relevant and useful. ";
			 txt += "";
			 info.innerHTML = txt;
			 break;
		}
		
		
		   

  

}


function artistMagazine(){
	requestinfo = "magazine";
    var title = document.getElementById("titletext");
	var info = document.getElementById("infotext");
	
	
	  switch (language) {
		case 'fr':
			 replaceText(title, "Pickin’Art Magazine");
			 var txt = "Pickin’Art also aims to be an important source of information and news with regular articles and ";
			 txt += "highly comprehensive and searchable lists of upcoming events that may be of interest to ";
			 txt += "artists, buyers or anyone with an interest in art.<br><br>";
			 txt += "The magazine is open to our community members to contribute articles and events to.  For example ";
			 txt += "it is a good place to list your upcoming exhibitions and write articles on your local ";
			 txt += "galleries and how you feel about them.<br><br>";
			 txt += "This is also a new way for artists to promote themselves and become recognised artists.  With the ";
			 txt += "way Yahoo and Google news works and the phenomenon of blogging it is very likely that ";
			 txt += "interesting articles will be posted all over the internet.  Especially with a little bit of help from us. ";
			 txt += "";
			 info.innerHTML = txt;
			 break;
		
		default:
			 replaceText(title, "Pickin’Art Magazine");
			 var txt = "Pickin’Art also aims to be an important source of information and news with regular articles and ";
			 txt += "highly comprehensive and searchable lists of upcoming events that may be of interest to ";
			 txt += "artists, buyers or anyone with an interest in art.<br><br>";
			 txt += "The magazine is open to our community members to contribute articles and events to.  For example ";
			 txt += "it is a good place to list your upcoming exhibitions and write articles on your local ";
			 txt += "galleries and how you feel about them.<br><br>";
			 txt += "This is also a new way for artists to promote themselves and become recognised artists.  With the ";
			 txt += "way Yahoo and Google news works and the phenomenon of blogging it is very likely that ";
			 txt += "interesting articles will be posted all over the internet.  Especially with a little bit of help from us. ";
			 txt += "";
			 info.innerHTML = txt;
			 break;
		}
}


function hyperlink(page){
	window.location="http://pickinart.com/"+page+"?language="+language;
}

