function doEventRegisterStuff(){
	$$('[moid]').each(function(s){
		new Moover(s.getAttribute('moid'));
	});
/*	$$('[moidLink]').each(function(s){
		new Moover(s.getAttribute('moidLink'), 'link');
	});*/
	$$('[formHint]').each(function(s){
		new FormHint(s);
	});
	$$('[mouseOver]').each(function(s){
		new GlossaryMouseOver(s);
	});
	$$('[showHide]').each(function(s){
		new ShowHide(s);
	});
	$$('[onEnter]').each(function(s){
		new OnEnterAttribute(s);
	});
  $$(".keyword").each(function(s){
    new Keyword(s);
  });
  $$(".multiColumn").each(function(s){
    new MultiColumn(s);
  });
	
	Event.observe(window, 'load', function(){showAnchor()});
	Event.observe(window, 'load', function(){tabToFirstKeyword()});
}

/**
  if search parameter provided select the first tab where a keyword is inside.
  if no keyword is inside the tabs dont do anything.
*/

function tabToFirstKeyword(){
  if(getQueryParameter(document.location.href, "search")){
    // has search parameter
	  if(document.location.href.indexOf('#_') == -1){
	    // has no anchor in link
		  tabs_ = $('tabs')
		  firstTab = null;
		  tabs_.select('a').each(function(e){
		    id = e.getAttribute('href');
		    if(id.indexOf('#') != -1){
		      id = id.substring(id.indexOf('#') + 2);
		    }
		    tab = $(id);
        if(tab){
			    if(tab.select('.qKeyword').length > 0){
			      if(firstTab == null){
			        firstTab = id;
			      }
			    }
			  }
		  });
		  
		  if(firstTab){
		    // tabs is a XTabs instance, instantiated after the tab html
		    tabs.show(firstTab)
		  }
		}
  }
}



// offline search function
function offSearch(){
  var jar = new CookieJar({expires:36000, path:'/'});
  var data = {
    keyword:$('searchInput')['keyword'].value,
    publi:$('searchInput')['publi'].getValue() != null,
    farmer:$('searchInput')['farmer'].getValue() != null
  }
  try{
    jar.put('searchInput', data);
  }catch(err){
    alert(err + " -> jar.set");
  }
  
	document.location.href = 'search.html';
}

function offSearchSet(){
  try {
    var jar = new CookieJar({expires:36000, path:'/'});
    var data = jar.get('searchInput');
    $('searchInput')['keyword'].value = data.keyword;
    $('searchInput')['publi'].checked = data.publi;
    $('searchInput')['farmer'].checked = data.farmer;
  } catch (err){
    if(err instanceof TypeError){
      
    }else{
      alert(err + " -> jar.get");
    }
  }
}



/**
 * Javascript code to store data as JSON strings in cookies. 
 * It uses prototype.js 1.5.1 (http://www.prototypejs.org)
 * 
 * Author : Lalit Patel
 * Website: http://www.lalit.org/lab/jsoncookies
 * License: Apache Software License 2
 *          http://www.apache.org/licenses/LICENSE-2.0
 * Version: 0.5
 * Updated: Jan 26, 2009 
 */

var CookieJar = Class.create();

CookieJar.prototype = {

  /**
   * Append before all cookie names to differntiate them.
   */
  appendString: "__CJ_",

  /**
   * Initializes the cookie jar with the options.
   */
  initialize: function(options) {
    this.options = {
      expires: 3600,    // seconds (1 hr)
      path: '',     // cookie path
      domain: '',     // cookie domain
      secure: ''      // secure ?
    };
    Object.extend(this.options, options || {});

    if (this.options.expires != '') {
      var date = new Date();
      date = new Date(date.getTime() + (this.options.expires * 1000));
      this.options.expires = '; expires=' + date.toGMTString();
    }
    if (this.options.path != '') {
      this.options.path = '; path=' + escape(this.options.path);
    }
    if (this.options.domain != '') {
      this.options.domain = '; domain=' + escape(this.options.domain);
    }
    if (this.options.secure == 'secure') {
      this.options.secure = '; secure';
    } else {
      this.options.secure = '';
    }
  },

  /**
   * Adds a name values pair.
   */
  put: function(name, value) {
    name = this.appendString + name;
    cookie = this.options;
    var type = typeof value;
    switch(type) {
      case 'undefined':
      case 'function' :
      case 'unknown'  : return false;
      case 'boolean'  : 
      case 'string'   : 
      case 'number'   : value = String(value.toString());
    }
    var cookie_str = name + "=" + escape(Object.toJSON(value));
    try {
      document.cookie = cookie_str + cookie.expires + cookie.path + cookie.domain + cookie.secure;
    } catch (e) {
      return false;
    }
    return true;
  },

  /**
   * Removes a particular cookie (name value pair) form the Cookie Jar.
   */
  remove: function(name) {
    name = this.appendString + name;
    cookie = this.options;
    try {
      var date = new Date();
      date.setTime(date.getTime() - (3600 * 1000));
      var expires = '; expires=' + date.toGMTString();
      document.cookie = name + "=" + expires + cookie.path + cookie.domain + cookie.secure;
    } catch (e) {
      return false;
    }
    return true;
  },

  /**
   * Return a particular cookie by name;
   */
  get: function(name) {
    name = this.appendString + name;
    var cookies = document.cookie.match(name + '=(.*?)(;|$)');
    if (cookies) {
      return (unescape(cookies[1])).evalJSON();
    } else {
      return null;
    }
  },

  /**
   * Empties the Cookie Jar. Deletes all the cookies.
   */
  empty: function() {
    keys = this.getKeys();
    size = keys.size();
    for(i=0; i<size; i++) {
      this.remove(keys[i]);
    }
  },

  /**
   * Returns all cookies as a single object
   */
  getPack: function() {
    pack = {};
    keys = this.getKeys();

    size = keys.size();
    for(i=0; i<size; i++) {
      pack[keys[i]] = this.get(keys[i]);
    }
    return pack;
  },

  /**
   * Returns all keys.
   */
  getKeys: function() {
    keys = $A();
    keyRe= /[^=; ]+(?=\=)/g;
    str  = document.cookie;
    CJRe = new RegExp("^" + this.appendString);
    while((match = keyRe.exec(str)) != undefined) {
      if (CJRe.test(match[0].strip())) {
        keys.push(match[0].strip().gsub("^" + this.appendString,""));
      }
    }
    return keys;
  }
};










function getQueryParameter ( queryString, parameterName ) {
  var parameterName = parameterName + "=";
  if ( queryString.length > 0 ) {
    begin = queryString.indexOf ( parameterName );
      if ( begin != -1 ) {
        begin += parameterName.length;
        end = queryString.indexOf ( "&" , begin );
        if ( end == -1 ) {
          end = queryString.length
        }
      return unescape ( queryString.substring ( begin, end ) );
    }
  }
}

function showAnchor(){
	var a = getQueryParameter(document.location.href, "anchor");
	if(a){
	  document.location.href="#" + a;
	}
}


function getXPosition(e){
	return Position.cumulativeOffset(e)[0];
}

function getYPosition(e){
	return Position.cumulativeOffset(e)[1];
}


function flipInside(x, y, width, height, oneSide){
  var ws = Position.windowSize();
  ws.width = ws.width - 10;
  ws.height = ws.height - 10;

  var x2 = x + width;
  var y2 = y + height;
  var nx = x;
  var ny = y;
  
  if(y2 > ws.height + ws.top){
    ny = y - height - 5;
  }else{
    ny = y + 5;
  }
  
  if(x2 > ws.left + ws.width){
    nx = ws.left + ws.width - width;
  }
  
  return {x:nx, y:ny}
}


function moveInside(x, y, width, height, oneSide){
	var ws = Position.windowSize();

	var dx = width / 2;
	var dy = height / 2;
	var nx = x;
	var ny = y;
	
	if(ny < ws.top){
		ny = ws.top;
	}

	if((ny + (dy * 2)) > (ws.height + ws.top)){
		ny = ws.height + ws.top - dy * 2;
	}
	
	if(nx < ws.left){
		nx = ws.left;
	}

	if((nx + (dx * 2)) > (ws.width + ws.left)){
		nx = ws.width + ws.left - dx * 2;
	}
	
	if(oneSide){
		var delx = Math.abs(nx-x);
		var dely = Math.abs(ny-y);
		if(delx > dely){
			ny = y;
		}else{
			nx = x;
		}
	}
	
	return {x:nx, y:ny}
}

Position.windowSize = function(){
	Position.prepare();
	return {
		width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
		height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
		left: Position.deltaX,
		top: Position.deltaY
	}
};

var OnEnterAttribute = Class.create();
OnEnterAttribute.prototype = {
	initialize: function(id){
		this.element = $(id);
		this.value = this.element.getAttribute("onenter");
		Event.observe(this.element, 'keypress', this.onEnter.bindAsEventListener(this));
	},

	onEnter:function(evt){
		if(evt.keyCode == Event.KEY_RETURN){
			var func = eval('function(event){' + this.value + '}');
			var result;
			if(!func){
				if(window.execScript){
					window.execScript('theBadFunction = function(event){' + this.value + '}');
					result = window.theBadFunction(evt);
				}
			}else{
				result = func(evt);
			}
			if(!result){
				Event.stop(evt);
			}
		}
	}
}

var MultiColumn = Class.create();
MultiColumn.prototype = {
  initialize: function(element){
    this.element = $(element);
    this.children = this.element.select(".multiColumnItem");
    this.columns = Math.floor(this.element.getDimensions().width / 260);
    this.elements = Math.ceil(this.children.size() / this.columns);
    this.reorganize();
  },
  
  reorganize: function(){
    var table = new Element("table", {"width":"100%"});
    var tBody = new Element("tbody");
    var tr = new Element("tr");
    table.appendChild(tBody);
    tBody.appendChild(tr);
    this.element.appendChild(table);
    for(var cnt=0; cnt < this.columns; cnt++){
      var td = new Element("td");
      td.writeAttribute({"valign":"top"});
      tr.appendChild(td);
      for(var c = cnt * this.elements; c < (cnt+1) * this.elements && c < this.children.size(); c++){
        
        td.appendChild(this.children[c].remove());
      }
    }
  }
}


var Keyword = Class.create();
Keyword.prototype = {
  initialize: function(element){
    this.element = $(element);
    this.sh = this.element.select('div.documents')[0];
    this.name = this.element.select('div.name')[0];
    Event.observe(this.element, "click", this.showHide.bindAsEventListener(this));
  },
  
  showHide: function(){
    if(this.sh.style.display != 'block'){
      this.sh.style.display = 'block';
      this.name.addClassName('nSelected');
    }else{
      this.sh.style.display = 'none';
      this.name.removeClassName('nSelected');
    }
  }
}


var ShowHide = Class.create();
ShowHide.prototype = {
	initialize: function(element){
		this.element = $(element);
		this.sh = $(element.getAttribute('showHide'));
		this.sh.style.display = 'none';
		Event.observe(this.element, "click", this.showHide.bindAsEventListener(this));
	},
	
	showHide: function(){
		if(this.sh.style.display == 'none'){
			this.sh.style.display = 'block';
		}else{
			this.sh.style.display = 'none';
		}
	}
}

var FormHint = Class.create();
FormHint.prototype = {
	initialize: function(input){
		this.input = $(input);
		Event.observe(this.input, "focus", this.focus.bindAsEventListener(this));
		Event.observe(this.input, "blur", this.focusLost.bindAsEventListener(this));
		this.focusLost();
	},
	
	focus: function(){
		if(this.input.value == this.input.getAttribute("formhint")){
			this.input.value = "";
		}
	},
	
	focusLost: function(){
		if(this.input.value == ""){
			this.input.value = this.input.getAttribute("formhint");
		}
	}	
}

window.glossaryBasePath = '/';

var GlossaryMouseOver = Class.create();

GlossaryMouseOver.prototype = {
	initialize: function(element){
		this.element = $(element);
		this.over = false;
		Event.observe(this.element, 'mousemove', this.showMouseOver.bindAsEventListener(this));
		Event.observe(this.element, 'mouseout', this.hideMouseOver.bindAsEventListener(this));
	},
	
	showMouseOver: function(evt){
	  var index = this.element.getAttribute("mouseOver");
	  var target = Event.element(evt);
    var x = evt.pointerX();
    var y = evt.pointerY();
		
		
		var xy = flipInside(x, y , $('glossaryPopup').offsetWidth, $('glossaryPopup').offsetHeight);
		
		$('glossaryPopup').style.left = xy.x + 'px';
		$('glossaryPopup').style.top = xy.y + 'px';
		$('glossaryPopupFrame').style.display = 'block';
		$('glossaryPopupFrame').style.left = xy.x + 'px';
		$('glossaryPopupFrame').style.top = xy.y + 'px';
    if(!this.over){
      $('glossaryPopup').style.display
      $('glossaryPopupFrame').style.width = '0px';
      $('glossaryPopupFrame').style.height = '0px';
      $('glossaryPopup').style.display = 'block';
      $('glossaryPopupFrame').style.display = 'block';
      
      
      $('glossaryPopupContent').innerHTML = $('ge_' + index).innerHTML;
			this.over = true;
		}
	},
	
	hideMouseOver: function(evt){
		$('glossaryPopupFrame').style.display = 'none';
		$('glossaryPopup').style.display = 'none';
		this.over = false;
	}
}

var Moover = Class.create();
Moover.prototype = {
	initialize: function(id, type){
		this.id = id;
		this.fixed = false;
		this.hideEvent = this.hide.bindAsEventListener(this);
		// show magnifying glass if over _Ov
		Event.observe($(this.id + "_Ov"), "mouseout", this.goOut.bindAsEventListener(this));
    Event.observe($(this.id + "_Ov"), "mouseover", this.goOver.bindAsEventListener(this));
    Event.observe($(this.id + "_Ov"), "mouseup", this.click.bindAsEventListener(this));
    Event.observe($(this.id), "mouseup", this.hideEvent);
	},
	goOut: function(){
    $(this.id + "_Ov").setStyle({cursor:'auto'});
	},
	goOver: function(){
	  $(this.id + "_Ov").setStyle({cursor:'pointer'});
	},
	click: function(){
    var mo = $(this.id);
    var left = (document.viewport.getWidth() - mo.getWidth()) / 2 + document.viewport.getScrollOffsets().left;
    var top = (document.viewport.getHeight() - mo.getHeight()) / 2 + document.viewport.getScrollOffsets().top;
    mo.setStyle({
      top: top + 'px',
      left: left + 'px',
      display: 'block',
      cursor: 'pointer'
    });
    var th = $('mBody').getHeight();
    var tw = $('mBody').getWidth();
    $('overlay').setStyle({visibility:'visible', height:th + 'px', width:tw + 'px'});
    Event.observe($('overlay'), "mouseup", this.hideEvent);
	},
	hide: function(){
	  $(this.id).setStyle({display:'none'});
    $('overlay').setStyle({visibility:'hidden'});
    Event.stopObserving($('overlay'), "mouseup", this.hideEvent);
	}
}

/* country mouseovers */

function countries(){
	this.dz = 'Algeria';			
	this.ao = 'Angola';
	this.bj = 'Benin';
	this.bw = 'Botswana';
	this.bv = 'Bouvet Island';
	this.bf = 'Burkina Faso';
	this.bi = 'Burundi';
	this.cm = 'Cameroon';
	this.cv = 'Cape Verde';
	this.cf = 'Central African Republic';
	this.td = 'Chad';
	this.km = 'Comoros';
	this.cg = 'Republic of the Congo';
	this.cd = 'Democratic Republic of the Congo';
	this.dj = 'Djibouti';
	this.eg = 'Egypt';
	this.gq = 'Equatorial Guinea';
	this.er = 'Eritrea';
	this.et = 'Ethiopia';
	this.ga = 'Gabon';
	this.gm = 'Gambia';
	this.gh = 'Ghana';
	this.gn = 'Guinea';
	this.gw = 'Guinea Bissau';
	this.ci = 'Ivory Coast';
	this.ke = 'Kenya';
	this.ls = 'Lesotho';
	this.lr = 'Liberia';
	this.ly = 'Libya';
	this.mg = 'Madagascar';
	this.mv = 'Malawi';
	this.ml = 'Mali';
	this.mr = 'Mauritania';
	this.mu = 'Mauritius';
	this.yt = 'Mayotte';
	this.ma = 'Morocco';
	this.mz = 'Mozambique';
	this.na = 'Namibia';
	this.ne = 'Niger';
	this.ng = 'Nigeria';
	this.re = 'Reunion';
	this.rw = 'Rwanda';
	this.st = 'São Tomé Príncipe';
	this.sn = 'Senegal';
	this.sc = 'Seychelles';
	this.sl = 'Siera Leone';
	this.so = 'Somalia';
	this.za = 'South Africa';
	this.sd = 'Sudan';
	this.sz = 'Swaziland';
	this.tz = 'Tanzania';
	this.tg = 'Togo';
	this.tn = 'Tunisia';
	this.ug = 'Uganda';
	this.zm = 'Zambia';
	this.zw = 'Zimbabwe';
	this.eh = 'Western Sahara';
}

var co = new countries();


function selCountry(code, e){
	if(!e){
		e = window.event;
	}
	if(e.pageX){
		mx = e.pageX;
		my = e.pageY;
	}else{
		if (window.pageYOffset){
			mx = e.clientX + window.pageXOffset;
			my = e.clientY + window.pageYOffset;
		}else if (document.documentElement && document.documentElement.scrollTop){
			mx = e.clientX + document.documentElement.scrollLeft;
			my = e.clientY + document.documentElement.scrollTop;
		}else if (document.body){
			mx = e.clientX + document.body.scrollLeft;
			my = e.clientY + document.body.scrollTop;
		}
	}
	element = document.getElementById("ccode");
	if(element.childNodes){
		list = element.childNodes;
		for(cnt=0;cnt<list.length;cnt++){
			element.removeChild(list[cnt]);
		}
	}
	element.appendChild(document.createTextNode(co[code]));
	element.style.top = my + 10 + 'px';
	element.style.left = mx + 10 + 'px';
	element.style.visibility = 'visible';
}
function mvCountry(code, e){
	if(!e){
		e = window.event;
	}
	if(e.pageX){
		mx = e.pageX;
		my = e.pageY;
	}else{
		if (window.pageYOffset){
			mx = e.clientX + window.pageXOffset;
			my = e.clientY + window.pageYOffset;
		}else if (document.documentElement && document.documentElement.scrollTop){
			mx = e.clientX + document.documentElement.scrollLeft;
			my = e.clientY + document.documentElement.scrollTop;
		}else if (document.body){
			mx = e.clientX + document.body.scrollLeft;
			my = e.clientY + document.body.scrollTop;
		}
	}
	element = document.getElementById("ccode");
	element.style.top = my + 10 + 'px';
	element.style.left = mx + 10 + 'px';
}

function unselCountry(code, e){
	element = document.getElementById("ccode");
	if(element.childNodes){
		list = element.childNodes;
		element.style.visibility = 'hidden';
		for(cnt=0;cnt<list.length;cnt++){
			element.removeChild(list[cnt]);
		}
	}
}


var mapCccmap=new Array('ly','eh','cf','eg','td','et','so','rw','mu','sd','ci','gm','ml','cv','mg','tg','bj','gh','ke','cd','bw','ga','st','cg','km','ne','za','mv','sz','ao','ma','dz','bi','tz','gn','ls','gw','ng','ug','bf','zw','er','sl','mz','mr','na','lr','dj','cm','tn','gq','sn','sc','re','zm');
var mapCocmap=new Array('127,16,126,15,124,15,121,15,121,13,118,13,115,16,115,18,114,20,112,20,108,18,105,17,104,15,103,15,98,13,97,13,95,13,95,15,93,15,92,17,92,18,91,19,90,20,90,22,90,25,91,26,91,29,89,30,89,31,91,33,91,35,92,35,94,36,94,36,95,38,100,39,101,40,106,38,126,48,126,47,128,47,128,41,127,34,127,27,126,20,127,19,126,18,127,16','46,26,45,29,37,28,36,35,33,37,33,41,23,40,23,38,25,37,28,32,31,31,31,28,32,26,34,26,35,25,35,23,46,24,46,26','135,86,135,85,133,85,133,83,130,80,130,79,127,78,127,77,125,77,125,76,125,74,124,72,122,71,120,72,120,73,118,76,116,76,114,77,114,77,113,77,113,78,112,79,109,80,107,80,106,80,105,81,104,80,101,85,101,87,102,88,102,89,102,91,105,93,105,95,107,91,109,91,110,91,112,91,112,90,113,88,115,87,117,89,119,89,120,89,122,90,124,88,125,88,125,88,127,87,128,87,129,88,129,88,130,86,132,87,134,87,135,86','127,16,127,18,127,19,126,20,127,27,127,34,128,42,140,41,144,41,147,41,148,41,150,42,151,41,152,41,153,39,153,38,154,38,154,36,154,35,149,29,149,27,145,23,145,22,145,21,145,20,146,20,146,22,147,24,149,25,150,25,150,23,150,20,148,16,146,17,144,17,144,17,142,16,139,16,137,18,135,18,131,16,127,16','106,38,125,48,126,58,123,58,123,60,121,61,122,63,121,63,121,64,121,65,120,66,120,66,121,66,122,69,123,70,123,72,121,71,120,72,120,73,118,76,116,77,114,77,114,77,113,77,113,78,112,79,109,79,107,80,106,80,105,81,103,80,103,78,100,75,100,74,104,74,103,73,102,68,101,66,100,66,99,64,99,61,99,61,101,58,104,56,104,49,105,47,104,45,104,44,103,42,103,39,106,38','158,61,160,61,161,61,162,60,164,61,165,60,169,61,172,64,174,65,175,65,174,66,172,68,173,70,175,70,175,70,176,73,178,75,186,77,189,77,182,86,178,86,176,88,174,88,174,89,171,88,168,91,164,90,161,88,159,88,158,88,158,86,156,85,155,83,152,80,150,79,150,77,152,77,153,76,152,74,153,73,153,71,155,71,155,69,156,66,158,66,158,64,158,63,158,61','173,105,174,103,178,99,178,98,180,97,183,94,184,94,187,91,190,88,191,85,194,78,194,77,195,76,195,75,196,72,196,70,197,70,197,69,196,66,196,66,195,67,191,68,188,68,188,69,186,69,186,70,183,70,181,71,179,71,177,68,175,70,176,73,178,75,181,76,186,77,189,77,182,86,178,86,176,88,174,88,174,89,172,92,172,102,173,105','142,104,143,104,144,103,145,105,145,107,143,107,142,108,141,108,140,107,139,107,140,106,141,105,142,104','210,155,211,155,211,156,210,156,210,155','123,72,123,70,122,70,122,67,120,67,120,66,121,65,121,64,121,63,122,63,122,61,123,60,123,58,126,58,126,48,126,47,128,47,128,42,140,41,143,41,147,41,148,41,150,42,151,41,152,41,153,39,153,38,154,38,157,40,159,43,160,49,163,51,162,52,160,54,159,54,159,58,158,60,158,63,158,64,158,66,156,66,155,69,155,71,153,71,153,73,153,75,150,77,150,79,152,80,155,83,156,85,158,86,158,88,157,88,154,88,153,89,152,90,149,90,148,91,148,90,145,90,145,91,142,88,140,89,139,88,138,89,135,86,134,85,133,84,133,83,130,80,129,79,127,78,127,77,125,77,125,74,124,72,123,72','42,88,45,87,46,86,50,86,54,86,55,86,55,85,54,82,55,79,56,77,56,75,53,73,51,74,50,73,50,72,48,72,47,72,47,71,46,71,46,72,44,72,43,72,42,72,41,73,42,75,42,76,43,76,42,77,41,76,41,77,42,78,41,79,41,82,40,82,41,82,43,84,42,86,42,88','21,61,23,61,26,61,26,62,28,62,28,63,27,63,25,62,23,62,23,63,20,62,21,61','75,49,73,49,72,47,70,46,68,45,68,43,54,32,50,32,50,51,50,54,50,56,49,58,37,57,36,58,35,57,34,57,34,58,32,59,32,60,33,61,33,62,34,63,34,65,34,66,35,66,36,66,37,66,38,67,39,66,40,66,40,68,41,69,41,70,41,70,42,72,43,72,44,72,46,72,46,71,46,71,47,72,48,72,49,69,49,68,52,67,52,65,53,64,54,64,56,63,61,60,63,60,64,60,68,59,72,59,74,58,75,56,75,49','1,49,1,50,2,51,2,51,3,50,1,49,7,51,6,51,7,52,7,51,7,51,3,51,3,52,4,52,4,52,3,51,7,53,6,53,7,54,7,53,7,53,2,56,2,56,3,57,3,56,2,56,5,56,4,56,5,57,6,56,5,56','192,133,194,137,194,142,194,144,193,142,192,144,193,146,191,147,191,149,185,163,185,165,183,167,183,168,178,170,176,169,175,168,175,167,174,166,175,164,174,162,174,159,175,159,175,158,176,158,178,154,178,153,178,152,178,150,177,149,177,149,177,147,179,146,179,144,182,143,184,143,186,142,187,141,188,140,188,139,188,139,188,139,188,137,190,137,191,136,191,134,192,133','67,83,66,82,67,78,66,75,66,73,65,72,65,71,63,70,63,71,64,72,64,74,63,75,64,77,64,82,66,84,67,83','70,83,67,83,66,82,67,78,66,75,66,73,65,72,65,71,67,69,68,69,69,69,69,67,70,67,72,68,72,69,73,71,73,73,71,75,71,76,70,77,70,79,70,80,70,83','56,75,56,73,55,71,56,70,63,70,62,71,64,72,64,74,63,75,64,77,64,82,66,84,65,85,63,85,60,86,60,86,58,86,57,87,55,86,55,85,54,82,55,79,56,77,56,75','153,89,154,88,157,88,158,88,159,88,161,88,164,90,168,91,171,88,174,89,172,92,172,102,173,105,171,107,169,107,169,110,168,111,168,112,167,113,163,110,163,108,154,103,153,103,153,100,156,95,154,91,153,89','95,117,95,116,95,116,96,115,96,114,97,113,98,114,99,112,101,112,101,114,102,113,103,112,105,111,105,110,106,108,105,107,107,105,107,104,110,102,110,101,110,99,110,98,111,96,111,95,112,92,112,90,113,88,115,87,117,89,119,89,120,89,122,90,124,88,124,88,125,88,127,87,128,87,129,88,130,88,130,86,132,87,133,87,134,87,135,86,138,89,140,88,140,89,142,88,145,91,145,94,146,95,146,95,143,98,143,99,142,100,142,102,142,104,141,105,140,106,140,107,141,110,141,112,141,117,143,120,145,123,142,123,140,123,139,126,139,129,138,132,139,133,140,134,142,133,142,137,140,136,140,137,139,135,138,134,136,133,136,132,134,132,134,133,130,132,129,131,128,131,128,131,127,130,126,130,126,130,124,130,122,130,121,130,122,128,121,126,121,120,118,120,117,120,117,119,114,120,114,121,114,122,114,122,110,123,108,122,106,116,98,116,95,117','120,172,123,168,127,169,129,169,130,167,131,167,133,165,133,164,134,163,136,161,137,161,139,160,139,159,135,158,135,156,131,153,129,149,127,149,125,150,124,149,118,150,118,159,115,159,116,167,117,169,117,172,120,172','92,95,92,98,92,98,89,98,88,98,88,100,87,101,86,103,86,103,86,104,87,104,88,105,87,106,92,111,94,111,94,110,93,108,93,107,95,107,95,106,96,106,97,107,98,107,99,107,99,107,100,107,100,106,101,106,101,104,101,102,99,101,99,100,101,98,100,97,99,97,97,98,98,95,92,95,96,113,95,113,95,114,95,116,95,116,96,115,96,114,96,113','80,98,82,99,80,102,77,101,80,98','112,91,110,91,109,91,107,92,105,96,104,95,101,95,97,95,97,98,99,97,100,97,101,98,99,100,99,101,101,102,101,106,100,106,100,107,99,107,99,107,98,107,97,107,96,106,95,106,95,107,93,107,93,108,94,109,94,111,92,111,94,114,95,113,96,113,98,114,99,112,101,112,101,114,102,113,103,112,105,111,105,110,106,108,105,107,107,105,107,104,110,102,110,101,110,99,110,98,111,96,110,95,112,92,112,91','177,131,177,132,178,132,178,131,177,131,180,132,180,133,181,133,181,133,180,132,178,133,178,133,179,133,179,133,178,133,181,134,181,135,182,135,182,134,181,134','103,39,101,40,100,39,95,38,84,45,81,47,79,48,75,49,75,56,74,58,72,59,68,59,64,60,65,64,67,64,66,65,68,66,69,66,69,67,69,68,70,67,73,69,73,67,73,66,74,64,75,64,77,63,80,64,81,65,82,66,83,65,84,65,87,66,89,66,90,65,93,65,95,66,96,66,98,64,99,64,99,62,99,61,101,58,104,56,104,54,104,49,105,47,104,45,104,44,103,42,103,39','139,160,137,161,136,161,134,163,133,164,133,165,131,166,130,167,129,169,127,169,123,168,120,172,117,172,117,170,117,169,115,167,115,170,115,176,112,177,109,177,108,175,107,177,111,186,111,187,110,187,111,189,111,191,111,191,112,190,114,193,117,191,119,191,121,190,126,191,130,190,137,186,142,180,145,177,147,172,145,172,144,173,142,172,142,171,143,169,145,170,146,166,144,160,139,160,136,177,137,179,137,181,136,181,134,182,133,181,132,180,134,177,136,177,136,177','151,126,152,127,153,126,154,128,155,130,155,131,155,132,154,133,154,137,155,137,157,140,157,143,155,145,155,146,155,146,155,145,153,143,154,141,153,139,151,140,150,139,149,137,149,136,150,134,152,134,152,133,151,131,152,130,150,130,152,130,152,128,151,128,151,126','145,172,145,170,143,169,142,171,142,172,144,173,145,172','124,148,123,146,121,144,121,136,126,136,126,132,126,130,125,130,122,130,121,130,122,128,121,126,121,120,119,120,117,120,117,120,114,120,114,121,114,122,114,122,110,123,108,122,106,117,98,117,95,117,96,118,97,121,98,123,98,124,98,124,98,126,99,130,99,133,98,135,97,135,97,136,96,137,96,138,95,139,95,140,95,142,95,143,94,143,94,144,94,146,96,147,98,146,100,147,112,147,112,149,117,149,124,148','65,6,63,6,63,5,59,6,58,4,54,7,53,9,50,9,47,12,47,12,46,14,45,16,45,16,45,17,45,18,45,18,42,20,40,22,36,23,36,23,46,24,47,22,49,20,51,20,52,19,55,19,57,18,59,16,59,15,61,15,62,14,65,14,66,13,65,12,65,10,66,9,65,8,65,6','95,38,95,37,95,36,92,35,91,35,91,33,89,31,89,30,90,29,91,26,90,25,90,22,90,19,89,15,87,13,86,11,86,9,87,9,88,8,88,4,89,3,86,2,84,2,82,3,80,2,78,2,77,3,73,3,71,3,70,4,67,4,65,6,65,8,66,9,65,10,65,12,66,13,65,14,62,14,61,15,59,15,59,17,57,18,55,19,52,19,51,20,49,20,47,22,46,25,68,44,68,45,70,46,73,47,73,49,75,49,79,48,81,47,83,45,95,38','144,108,144,107,145,107,143,107,142,108,141,108,140,107,140,110,141,112,143,111,143,110,145,109,144,108','170,129,169,128,168,127,168,126,167,124,167,120,168,118,166,117,167,113,163,110,163,108,154,103,144,104,145,105,145,107,144,108,144,108,145,109,143,110,143,111,141,112,141,115,142,115,141,117,143,120,145,124,151,126,152,126,153,126,154,128,154,130,155,131,155,132,155,132,158,131,159,132,161,131,162,132,163,131,166,131,168,130,170,129','28,64,29,64,32,66,34,65,34,66,35,66,36,66,37,66,38,67,39,66,41,66,41,68,41,69,41,70,41,70,42,72,41,73,42,75,42,77,41,76,41,77,42,78,41,79,40,79,39,79,38,79,38,77,35,76,35,74,34,73,33,72,30,72,30,74,29,74,28,73,27,72,26,71,25,71,25,69,25,67,28,67,28,66,28,65,28,64','134,178,136,178,136,177,137,179,137,181,136,181,134,182,133,181,132,179,134,178','22,65,24,65,25,64,28,64,28,65,28,66,28,67,25,67,25,69,23,68,23,67,24,66,23,66,22,66,21,66,22,65','100,66,99,64,98,64,96,66,95,66,93,65,90,65,84,65,83,65,82,66,81,66,80,64,77,63,75,64,74,64,73,66,73,67,73,69,73,71,73,72,72,74,71,75,71,76,70,76,70,79,70,80,70,83,74,83,76,85,77,87,77,88,78,89,80,89,82,88,84,88,85,87,85,88,86,86,86,85,91,82,92,82,92,83,93,83,94,82,96,77,96,77,97,76,98,75,99,71,100,71,102,69,101,68,101,67,100,66','145,91,145,90,148,90,148,91,149,90,152,90,153,89,154,91,156,95,153,100,153,103,144,103,143,104,142,104,142,102,142,100,143,99,143,98,146,95,146,94,145,94,145,91','64,60,63,60,61,60,56,63,54,64,53,64,52,65,52,67,49,68,50,69,48,72,50,72,50,73,51,74,53,73,56,75,56,73,55,71,56,70,63,70,65,71,67,69,68,69,69,69,69,67,69,67,69,66,68,66,66,65,66,64,65,64,64,60','139,145,139,144,140,143,143,143,143,144,145,143,148,145,149,146,149,149,148,152,149,154,147,156,147,158,144,161,139,160,139,159,135,158,135,156,131,153,129,148,134,149,136,146,139,145','163,51,166,57,172,61,174,63,175,63,176,65,175,65,174,65,169,61,165,60,164,61,162,60,161,61,158,61,158,60,159,58,159,54,162,52,163,51','29,75,30,74,31,72,33,72,34,73,35,74,35,77,36,77,33,80,31,79,29,79,29,77,28,76,29,75','147,172,145,172,145,170,145,165,144,160,147,158,147,156,149,154,148,152,149,150,149,146,148,145,145,143,143,144,143,141,145,140,150,139,151,140,153,140,154,141,153,143,155,145,155,147,155,146,155,145,157,144,158,140,155,137,154,137,154,133,155,132,155,132,158,131,159,132,161,132,162,132,163,131,166,131,168,130,170,129,170,130,169,131,170,139,169,141,168,144,164,147,162,147,158,151,155,152,154,153,153,153,153,155,154,157,155,162,154,164,154,165,153,167,149,168,148,169,147,171,147,172','50,32,54,32,46,25,45,29,37,28,36,35,33,36,33,41,23,40,23,41,24,41,25,43,24,45,24,47,24,50,23,53,28,53,30,55,31,58,32,59,34,58,34,57,35,57,36,58,37,57,49,58,50,56,50,54,50,51,50,32','107,177,104,174,102,167,101,160,94,149,94,146,96,147,98,146,100,148,112,147,112,149,117,149,118,149,120,149,129,148,129,149,127,149,125,150,124,149,118,150,118,159,115,159,115,167,115,171,115,176,112,178,109,177,108,174,107,177','42,88,42,86,43,85,43,84,41,82,40,82,41,82,40,79,39,80,38,79,38,77,35,76,35,77,35,77,33,80,38,86,42,88','175,65,176,65,177,67,175,68,176,68,175,69,173,70,172,68,174,66,175,65','88,95,89,93,89,93,88,91,89,89,88,89,87,90,86,90,86,88,85,88,86,86,86,85,91,82,92,83,92,83,93,83,94,82,96,77,96,77,97,76,98,75,99,71,101,71,102,69,101,68,101,67,100,66,101,66,102,68,103,73,104,74,100,74,100,75,103,78,104,80,101,85,102,88,102,89,102,91,105,93,105,94,105,96,104,95,101,95,97,95,92,94,92,95,88,95','89,3,92,1,93,3,94,3,95,2,95,3,93,4,93,6,94,6,93,9,92,10,92,11,93,12,94,11,95,13,95,15,93,15,92,17,92,18,91,19,90,20,89,15,87,14,86,11,86,9,87,9,88,8,88,4,89,3','88,95,92,95,92,98,92,98,89,98,87,98,88,96,88,95','22,53,28,53,30,55,31,58,32,59,32,60,33,61,33,63,34,63,34,65,32,66,29,64,28,64,25,64,24,65,22,64,20,64,21,64,23,64,20,63,20,62,23,63,23,62,25,62,27,63,28,63,28,61,26,61,26,61,23,61,21,60,20,58,22,56,22,53','210,111,209,111,209,112,210,112,210,111,205,111,204,112,204,112,205,112,205,111,205,114,203,114,203,116,204,115,205,114','204,157,206,156,206,158,205,158,205,158,204,157','150,139,149,137,149,136,150,134,152,134,152,133,151,131,152,130,151,130,152,130,152,129,152,128,151,126,148,125,145,124,145,123,143,123,140,124,139,126,139,129,138,132,139,133,141,134,142,133,142,137,141,136,140,137,139,136,138,134,136,133,136,133,130,132,130,131,128,131,128,131,127,130,127,130,126,130,126,132,126,136,121,136,121,144,123,146,124,148,128,148,129,148,133,149,136,146,139,145,139,144,140,143,143,143,142,141,150,139');


function createMap_cmap(node, ccs, cos){
	var area = null;
	
	if(node.innerHTML != null){// for stupid IE
		var ih = "";
		for(var cnt=0; cnt < ccs.length; cnt++){
			var cc = ccs[cnt];
			var co = cos[cnt];
			
			ih += '<area shape="poly" coords="'+co+'" onmouseover="selCountry(\''+cc+'\', event)" onmousemove="mvCountry(\''+cc+'\', event)" onmouseout="unselCountry(\''+cc+'\', event)" />';
		}
		node.innerHTML = ih;
	}else{
		for(var cnt=0; cnt < ccs.length; cnt++){
			var cc = ccs[cnt];
			var co = cos[cnt];
			
			area = document.createElement('area');
			node.appendChild(area);
			area.setAttribute('shape', 'poly');
			area.setAttribute('coords', co);
			
			area.setAttribute('onmouseover', "selCountry('"+cc+"', event)");
			area.setAttribute('onmousemove', "mvCountry('"+cc+"', event)");
			area.setAttribute('onmouseout', "unselCountry('"+cc+"', event)");
		}
	}
}

function mov(imgId, url){
	$(imgId).src = url;
}

function chImage(thumb, image){
  var img = $('tt_img_'+image);
  img.src = thumblinks[thumb].imagelink;
  
  var copyright = $('tt_cc_'+image);
  copyright.innerHTML = thumblinks[thumb].copyright;
  var title = $('tt_tt_'+image);
  title.innerHTML = thumblinks[thumb].title;
  var desc = $('tt_dd_'+image);
  desc.innerHTML = thumblinks[thumb].description;
}

function showTooltip(id){
	popup_id = id;
	popupTimeout = setTimeout(function(){
		$(popup_id).style.visibility='visible';
		document.onmousemove = function(){
			$(popup_id).style.visibility='hidden';
			document.onmousemove = null;
		};
	}, 700);
	
}
function hideTooltip(id){
	clearTimeout(popupTimeout);
}

function validateContactForm(){
	var ret = true;
	var name = document.forms['contactform'].name;
	if (name.value == ""){
		ret = false;
		name.style.border = '2px solid red';
	}
	else{
		name.style.border = '2px solid #d3e0e8';
	}
	var comment = document.forms['contactform'].comment;
	if (comment.value == ""){
		ret = false;
		comment.style.border = '2px solid red';
	}
	else{
		comment.style.border = '2px solid #d3e0e8';
	}
	if (ret == false){
		$('errormessage').style.visibility = 'visible';
	}
	else{
		document.forms['contactform'].submit();
	}
	return ret;
}
