var relative_path = '/';

function checkform(){
  var err = false;
  var req = document.getElementsByClassName('required');
  req.each(function(o) {
    if(o.match('input') || o.match('textarea')) {
      if(o.getValue().strip().empty()) {
        o.setStyle({backgroundColor:'#FFA500'});
        Event.observe(o, 'focus', function(){
          o.setStyle({backgroundColor:''});
        });
        err = true;
      }
    }
  });
  if(err) {
    alert('Vul alle velden in waarvoor een * staat.');
    return false;
  }
  return true;
}

function new_captcha() {
	thesrc = document.getElementById("captcha").src;
	thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
	document.getElementById("captcha").src = thesrc+"?"+Math.round(Math.random()*100000);
}

function tag_posts(tid,page) {
  $('tag_posts').addClassName('being_ajaxed');
  new Ajax.Updater('tag_posts', relative_path+'ajax/ajaxcalls.php?action=tag_posts', {parameters: {'tid':tid, 'page':page}, onComplete:function(){
    $('tag_posts').removeClassName('being_ajaxed');
  }});
}

function tag_pictures(tid,page) {
  $('tag_pictures').addClassName('being_ajaxed');
  new Ajax.Updater('tag_pictures', relative_path+'ajax/ajaxcalls.php?action=tag_pictures', {parameters: {'tid':tid, 'page':page}, onComplete:function(){
    $('tag_pictures').removeClassName('being_ajaxed');
  }});
}

function tag_videos(tid,page) {
  $('tag_videos').addClassName('being_ajaxed');
  new Ajax.Updater('tag_videos', relative_path+'ajax/ajaxcalls.php?action=tag_videos', {parameters: {'tid':tid, 'page':page}, onComplete:function(){
    $('tag_videos').removeClassName('being_ajaxed');
  }});
}

function location_posts(type,id,page) {
  $('location_posts').addClassName('being_ajaxed');
  new Ajax.Updater('location_posts', relative_path+'ajax/ajaxcalls.php?action=location_posts', {parameters: {'type':type,'id':id, 'page':page}, onComplete:function(){
    $('location_posts').removeClassName('being_ajaxed');
  }});
}

function location_pictures(type,id,page) {
  $('location_pictures').addClassName('being_ajaxed');
  new Ajax.Updater('location_pictures', relative_path+'ajax/ajaxcalls.php?action=location_pictures', {parameters: {'type':type,'id':id, 'page':page}, onComplete:function(){
    $('location_pictures').removeClassName('being_ajaxed');
  }});
}

function location_videos(type,id,page) {
  $('location_videos').addClassName('being_ajaxed');
  new Ajax.Updater('location_videos', relative_path+'ajax/ajaxcalls.php?action=location_videos', {parameters: {'type':type,'id':id, 'page':page}, onComplete:function(){
    $('location_videos').removeClassName('being_ajaxed');
  }});
}

function index_explore(type) {
    $$('#index_explore ul li.last')[0].update('<img src="'+ relative_path +'img/ajax-loader.gif" width="13" height="13" alt="" />&nbsp;');
	new Ajax.Updater('index_explore', relative_path+'ajax/ajaxcalls.php?action=index_explore', {parameters: {'type':type}, method: 'get'});
}
