/* -------- effect functions --------*/
var clear_url = function(lang){
  var url = $('url_'+lang);
  if (url._cleared) return;
  url._cleared = true;
  url.value= "http://";
  
  // for ie
  if(url.createTextRange){
    var range = url.createTextRange();
    range.move('character',url.value.length);
    range.select();
  }
};

var clear_city = function(lang){
  var city = $('city_'+lang);
  if (city._cleared) return;
  city.clear();
  city._cleared = true;
};

/* -------- forms --------*/
// JA
//// url
$('url_ja').onblur = function(){
  Validator.check_ja(this,'url');
};
$('url_ja').onfocus = function(){
  clear_url('ja');
};

//// city
$('city_ja').onblur = function(){
  Validator.check_ja(this);
};
$('city_ja').onfocus = function(){
  clear_city('ja');
}

//// button
$('button_ja').onclick = function(){
  clear_url('ja');
  clear_city('ja');
  this.focus();
  if(Validator.check_ja($('url_ja'),'url') & Validator.check_ja($('city_ja'))){
    create_widget('ja');
  }
};

//// code
$('widget_code_ja').onfocus = function(){
  this.activate();
};

// EN
//// url
$('url_en').onblur = function() {
  Validator.check_en(this,'url');
};
$('url_en').onfocus = function(){
  clear_url('en');
}

//// city
$('city_en').onblur = function(){
  Validator.check_en(this);
};
$('city_en').onfocus = function(){
  clear_city('en');
};

//// button
$('button_en').onclick = function(){
  clear_url('en');
  clear_city('en');
  this.focus();
  if(Validator.check_en($('url_en'),'url') & Validator.check_en($('city_en'))){
    create_widget('en');
  }
};

//// code
$('widget_code_en').onfocus = function(){
  this.activate();
};

/* -------- toggle --------*/
// 
$('country_toggle').onclick = function(){
  Effect.toggle('country_list','slide')
};
$('blog_toggle').onclick = function(){
  Effect.toggle('blog_list','slide')
};