﻿/*var timerjs=setTimeout("setcookie(\"jobkonjavascripterror\",0,1);",5000);*/

//onerror=handleErr;
function handleErr(msg,url,l)
{
	/*
	if(url.indexOf("script-pt.js")>-1 || url.indexOf("index.php")){
		clearTimeout(timerjs);
		var jserror=readcookie("jobkonjavascripterror");
		jserror++;
		setcookie("jobkonjavascripterror",jserror,1);
		if(jserror<5){
			location.href="";
		}else if(jserror=5){
			if(readcookie("jobkonjavascripterrordone")==""){
				alert("Devido a problemas de conexão que você tem, alguns componentes não puderam ser carregados corectly e que é possível para você ecounter dificuldades enquanto navegam pelo site.");
				setcookie("jobkonjavascripterrordone",1,1);
			}
		}
		return true;
	}*/
}

function cachepage(){
	/*preloadshow();
	//var lo_documentImages = document.images;
	//var ll_loop           = eval( 0 );
	//var lo_currentImage   = new Image();
	var lo_newImage       = new Image();
	//document.getElementById('preloading').innerHTML="Loading images...";
	
	//for( ll_loop = 0; ll_loop < lo_documentImages.length; ll_loop ++ )
	//	{
	//	lo_currentImage = lo_documentImages[ ll_loop ];
	//	lo_newImage     = new Image();
	//	lo_newImage.src = lo_currentImage.src;
	//	}
	
	//document.getElementById('preloading').innerHTML="Loading menu items...";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/Contact_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/Advanced_search_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/Home_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/Logins_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/Registers_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/Why_us_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/logout_neapasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/logout_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/cascade-Cand-neapasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/cascade-Cand-apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/cascade-Employers-neapasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/cascade-Employers-apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/cv_apasat.gif";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-en.jobkon.com/jobs_apasat.gif";
	
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/Contact_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/Advanced_search_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/Home_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/Logins_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/Registers_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/Why_us_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/logout_neapasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/logout_apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/cascade-Cand-neapasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/cascade-Cand-apasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/cascade-Employers-neapasat.jpg";
	lo_newImage     = new Image();
	lo_newImage.src= "http://jobkon-pt.jobkon.com/cascade-Employers-apasat.jpg";*/
	//preloadhide();
}

function preloadhide(){
	//document.getElementById('preloading').innerHTML="";
	$("#preloading").hide();
}

function preloadshow(){
	//document.getElementById('preloading').innerHTML="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='60' height='60'><param name='movie' value='loading.swf'><param name='quality' value='high' /><param name='wmode' value='transparent'><embed src='loading.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='60' height='60'></embed></object>";
	$("#preloading").show();
}
$(document).ready(function(e) {
    preloadhide();
});

var browser=navigator.appName;
var version=navigator.appVersion;
if(version.length>50){version="6.0";}

var hhistory="";
var xmlHttp = creazaXmlHttp();

function creazaXmlHttp() 
   { 
   var xmlHttp; 
   // pentru IE 
   if(window.ActiveXObject) 
      { 
      try 
         { 
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
         } 
      catch (e) 
         { 
         xmlHttp = false; 
         } 
      } 
   //Pt Mozilla sau alte browsere
   else 
      { 
      try 
         { 
         xmlHttp = new XMLHttpRequest(); 
         } 
      catch (e) 
         { 
         xmlHttp = false; 
         } 
      }

   if (!xmlHttp)
      alert("XMLHttpRequest could not be created."); 
   else 
      return xmlHttp; 
   } 

/*
Acesta functie preia numerele introduse in input-uri si le trimite php-ului pentru calculare
*/

function getajax(adresa)
   {
   //document.getElementById("space").style.visibility = "visible";
   preloadshow();
   favicon.change("http://jobkon-img.jobkon.com/load.gif");
   //document.getElementById('preloading').innerHTML="Loading images...";
   //if(hhistory<>""){hhistory+=",";}
   hhistory+=","+adr;//alert (hhistory);
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php 
      xmlHttp.onreadystatechange = gestioneazaRezultat;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      } 
   }

   
function gestioneazaRezultat() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul 
         document.getElementById("content").innerHTML = raspuns ;
		 favicon.change("http://jobkon-img.jobkon.com/icon.png");
		 preloadhide();
		 //tt_Hide();
      } 
   }
}
function jqajax(url,postdata,returndiv,ifasync){
	if(typeof(ifasync)=="undefined"){ifasync=false;}
	preloadshow();
   favicon.change("http://jobkon-img.jobkon.com/load.gif");
	var htmlu ='';
		if(postdata!=null && postdata!=""){
			htmlu = $.ajax({
			  url: url,
			  cache: true,
			  async: ifasync,
			  dataType: "html",
			  type: "POST",
			  data: postdata,
			  contentType: "application/x-www-form-urlencoded;charset=ISO-8859-2",
			  error:function(xhr, status, errorThrown) {
					//alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
				}, 
			  complete: function(html){
				  //$('#loadingicondiv').css('zIndex', 9999);
			  },
			  success:function(html){
				  if(ifasync==true){
					  $("#"+returndiv).animate({opacity:0},function(){$(this).html(html).animate({opacity:1},function(){preloadhide();favicon.change("http://jobkon-img.jobkon.com/icon.gif");});});
				  }
			  }
			}).responseText;
		}else{
			htmlu = $.ajax({
			  url: url,
			  cache: true,
			  async: ifasync,
			  dataType: "html",
			  type: "GET",
			  contentType: "application/x-www-form-urlencoded;charset=ISO-8859-2",
			  error:function(xhr, status, errorThrown) {
					//alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
				}, 
			  complete: function(html){
				  //$('#loadingicondiv').css('zIndex', 9999);
			  },
			  success:function(html){
				  if(ifasync==true){
					  $("#"+returndiv).animate({opacity:0},function(){$(this).html(html).animate({opacity:1},function(){preloadhide();favicon.change("http://jobkon-img.jobkon.com/icon.gif");});});
				  }
			  }
			}).responseText;
		}
		if(ifasync==false){preloadhide();favicon.change("http://jobkon-img.jobkon.com/icon.gif");}
		if(typeof(htmlu)=="undefined"){htmlu="";}
		if(typeof(returndiv)=="undefined" || returndiv==""){
			return htmlu;
		}else{
			if(!ifasync){
				$("#"+returndiv).animate({opacity:0},function(){$(this).html(htmlu).animate({opacity:1},function(){preloadhide();favicon.change("http://jobkon-img.jobkon.com/icon.gif");});});
			}
			return "";
		}
}

function getformular(adresa)
   {
   preloadshow();
   favicon.change("http://jobkon-img.jobkon.com/load.gif");
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php 
      xmlHttp.onreadystatechange = gestioneazagetformular;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      } 
   }

   
function gestioneazagetformular() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul 
         document.getElementById("formular").innerHTML = raspuns ;
         document.getElementById("space").style.visibility = "hidden";
		 document.getElementById("space").text = "";
		 favicon.change("http://jobkon-img.jobkon.com/icon.png");
		 preloadhide();
		 //tt_Hide();
      } 
   }
}

function checkuser(adresa)
	{
   document.getElementById("space").style.visibility = "visible";
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php 
      xmlHttp.onreadystatechange = gestioneazacheckuser;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      }
}

function gestioneazacheckuser() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul 
         document.getElementById("checkuser").innerHTML = raspuns ;
         document.getElementById("space").style.visibility = "hidden";
		 document.getElementById("space").text = "";
		 //tt_Hide();
      } 
   }
}

function checkmail(adresa)
	{
   document.getElementById("space").style.visibility = "visible";
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php 
      xmlHttp.onreadystatechange = gestioneazacheckmail;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      }
}

function gestioneazacheckmail() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul 
         document.getElementById("checkmail").innerHTML = raspuns ;
         document.getElementById("space").style.visibility = "hidden";
		 document.getElementById("space").text = "";
		 //tt_Hide();
      } 
   }
}

function getcountry(adresa)
	{
   preloadshow();
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php
      xmlHttp.onreadystatechange = gestioneazacountry;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      }
}

function gestioneazacountry() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul
		 
		 while (document.getElementById('region').childNodes.length > 0) {
			document.getElementById('region').removeChild(document.getElementById('region').childNodes[0])
		}
		 var brokenstring=raspuns.split('#');
		 for (var i=0; i < brokenstring.length;++i){
		 	addOption(document.getElementById('region'), brokenstring[i], brokenstring[i]);
		 }
         //document.getElementById('region').innerHTML = raspuns ;
         preloadhide();
		 //tt_Hide();
      } 
   }
}

function getcountry2(adresa)
	{
   preloadshow();
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php
      xmlHttp.onreadystatechange = gestioneazacountry2;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      }
}

function gestioneazacountry2() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul
		 
		 while (document.getElementById('region2').childNodes.length > 0) {
			document.getElementById('region2').removeChild(document.getElementById('region2').childNodes[0])
		}
		 var brokenstring=raspuns.split('#');
		 for (var i=0; i < brokenstring.length;++i){
		 	addOption(document.getElementById('region2'), brokenstring[i], brokenstring[i]);
		 }
         //document.getElementById('region2').innerHTML = raspuns ;
         preloadhide();
		 //tt_Hide();
      } 
   }
}


function getcountry3(adresa)
	{
   preloadshow();
   // verificam daca xmlHttp este liber 
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
      { 
      //obtinem cele doua valori ale numerelor
      // executam script-ul php de adunare trimitand cele doua numere ca paramentri prin get
      xmlHttp.open("GET", adresa, true);
      //definim functia care se va ocupa de manipularea rezultatului primit de la script-ul php
      xmlHttp.onreadystatechange = gestioneazacountry3;
      // trimitem cererea catre server 
      xmlHttp.send(null); 
      }
}

function gestioneazacountry3() 
   { 
   // daca rezultatul este obtinut 
   if (xmlHttp.readyState == 4) 
      { 
      // status = 200 arata faptul ca cerea a fost rezoltata cu success 
      if (xmlHttp.status == 200) 
         { 
         // extragem rezultatul 
         raspuns = xmlHttp.responseText;
         //modificam div-ul rezultat cu rezultatul
		 
		 while (document.getElementById('region3').childNodes.length > 0) {
			document.getElementById('region3').removeChild(document.getElementById('region3').childNodes[0])
		}
		 var brokenstring=raspuns.split('#');
		 for (var i=0; i < brokenstring.length;++i){
		 	addOption(document.getElementById('region3'), brokenstring[i], brokenstring[i]);
		 }
         preloadhide();
		 //tt_Hide();
      } 
   }
}



function count( mixed_var, mode ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: _argos
    // *     example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE');
    // *     returns 1: 6
    // *     example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE');
    // *     returns 2: 6
 
    var key, cnt = 0;
 
    if( mode == 'COUNT_RECURSIVE' ) mode = 1;
    if( mode != 1 ) mode = 0;
 
    for (key in mixed_var){
        cnt++;
        if( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
            cnt += count(mixed_var[key], 1);
        }
    }
 
    return cnt;
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


var http_request = false;
var msg_div = "";

   function postajax(url, parameters,successdiv) {
   	  preloadshow();
	  favicon.change("http://jobkon-img.jobkon.com/load.gif");
	  document.getElementById("space").style.visibility = "visible";
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      msg_div = successdiv;
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
   		// ================= INFO @ http_request.readyState ================================ \\
		// 0  	The object has not yet started initializing (uninitialized).				 \\
		// 1 	The object is initializing, but no data is being read (loading).			 \\
		// 2 	Data is being loaded into the object and parsed (loaded).                    \\
		// 3 	Parts of the object's data has been read and parsed, so the object model is  \\
		//		available. However, the complete object data is not yet ready (interactive). \\
		// 4 	The object has been loaded, its content parsed (completed).                  \\
		// ================================================================================= \\
		
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById(msg_div).innerHTML = result;      
            document.getElementById("space").style.visibility = "hidden";
			favicon.change("http://jobkon-img.jobkon.com/icon.png");
			preloadhide();
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
function setcookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)
	+ ";expires="+expire.toGMTString();
}


//RANDOMCODE
var vowels = new Array("a", "a", "a", "a", "a", "a", "a", "a", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "i", "i", "i", "i", "i", "i", "i", "i", "i", "i", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "u", "u", "ee", "oo", "ao", "au", "ea", "eu", "ia", "ie", "io", "iu", "oa", "oe", "ou", "ua", "ui", "ue", "uo")
var consonents = new Array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "qu", "r", "s", "t", "v", "w", "x", "y", "z", "bl", "br", "cl", "cr", "dr", "fl", "gr", "kl", "pl", "pr", "sl", "sn", "st", "tr")
var endings = new Array("b", "d", "f", "g", "h", "l", "m", "n", "p", "r", "s", "t", "w", "y", "z", "le", "ly", "ng", "pe", "rd", "re", "st", "th")

function randomcode( nr ) {
  // Declare the variables used in this function:
  //var wordCount = 0     // Number of words to generate
  var syllables = nr     // Number of syllables to generate in each word
  var leading = false   // Allow leading vowels
  var trailing = false  // Allow trailing vowel sounds
  var word = ""         // The word currently being generated
  var wordList = ""     // String of all words that will be put in text area
  var position = 0      // Position of a value in one of the arrays
  var sylsDone = 0      // Number of syllables done in current word
  
  for (j = 0; j < syllables; j++) {
      // Are we generating the first syllable in this word?
      if (j == 0) {
        // This is the first syllable in this word.
        // Are we allowed to use a vowel (skip the first consonant) in the first syllable?
        if (leading == true) {
          // We are allowed to skip the first consonant, so
          // randomly either skip the first consonant or generate it:
          if (rand(2) == 1 & j == 0) {
            position = rand(consonents.length)
            word = word + consonents[position - 1]
          }
        } else {
          // We are not allowed to skip the first consonant, so
          // generate a consonant at the beginning of the first syllable:
          position = rand(consonents.length)
          word = word + consonents[position - 1]
        }
      } else {
        // This is not the first syllable in this word, so we must start it with a consonant:
        position = rand(consonents.length)
        word = word + consonents[position - 1]
      }
      // Every syllable must have a vowel:
      position = rand(vowels.length)
      word = word + vowels[position - 1]
      // Increment the number of syllables done:
      sylsDone = sylsDone + 1
      // Is this the last syllable in the word?
      if (sylsDone == syllables) {
        // This is the last syllable in the word.
        // Is the word allowed to end in a vowel sound?
        if (trailing == true) {
          // The word is allowed to end in a vowel sound, so
          // randomly either skip the last consonant or generate it:
          if (rand(2) == 1) {
            position = rand(endings.length)
            word = word + endings[position - 1]
          }
        } else {
          // The word is not allowed to end in a vowel sound, so
          // generate a consonant at the end of the last syllable:
          position = rand(endings.length)
          word = word + endings[position - 1]
        }
      }
    }
    // Add a carriage return so that the next word will be on the next line:
    return(word)
}

rnd.today=new Date()
rnd.seed=rnd.today.getTime()
function rnd() {
  rnd.seed = (rnd.seed*9301+49297) % 233280
  return rnd.seed/(233280.0)
}
function rand(number) {
  return Math.ceil(rnd()*number)
}



function changeheader(){
	document.getElementById("header1").src = "_imgf_http://jobkon-img.jobkon.com/header11.jpg";
	document.getElementById("header2").src = "_imgf_http://jobkon-img.jobkon.com/header21.jpg";
	document.getElementById("img").src = 'code.php?rand='+(Math.floor(Math.random()*10000000000000000000));
}

function changeheader2(){
	document.getElementById("header1").src = "_imgf_http://jobkon-img.jobkon.com/header1.jpg";
	document.getElementById("header2").src = "_imgf_http://jobkon-img.jobkon.com/header2.jpg";
	document.getElementById("img").src = 'code.php?rand='+(Math.floor(Math.random()*10000000000000000000));
}

function req(action){
	if(action=='register'){
		postu="c1="+encode64(document.getElementById('c1').value)+'&c2='+encode64(document.getElementById('c2').value)+'&c3='+encode64(document.getElementById('c3').value)+'&mail='+(document.getElementById('mail').value)+'&user='+(document.getElementById('user').value)+'&pass='+(document.getElementById('pass').value)+'&pass2='+(document.getElementById('pass2').value)+'&month='+(document.getElementById('month').value)+'&day='+(document.getElementById('day').value)+'&year='+(document.getElementById('year').value)+'&c9='+encode64(document.getElementById('c9').value)+'&country='+encode64(document.getElementById('country').value)+'&region='+encode64(document.getElementById('region').value)+'&c6='+encode64(document.getElementById('c6').value)+'&c7='+encode64(document.getElementById('c7').value)+'&c8='+encode64(document.getElementById('c8').value)+'&c10='+encode64(document.getElementById('c10').value)+'&c11='+encode64(document.getElementById('c11').value)+'&c12='+encode64(document.getElementById('c12').value)+'&code='+(document.getElementById('code').value)+'&edu='+(document.getElementById('ed').value)+'&calif='+(document.getElementById('calif').value)+'&desired='+(document.getElementById('desired').value)+'&favorite='+(document.getElementById('favorite').value)+'&asistant='+document.getElementById('asistant').checked;
		postajax("index.php?page=register_candidates&mod=1",postu,'content');
	}
	
	if(action=='save-personal-candidates'){
		postu=translate("c1="+document.getElementById('c1').value+'#and#c2='+document.getElementById('c2').value+'#and#c3='+document.getElementById('c3').value+'#and#month='+document.getElementById('month').value+'#and#day='+document.getElementById('day').value+'#and#year='+document.getElementById('year').value+'#and#c9='+document.getElementById('c9').value+'#and#c4='+document.getElementById('country2').value+'#and#c5='+document.getElementById('region2').value+'#and#c6='+document.getElementById('c6').value+'#and#c7='+document.getElementById('c7').value+'#and#c8='+document.getElementById('c8').value+'#and#c10='+document.getElementById('c10').value+'#and#c11='+document.getElementById('c11').value+'#and#c12='+document.getElementById('c12').value+'#and#edu='+document.getElementById('edu').value+'#and#calif='+document.getElementById('calif').value+'#and#desired='+document.getElementById('desired').value);
		postajax("index.php?page=personal&mod=1",postu,'content');
	}
	
	if(action=='save-personal-employer'){
		postu=translate("f1="+document.getElementById('f1').value+"#and#c1="+document.getElementById('c1').value+'#and#c2='+document.getElementById('c2').value+'#and#c3='+document.getElementById('c3').value+'#and#pass='+document.getElementById('pass').value+'#and#pass1='+document.getElementById('pass1').value+'#and#pass2='+document.getElementById('pass2').value+'#and#c9='+document.getElementById('c9').value+'#and#c4='+document.getElementById('country2').value+'#and#c5='+document.getElementById('region2').value+'#and#c6='+document.getElementById('c6').value+'#and#c7='+document.getElementById('c7').value+'#and#c8='+document.getElementById('c8').value+'#and#c10='+document.getElementById('c10').value+'#and#c11='+document.getElementById('c11').value+'#and#c12='+document.getElementById('c12').value+'#and#mail2='+document.getElementById('mail2').value);
		postajax("index.php?page=personal&mod=1",postu,'content');
	}
	
	if(action=='experiences'){
		postu="company="+encode64(document.getElementById('company').value)+'&department='+(document.getElementById('department2').value)+'&title='+encode64(document.getElementById('title').value)+'&country='+encode64(document.getElementById('country3').value)+'&region='+encode64(document.getElementById('region3').value)+'&city='+encode64(document.getElementById('city').value)+'&salary='+(document.getElementById('salary').value)+'&dayb='+(document.getElementById('dayb').value)+'&monthb='+(document.getElementById('monthb').value)+'&yearb='+(document.getElementById('yearb').value)+'&daye='+(document.getElementById('daye').value)+'&monthe='+(document.getElementById('monthe').value)+'&yeare='+(document.getElementById('yeare').value)+'&workfield='+encode64(document.getElementById('workfield').value)+'&responsabilities='+encode64(document.getElementById('responsabilities').value)+'&acheivements='+encode64(document.getElementById('acheivements').value)+'&recommandations='+encode64(document.getElementById('recommandations').value)+'&bonuses='+encode64(document.getElementById('bonuses').value);
		postajax("index.php?page=experience&mod=1&lang="+document.getElementById('lang').value,postu,'content');
	}
	
	if(action=='experiences-save'){
		postu="company="+encode64(document.getElementById('company').value)+'&department='+(document.getElementById('department2').value)+'&title='+encode64(document.getElementById('title').value)+'&country='+encode64(document.getElementById('country3').value)+'&region='+encode64(document.getElementById('region3').value)+'&city='+encode64(document.getElementById('city').value)+'&salary='+(document.getElementById('salary').value)+'&dayb='+(document.getElementById('dayb').value)+'&monthb='+(document.getElementById('monthb').value)+'&yearb='+(document.getElementById('yearb').value)+'&daye='+(document.getElementById('daye').value)+'&monthe='+(document.getElementById('monthe').value)+'&yeare='+(document.getElementById('yeare').value)+'&workfield='+encode64(document.getElementById('workfield').value)+'&responsabilities='+encode64(document.getElementById('responsabilities').value)+'&acheivements='+encode64(document.getElementById('acheivements').value)+'&recommandations='+encode64(document.getElementById('recommandations').value)+'&bonuses='+encode64(document.getElementById('bonuses').value);
		postajax("index.php?page=edit-experience&mod=1&id="+document.getElementById('idhidden').value+"&lang="+document.getElementById('lang').value,postu,'content');
	}
	
	if(action=='desired-job'){
		postu=translate("objective="+document.getElementById('objective').value+'#and#job1='+document.getElementById('job1').checked+'#and#job2='+document.getElementById('job2').checked+'#and#job3='+document.getElementById('job3').checked+'#and#job4='+document.getElementById('job4').checked+'#and#job5='+document.getElementById('job5').checked+'#and#job6='+document.getElementById('job6').checked+'#and#job7='+document.getElementById('job7').checked+'#and#day='+document.getElementById('day').value+'#and#month='+document.getElementById('month').value+'#and#year='+document.getElementById('year').value+'#and#salary='+document.getElementById('salary').value+'#and#benefits='+document.getElementById('benefits').value);
		postajax("index.php?page=desired_job&mod=1&lang="+document.getElementById('lang').value,postu,'content');
	}
	
	if(action=='addlanguace'){
		postajax("index.php?page=studies&mod=1&lang="+document.getElementById('lang').value,"save=languace&languace="+document.getElementById('languace').value+'&writing='+document.getElementById('writing').value+'&speaking='+document.getElementById('speaking').value+'&reading='+document.getElementById('reading').value,'content');
	}
	
	if(action=='remlanguace'){
		postajax("index.php?page=studies&mod=1&lang="+document.getElementById('lang').value,"save=remlanguace&languace="+document.getElementById('languaces').value,'content');
	}
	
	if(action=='savestudies'){
		postu=translate("save=savestudies#and#studies="+document.getElementById('studiess').value+"#and#studiesaf="+document.getElementById('studiesaf').value+"#and#courses="+document.getElementById('courses').value+"#and#pc="+document.getElementById('pc').value+"#and#other="+document.getElementById('other').value);
		postajax("index.php?page=studies&mod=1&lang="+document.getElementById('lang').value,postu,'content');
	}
	
	if(action=='intent-letter'){
		postu=translate("letter="+document.getElementById('letter').value);
		postajax("index.php?page=intent_letter&mod=1&lang="+document.getElementById('lang').value,postu,'content');
	}
	
	if(action=='register_employers'){
		postu='f1='+encode64(document.getElementById('f1').value)+'&mail='+(document.getElementById('mail').value)+'&mail2='+(document.getElementById('mail2').value)+'&user='+(document.getElementById('user').value)+'&pass='+(document.getElementById('pass').value)+'&pass2='+(document.getElementById('pass2').value)+'&country='+encode64(document.getElementById('country').value)+'&region='+encode64(document.getElementById('region').value)+'&c6='+encode64(document.getElementById('c6').value)+'&c7='+encode64(document.getElementById('c7').value)+'&c8='+encode64(document.getElementById('c8').value)+'&c10='+encode64(document.getElementById('c10').value)+'&c11='+encode64(document.getElementById('c11').value)+'&c12='+encode64(document.getElementById('c12').value)+'&code='+(document.getElementById('code').value)+'&asistant='+document.getElementById('asistant').checked;
		postajax("index.php?page=register_employers&mod=1",postu,'content');
	}
	
	if(action=='recover-password'){
		postajax("index.php?page=forgotpassword&mod=1",'mail='+document.getElementById('mail').value+'&code='+document.getElementById('code').value,'content');
	}
	
	if(action=='post-job'){
		postu=translate("c1="+document.getElementById('c1').value+"#and#c2="+document.getElementById('c2').value+"#and#c3="+document.getElementById('c3').value+"#and#c4="+document.getElementById('c4').value+"#and#c5="+document.getElementById('c5').value+"#and#c6="+document.getElementById('c6').value+'#and#c10'+document.getElementById('c10').value+'#and#job1='+document.getElementById('job1').checked+'#and#job2='+document.getElementById('job2').checked+'#and#job3='+document.getElementById('job3').checked+'#and#job4='+document.getElementById('job4').checked+'#and#job5='+document.getElementById('job5').checked+'#and#job6='+document.getElementById('job6').checked+'#and#job7='+document.getElementById('job7').checked+'#and#c8='+document.getElementById('c8').value+'#and#begindate='+document.getElementById('begindate').value+'#and#enddate='+document.getElementById('enddate').value+'#and#country='+document.getElementById('country2').value+'#and#region='+document.getElementById('region2').value+'#and#ontop='+document.getElementById('ontop').checked+'#and#chenar='+document.getElementById('chenar').checked);
		postajax("index.php?page=my_jobs_post&mod=1",postu,'content');
	}
	
	if(action=='post-job-confirm'){
		postajax("index.php?page=job-post-confirm&mod=1&id="+document.getElementById('idu').value,"post=post",'content');
	}
	if(action=='post-job-confirm-edit'){
		postajax("index.php?page=job-post-confirm&mod=1&option=edit&id="+document.getElementById('idu').value,"post=post",'content');
	}

	if(action=='post-job-cancel'){
		postajax("index.php?page=job-post-confirm&mod=1&id="+document.getElementById('idu').value,"post=cancel",'content');
	}
	
	if(action=='save-settings'){
		postajax("index.php?page=settings&mod=1","candidati="+document.getElementById('candidati').value+"&candidatic="+document.getElementById('candidatic').value+"&firme="+document.getElementById('firme').value+"&firmec="+document.getElementById('firmec').value+"&advice="+document.getElementById('advice').value+"&tips="+document.getElementById("tips").value+"&testimonials="+document.getElementById("testimonials").value+"&invoices="+document.getElementById("invoices").value+"&edit="+document.getElementById('edit').value+"&clone="+document.getElementById("clone").value+"&access="+document.getElementById('access').value+"&files="+document.getElementById('files').value+"&setari="+document.getElementById('setari').value+"&loguri="+document.getElementById('loguri').value+"&statistics="+document.getElementById("statistics").value+"&ban="+document.getElementById('ban').value+"&passrecover="+document.getElementById('passrecover').value+"&anunt="+document.getElementById('anunt').value+"&anuntdurata="+document.getElementById('anuntdurata').value+"&ontop="+document.getElementById('ontop').value+"&chenar="+document.getElementById('chenar').value+"&credits="+document.getElementById('credits').value+"&mail1="+document.getElementById('mail1').value+"&mail2="+document.getElementById('mail2').value+"&mail3="+document.getElementById('mail3').value+"&mail4="+document.getElementById('mail4').value+"&mail5="+document.getElementById('mail5').value,'content');
	}
	
	if(action=='save-account-data'){
		postajax("index.php?page=my_settings&mod=1","mail2="+document.getElementById('mail2').value+"&pass="+document.getElementById('pass').value+"&pass1="+document.getElementById('pass1').value+"&pass2="+document.getElementById('pass2').value,'content');
	}
	
	if(action=='search-candidate-op'){
		postajax("index.php?page=accounts&mod=1&nu=&du="+document.getElementById('du').value+"&accmin="+document.getElementById('accmin').value+"&accmax="+document.getElementById('accmax').value,"id="+document.getElementById('id').value+"&user="+document.getElementById('user').value,'content');
	}
	
	if(action=='contact'){
		postu=translate("c1="+document.getElementById('c1').value+"#and#mail="+document.getElementById('mail').value+"#and#subject="+document.getElementById('subject').value+"#and#mesaj="+document.getElementById('mesaj').value);
		postajax("index.php?page=contact&mod=1",postu,'content');
	}
	
	if(action=='advice'){
		postu=translate("title="+document.getElementById('title').value+"#and#cont="+document.getElementById('cont').value);
		postajax("index.php?page=advice&mod=1&id="+document.getElementById('id').value,postu,'content');
	}
	
	if(action=='tips'){
		postu=translate("title="+document.getElementById('title').value+"#and#cont="+document.getElementById('cont').value);
		postajax("index.php?page=tips&mod=1&id="+document.getElementById('id').value,postu,'content');
	}
}

function fillregions(){
	FillCountry(document.getElementById('country'), document.getElementById('region'), '');
}

function fillregions2(){
	FillCountry(document.getElementById('country2'), document.getElementById('region2'), '');
}

function fillregions3(){
	FillCountry(document.getElementById('country3'), document.getElementById('region3'), '');
}



function desc(){
				if(document.getElementById('plan').value=="1"){
					document.getElementById('offer').innerHTML="Buy an agreement subscription for <strong>3 months</strong>, and you will get <strong>90 days</strong> of full access in our database, that means you can see unlimited no. of Cv's, and post up to <strong>3 jobs offers</strong>.";
				}else if(document.getElementById('plan').value=="2"){
					document.getElementById('offer').innerHTML="Buy an agreement subscription for <strong>6 months</strong>, and you will get <strong>180 days</strong> of full access in our database, that means you can see unlimited no. of Cv's, and post up to <strong>6 jobs offers</strong>.";
				}else if(document.getElementById('plan').value=="3"){
					document.getElementById('offer').innerHTML="Buy an agreement subscription for <strong>12 months</strong>, and you will get 365 days of full access in our database, that means you can see unlimited no. of Cv's, and post up to <strong>10 jobs offers</strong>.";
				}
}

function descpt(){
				if(document.getElementById('plan').value=="1"){
					document.getElementById('offer').innerHTML="Comprar um acordo subscriç&atilde;o para <strong>3 meses</strong>, e voc&ecirc; obterá acesso total <strong>90 dias</strong> em nossa base de dados, isso significa que voc&ecirc; pode ver número ilimitado de currículos e postar até <strong>3 ofertas de emprego</strong>.";
				}else if(document.getElementById('plan').value=="2"){
					document.getElementById('offer').innerHTML="Comprar um acordo subscriç&atilde;o para <strong>6 meses</strong>, e voc&ecirc; obterá acesso total <strong>180 dias</strong> em nossa base de dados, isso significa que voc&ecirc; pode ver número ilimitado de currículos e postar até <strong>6 ofertas de emprego</strong>.";
				}else if(document.getElementById('plan').value=="3"){
					document.getElementById('offer').innerHTML="Comprar um acordo subscriç&atilde;o para <strong>12 meses</strong>, e voc&ecirc; obterá acesso total <strong>365 dias</strong> em nossa base de dados, isso significa que voc&ecirc; pode ver número ilimitado de currículos e postar até <strong>10 ofertas de emprego</strong>.";
				}
}

function help(div){
	if(div=='namehelp'){
		mesaj='Insert your real name here. This name, will appear to your cv and will be seen by employers.';
	}else if(div=='genderhelp'){
		mesaj='Select your gender from the list. This is very important for an employer to know.';
	}else if(div=='mailhelp'){
		mesaj="Insert your email address here, it must be real and valid. Your email address must not exists in our database. If it already exists, please contact us by pressing the 'Contact' button from the menu.";
	}else if(div=='mailhelp2'){
		mesaj="Insert your second email address here, it must be real and valid. Your email address must not exists in our database. If it already exists, please contact us by pressing the 'Contact' button from the menu.";
	}else if(div=='userhelp'){
		mesaj="Your username must be unique in our database, and it is not case sensitive. To make sure that it is not already taken by someone else, wait until the 'Loading' status disappears, and a message will appear near this field to reveal if the username is available or not.<br><br>O nome de usuário deve conter apenas letras e números, sem sinais diacríticos.";
	}else if(div=='passhelp'){
		mesaj="Choose a password that is easy for you to remember. Do not write your password or give it to your friends or family members. We will email your username and password.<br><br>REMEMBER: THE PASSWORD IS CASESENSITIVE.<br><br>A senha deve conter apenas letras e números, sem sinais diacríticos.";
	}else if(div=='passhelp2'){
		mesaj="You must write down the desired password again, to avoid errors.<br><br>REMEMBER: THE PASSWORD IS CASESENSITIVE.";
	}else if(div=='birthhelp'){
		mesaj="Write your birthdate like this: day / month / year. It is very important for an employer to know your age.";
	}else if(div=='countryhelp'){
		mesaj="Choose the country where you are from.";
	}else if(div=='regionhelp'){
		mesaj="Choose the region where you are from.";
	}else if(div=='cityhelp'){
		mesaj="Insert the city where you are from.";
	}else if(div=='addresshelp'){
		mesaj="Insert your complete address. This will appear on your cv.";
	}else if(div=='addresshelpempl'){
		mesaj="Insert your complete physical address.";
	}else if(div=='idhelp'){
		mesaj="Insert your ID.";
	}else if(div=='phonehelp'){
		mesaj="Write your phone number in order for the employers to call you for interviews.";
	}else if(div=='cellhelp'){
		mesaj="Write your cell phone number in order for the employers to call you for interviews.";
	}else if(div=='faxhelp'){
		mesaj="Write your fax number in order for the employers to call you for interviews.";
	}else if(div=='codehelp'){
		mesaj="Insert the code you see in from the image above. This is a security measure to identify bots or programs.";
	}else if(div=='agreehelp'){
		mesaj="In order to use this site, you must read and agree to our terms and conditions.";
	}else if(div=='registerhelp'){
		mesaj="After you click the complete registration you will receive an e-mail from one of our assistants. Make sure you activate your account sent in your e-mail within 2 weeks.";
	}else if(div=='companyhelp'){
		mesaj="Input your company name here.";
	}else if(div=='eduhelp'){
		mesaj="Select your education degree.";
	}else if(div=='califhelp'){
		mesaj="Select your qualification level.";
	}else if(div=='desiredhelp'){
		mesaj="Select your desired job department.";
	}
	document.getElementById(div).innerHTML=mesaj;
	document.getElementById(div).style.display='inline';
}

function unhelp(div){
	document.getElementById(div).innerHTML='';
	document.getElementById(div).style.display='none';
}

function helppt(div){
	if(div=='namehelp'){
		mesaj='Digite seu nome verdadeiro aqui. Este nome, aparecer&aacute; no seu cv e ser&aacute; visto por empregadores.';
	}else if(div=='genderhelp'){
		mesaj='Escolha seu g&eacute;nero na lista. Esta informa&ccedil;&atilde;o &eacute; muito importante para o empregador.';
	}else if(div=='mailhelp'){
		mesaj="Digite seu endere&ccedil;o de e-mail aqui, deve ser real e v&aacute;lido. Seu endere&ccedil;o de e-mail n&atilde;o deve existir em nossa base de dados. Se j&aacute; existe, por favor contate-nos clicando o bot&atilde;o Contato do menu.";
	}else if(div=='mailhelp2'){
		mesaj="Digite seu segundo endere&ccedil;o de e-mail aqui, deve ser real e v&aacute;lido. Seu endere&ccedil;o de e-mail n&atilde;o deve existir em nossa base de dados. Se j&aacute; existe, por favor contate-nos clicando o bot&atilde;o  Contato do menu.";
	}else if(div=='userhelp'){
		mesaj="Seu nome de usu&aacute;rio deve ser unico em nossa base de dados, e n&atilde;o &eacute; diferenciando com mai&uacute;sculas e min&uacute;sculas. Para certificar-se de que n&atilde;o est&aacute; a ser usado  por alguma outra pessoa, espere at&eacute; o estado de 'Loading'  desaparecer, e uma mensagem aparecer&aacute; perto deste campo para revelar se o seu nome de usu&aacute;rio est&aacute; dispon&iacute;vel ou n&atilde;o.";
	}else if(div=='passhelp'){
		mesaj="Escolha uma senha que seja f&aacute;cil para voc&ecirc; lembrar. N&atilde;o escreva sua senha nem a d&ecirc; a seus amigos ou membros da fam&iacute;lia. N&oacute;s enviaremos por e-mail seu nome de usu&aacute;rio e sua senha .&lt;br&gt;&lt;br&gt;LEMBRE-SE: A SENHA DIFERENCIA LETRAS(caract&eacute;res maiusculas das minusculas).";
	}else if(div=='passhelp2'){
		mesaj="Voc&ecirc; deve escrever abaixo novamente a senha desejada , para evitar erros.&lt;br&gt;&lt;br&gt; LEMBRE-SE: A SENHA DIFERENCIA LETRAS(caract&eacute;res maiusculas das minusculas).";
	}else if(div=='birthhelp'){
		mesaj="Escreva sua data de nascimento assim: dia/m&ecirc;s/ano. &Eacute; muito importante para um empregador saber sua idade.";
	}else if(div=='countryhelp'){
		mesaj="Escolha o pa&iacute;s onde voc&ecirc; vive.";
	}else if(div=='regionhelp'){
		mesaj="Escolha a regi&atilde;o de onde voc&ecirc; vive.";
	}else if(div=='cityhelp'){
		mesaj="Digite a cidade de onde voc&ecirc; vive.";
	}else if(div=='addresshelp'){
		mesaj="Digite seu endere&ccedil;o completo. Isto aparecer&aacute; no seu cv.";
	}else if(div=='addresshelpempl'){
		mesaj="Digite seu endere&ccedil;o completo.";
	}else if(div=='idhelp'){
		mesaj="Digite  o seu ID.";
	}else if(div=='phonehelp'){
		mesaj="Escreva seu n&uacute;mero de telefone para que os empregadores possam contacta-lo para as entrevistas.";
	}else if(div=='cellhelp'){
		mesaj="Escreva seu n&uacute;mero de telefone celular para que os empregadores possam contacta-lo para as entrevistas.";
	}else if(div=='faxhelp'){
		mesaj="Escreva seu n&uacute;mero de fax para que os empregadores possam contacta-lo para as entrevistas.";
	}else if(div=='codehelp'){
		mesaj="Digite o c&oacute;digo que voc&ecirc; v&ecirc; dentro da imagem acima. Esta &eacute; uma medida de seguran&ccedil;a para  identificar bot ou programas.";
	}else if(div=='agreehelp'){
		mesaj="Para usar este site, voc&ecirc; deve ler e concordar com os  nossos termos e condi&ccedil;&otilde;es.";
	}else if(div=='registerhelp'){
		mesaj="Depois que voc&ecirc; clicar o registo completo voc&ecirc; receber&aacute; um email de um de nossos assistentes.Tenha certeza voc&ecirc; ativa sua conta que ser&aacute; enviada para o seu e-mail dentro de 2 semanas.";
	}else if(div=='companyhelp'){
		mesaj="Introduza o nome da sua companhia aqui.";
	}else if(div=='eduhelp'){
		mesaj="Escolha o seu grau da instru&ccedil;&atilde;o.";
	}else if(div=='califhelp'){
		mesaj="Escolha seu n&iacute;vel da qualifica&ccedil;&atilde;o.";
	}else if(div=='desiredhelp'){
		mesaj="Escolha o departamento em que deseja trabalhar.";
	}
	document.getElementById(div).innerHTML=	mesaj;
	document.getElementById(div).style.display='inline';
}

function unhelppt(div){
	document.getElementById(div).innerHTML='';
	document.getElementById(div).style.display='none';
}

function validateexperience(lang){
	var failed=false;
	var err='';
	if(lang=='en'){
		err='Some fields have not been filled. Please check the following errors:\n\r\n\r';
	}else if(lang=='pt'){
		err='Alguns campos nâo foram preenchidos. Por favor, verifique os seguintes erros:\n\r\n\r';
	}
	if(document.getElementById('company').value.length==0){
		failed=true;
		if(lang=='en'){
			err+='Invalid company title.\n\r';
		}else if(lang=='pt'){
			err+='Inválido experiência título.\n\r';
		}
	}
	if(document.getElementById('department2').value.length==0 || document.getElementById('department2').value==0){
		failed=true;
		if(lang=='en'){
			err+='Invalid department value.\n\r';
		}else if(lang=='pt'){
			err+='Departamento valor inválido.\n\r';
		}
	}
	if(document.getElementById('title').value.length==0){
		failed=true;
		if(lang=='en'){
			err+='Invalid title value.\n\r';
		}else if(lang=='pt'){
			err+='Título do valor inválido.\n\r';
		}
	}
	if(document.getElementById('salary').value.length==0){
		failed=true;
		if(lang=='en'){
			err+='Invalid salary value.\n\r';
		}else if(lang=='pt'){
			err+='Valor inválido salário.\n\r';
		}
	}
	if(document.getElementById('dayb').value.length==0 || document.getElementById('monthb').value.length==0 || document.getElementById('yearb').value.length==0){
		failed=true;
		if(lang=='en'){
			err+='Invalid begin date value.\n\r';
		}else if(lang=='pt'){
			err+='À data de início valor inválido.\n\r';
		}
	}
	var monthe=document.getElementById("monthe").value;
	var time = new Date();
	if((document.getElementById('daye').value.length==0 || document.getElementById('monthe').value.length==0 || document.getElementById('yeare').value.length==0 || tosec(1,1,1,document.getElementById("dayb").value,document.getElementById("monthb").value,document.getElementById("yearb").value)>=tosec(1,1,1,document.getElementById("daye").value,parseFloat(monthe),document.getElementById("yeare").value)) && (document.getElementById('daye').value!='--' && document.getElementById('monthe').value!='--' && document.getElementById('yeare').value!='--')){
		failed=true;
		if(lang=='en'){
			err+='Invalid end date value.\n\r';
		}else if(lang=='pt'){
			err+='Valor inválido data final.\n\r';
		}
	}
	if(document.experience.country.value==''){
		failed=true;
		if(lang=='en'){
			err+='Invalid country selection\n\r';
		}else if(lang=='pt'){
			err+='Selecção do país inválido\n\r';
		}
	}
	if(document.experience.region2.value=='' && document.experience.country.value!="Other Country"){
		failed=true;
		if(lang=='en'){
			err+='Invalid region selection\n\r';
		}else if(lang=='pt'){
			err+='Selecção do região inválido\n\r';
		}
	}
	if(failed==true){
		alert(err);
		return false;
	}else{
		return true;
	}
}

var dhtmlwindow={
imagefiles:['', 'js/close.gif', 'js/restore.gif', 'js/resize.gif'], //Path to 4 images used by script, in that order
ajaxbustcache: true, //Bust caching when fetching a file via Ajax?

minimizeorder: 0,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes

init:function(t){
	var domwindow=document.createElement("div") //create dhtml window div
	domwindow.id=t
	if(navigator.appName == "Netscape" || navigator.appName == "Opera"){
		domwindow.className="dhtmlwindow";
	}else{
		domwindow.className="dhtmlwindowie";
	}
	var domwindowdata=''
	domwindowdata='<div class="drag-handle">'
	domwindowdata+='DHTML Window <div class="drag-controls"><img src="'+this.imagefiles[1]+'" title="Close" /></div>'
	domwindowdata+='</div>'
	domwindowdata+='<div class="drag-contentarea"></div>'
	domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url('+this.imagefiles[3]+') top right no-repeat;">&nbsp;</div></div>'
	domwindowdata+='</div>'
	domwindow.innerHTML=domwindowdata
	document.getElementById("dhtmlwindowholder").appendChild(domwindow)
	this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	var t=document.getElementById(t)
	var divs=t.getElementsByTagName("div")
	for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		if (/drag-/.test(divs[i].className))
			t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	}
	t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	t.handle._parent=t //store back reference to dhtml window
	t.resizearea._parent=t //same
	t.controls._parent=t //same
	t.onclose=function(){return true} //custom event handler "onclose"
	t.onmousedown=function(){dhtmlwindow.zIndexvalue++; this.style.zIndex=dhtmlwindow.zIndexvalue} //Increase z-index of window when focus is on it
	t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
	t.resizearea.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
	t.controls.onclick=dhtmlwindow.enablecontrols
	t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
	t.hide=function(){dhtmlwindow.close(this)} //public function for hiding dhtml window
	t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions
	t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	t.isResize=function(bol){dhtmlwindow.isResize(this, bol)} //public function for specifying if window is resizable
	t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
	t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
	this.tobjects[this.tobjects.length]=t
	return t //return reference to dhtml window div
},

open:function(t, contenttype, contentsource, title, attr, recalonload){
	var winX=readcookie('jobkoncompopupx');
	var winY=readcookie('jobkoncompopupy');
    
    if(winX==''){winX = 0;}
    if(winY==''){winY = (window.document.all)?window.screenTop:window.screenY;}
    
    attr+='left='+winX+'px, top='+winY+'px';
    setcookie('jobkoncompopupx',winX,365);
    setcookie('jobkoncompopupy',winY,365);
	
	
	
	var d=dhtmlwindow //reference dhtml window object
	function getValue(Name){
		var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	}
	if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		t=this.init(t) //return reference to dhtml window div
	else
		t=document.getElementById(t)
	t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	//alert(getValue(("width")));
	//var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	var xpos=getValue("left") //Get x coord of window
	//var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	var ypos=getValue("top") //Get y coord of window
	//t.moveTo(xpos, ypos) //Position window
	if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		else
			this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	}
	t.isResize(getValue("resize")) //Set whether window is resizable
	t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
	t.style.visibility="visible"
	t.style.display="block"
	t.contentarea.style.display="block"
	t.moveTo(xpos, ypos) //Position window
	t.load(contenttype, contentsource, title)
	if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
		t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
		t.controls.firstChild.setAttribute("title", "Minimize")
		t.state="fullview" //indicate the state of the window as being "fullview"
	}
	tt=t;
    adjustposition();
	return t
},

setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	t.style.width=Math.max(parseInt(w), 150)+"px"
	t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},

moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	this.getviewpoint() //Get current viewpoint numbers
	//t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	t.style.left=x+"px" 
	//t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
	t.style.top=y+"px"
},

isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
	t.statusarea.style.display=(bol)? "block" : "none"
	t.resizeBool=(bol)? 1 : 0
},

isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},

load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	var contenttype=contenttype.toLowerCase() //convert string to lower case
	if (typeof title!="undefined")
		t.handle.firstChild.nodeValue=title
	if (contenttype=="inline")
		t.contentarea.innerHTML=contentsource
	else if (contenttype=="div"){
		t.contentarea.innerHTML=document.getElementById(contentsource).innerHTML //Populate window with contents of specified div on page
		document.getElementById(contentsource).style.display="none" //hide that div
	}
	else if (contenttype=="iframe"){
		t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
		if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
			t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'" id="_iframe-'+t.id+'"></iframe>'
		window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
		}
	else if (contenttype=="ajax"){
		this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	}
	t.contentarea.datatype=contenttype //store contenttype of current window for future reference
},

setupdrag:function(e){
	var d=dhtmlwindow //reference dhtml window object
	var t=this._parent //reference dhtml window div
	d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e
	d.initmousex=e.clientX //store x position of mouse onmousedown
	if(d.initmousex<3){d.initmousex=3;}
	d.initmousey=e.clientY
	if(d.initmousey<3){d.initmousey=3;}
	d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	d.inity=parseInt(t.offsetTop)
	d.width=parseInt(t.offsetWidth) //store width of window div
	d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
		t.contentarea.style.visibility="hidden"
	}
	document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	document.onmouseup=function(){
		if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			t.contentarea.style.backgroundColor="white"
			t.contentarea.style.visibility="visible"
		}
		d.stop()
	}
	return false
},

getdistance:function(e){
	var d=dhtmlwindow
	var etarget=d.etarget
	var e=window.event || e
	d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	d.distancey=e.clientY-d.initmousey
	if (etarget.className=="drag-handle") //if target element is "handle" div
		d.move(etarget._parent, e)
	else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		d.resize(etarget._parent, e)
	return false //cancel default dragging behavior
},

getviewpoint:function(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},

rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	this.getviewpoint() //Get current window viewpoint numbers
	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
	t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
},

move:function(t, e){
	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
	var yy=dhtmlwindow.distancey+dhtmlwindow.inity
	if(yy<3){yy=3}
	t.style.top=yy+"px"
},

resize:function(t, e){
	t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
	t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
},

enablecontrols:function(e){
	var d=dhtmlwindow
	var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
		d.minimize(sourceobj, this._parent)
	else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
		d.restore(sourceobj, this._parent)
	else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)
	return false
},

minimize:function(button, t){
	dhtmlwindow.rememberattrs(t)
	button.setAttribute("src", dhtmlwindow.imagefiles[2])
	button.setAttribute("title", "Restore")
	t.state="minimized" //indicate the state of the window as being "minimized"
	t.contentarea.style.display="none"
	t.statusarea.style.display="none"
	if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows

		dhtmlwindow.minimizeorder++ //increment order
		t.minimizeorder=dhtmlwindow.minimizeorder
	}
	t.style.left="10px" //left coord of minmized window
	t.style.width="200px"
	t.style.position="fixed"
	var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
	t.style.top="800"
	//t.style.top=dhtmlwindow.scroll_top+dhtmlwindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing-20+"px"
},

restore:function(button, t){
	dhtmlwindow.getviewpoint()
	button.setAttribute("src", dhtmlwindow.imagefiles[0])
	button.setAttribute("title", "Minimize")
	t.state="fullview" //indicate the state of the window as being "fullview"
	t.style.display="block"
	t.contentarea.style.display="block"
	if (t.resizeBool) //if this window is resizable, enable the resize icon
		t.statusarea.style.display="block"
	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px" //position window to last known x coord just before minimizing
	var yy=parseInt(t.lasty)+dhtmlwindow.scroll_top
	if(yy<3){yy=3}
	t.style.top=yy+"px"
	t.style.width=parseInt(t.lastwidth)+"px"
	//t.style.position="absolute"
},


close:function(t){
	var dividu=t.id
	document.getElementById("_iframe-"+dividu).src=''
	try{
		var closewinbol=t.onclose()
	}
	catch(err){ //In non IE browsers, all errors are caught, so just run the below
		var closewinbol=true
 }
	finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		if (typeof closewinbol=="undefined"){
			alert("An error has occured somwhere inside your \"onclose\" event handler")
			var closewinbol=true
		}
	}
	if (closewinbol){ //if custom event handler function returns true
		if (t.state!="minimized") //if this window isn't currently minimized
			dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		t.style.display="none"
	}
	divwin=t.init;
	return closewinbol
},

show:function(t){
	if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
	else
		t.style.display="block"
	t.state="fullview" //indicate the state of the window as being "fullview"
},

ajax_connect:function(url, t){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
	if (this.ajaxbustcache) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
},

ajax_loadpage:function(page_request, t){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	t.contentarea.innerHTML=page_request.responseText
	}
},


stop:function(){
	dhtmlwindow.etarget=null //clean up
	document.onmousemove=null
	document.onmouseup=null
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

cleanup:function(){
	for (var i=0; i<dhtmlwindow.tobjects.length; i++){
		dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
	}
	window.onload=null
}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup





// Favicon.js - Change favicon dynamically [http://ajaxify.com/run/favicon].
// Copyright (c) 2006 Michael Mahemoff. Only works in Firefox and Opera.
// Background and MIT License notice at end of file, see the homepage for more.

// USAGE:
// * favicon.change("/icon/active.ico");  (Optional 2nd arg is new title.)
// * favicon.animate(new Array("icon1.ico", "icon2.ico", ...));
//     Tip: Use "" as the last element to make an empty icon between cycles.
//     To stop the animation, call change() and pass in the new arg.
//     (Optional 2nd arg is animation pause in millis, overwrites the default.)
// * favicon.defaultPause = 5000;

var favicon = {

// -- "PUBLIC" ----------------------------------------------------------------

defaultPause: 2000,

change: function(iconURL, optionalDocTitle) {
  clearTimeout(this.loopTimer);
  if (optionalDocTitle) {
    document.title = optionalDocTitle;
  }
  this.addLink(iconURL, true);
},

animate: function(iconSequence, optionalDelay) {
  this.preloadIcons(iconSequence);
  this.iconSequence = iconSequence;
  this.sequencePause = (optionalDelay) ?  optionalDelay : this.defaultPause;
  favicon.index = 0;
  favicon.change(iconSequence[0]);
  this.loopTimer = setInterval(function() {
    favicon.index = (favicon.index+1) % favicon.iconSequence.length;
    favicon.addLink(favicon.iconSequence[favicon.index], false);
  }, favicon.sequencePause);
},

// -- "PRIVATE" ---------------------------------------------------------------

loopTimer: null,

preloadIcons: function(iconSequence) {
  var dummyImageForPreloading = document.createElement("img");
  for (var i=0; i<iconSequence.length; i++) {
    dummyImageForPreloading.src = iconSequence[i];
  }
},

addLink: function(iconURL) {
  var link = document.createElement("link");
  link.type = "image/x-icon";
  link.rel = "shortcut icon";
  link.href = iconURL;
  this.removeLinkIfExists();
  this.docHead.appendChild(link);
},

removeLinkIfExists: function() {
  var links = this.docHead.getElementsByTagName("link");
  for (var i=0; i<links.length; i++) {
    var link = links[i];
    if (link.type=="image/x-icon" && link.rel=="shortcut icon") {
      this.docHead.removeChild(link);
      return; // Assuming only one match at most.
    }
  }
},

docHead:document.getElementsByTagName("head")[0]
}

// BACKGROUND
// The main point of this script is to give you a means of alerting the user
// something has happened while your application is in a background tab. Serves
// a similar task to notifications in the operating system taskbar. A secondary
// function is to support favicon animation.
//
// This script works by DOM manipulation. After a call, there will be exactly one
// "rel='icon'" link and one "rel='shortcut icon'" link under the head element.
// Both of these are required for portability reasons. It would be nice  (from
// a performance perspective) if we could just update an existing link, if it
// already exists, but it turns out we can't. Firefox (and others?) will ignore
// changes to the link's attributes; it's only interested in a new link being
// added. So we have to delete and re-add in all cases.

// LEGAL
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
// copies of the Software, and to permit persons to whom the Software is 
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE.












var datePickerDivID = "datepicker";
var iFrameDivID = "datepickeriframe";

var dayArrayShort = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
var dayArrayLong = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
var monthArrayLong = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
 

var defaultDateSeparator = "/";        // common values would be "/" or "."
var defaultDateFormat = "dmy"    // valid values are "mdy", "dmy", and "ymd"
var dateSeparator = defaultDateSeparator;
var dateFormat = defaultDateFormat;

/**
This is the main function you'll call from the onClick event of a button.
Normally, you'll have something like this on your HTML page:

Start Date: <input name="StartDate">
<input type=button value="select" onclick="displayDatePicker('StartDate');">

That will cause the datepicker to be displayed beneath the StartDate field and
any date that is chosen will update the value of that field. If you'd rather have the
datepicker display beneath the button that was clicked, you can code the button
like this:

<input type=button value="select" onclick="displayDatePicker('StartDate', this);">

So, pretty much, the first argument (dateFieldName) is a string representing the
name of the field that will be modified if the user picks a date, and the second
argument (displayBelowThisObject) is optional and represents an actual node
on the HTML document that the datepicker should be displayed below.

In version 1.1 of this code, the dtFormat and dtSep variables were added, allowing
you to use a specific date format or date separator for a given call to this function.
Normally, you'll just want to set these defaults globally with the defaultDateSeparator
and defaultDateFormat variables, but it doesn't hurt anything to add them as optional
parameters here. An example of use is:

<input type=button value="select" onclick="displayDatePicker('StartDate', false, 'dmy', '.');">

This would display the datepicker beneath the StartDate field (because the
displayBelowThisObject parameter was false), and update the StartDate field with
the chosen value of the datepicker using a date format of dd.mm.yyyy
*/
function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep)
{
  var targetDateField = document.getElementsByName (dateFieldName).item(0);
 
  // if we weren't told what node to display the datepicker beneath, just display it
  // beneath the date field we're updating
  if (!displayBelowThisObject)
    displayBelowThisObject = targetDateField;
 
  // if a date separator character was given, update the dateSeparator variable
  if (dtSep)
    dateSeparator = dtSep;
  else
    dateSeparator = defaultDateSeparator;
 
  // if a date format was given, update the dateFormat variable
  if (dtFormat)
    dateFormat = dtFormat;
  else
    dateFormat = defaultDateFormat;
 
  var x = displayBelowThisObject.offsetLeft;
  var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight ;
 
  // deal with elements inside tables and such
  var parent = displayBelowThisObject;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    x += parent.offsetLeft;
    y += parent.offsetTop ;
  }
 
  drawDatePicker(targetDateField, x, y);
}


/**
Draw the datepicker object (which is just a table with calendar elements) at the
specified x and y coordinates, using the targetDateField object as the input tag
that will ultimately be populated with a date.

This function will normally be called by the displayDatePicker function.
*/
function drawDatePicker(targetDateField, x, y)
{
  var dt = getFieldDate(targetDateField.value );
 
  // the datepicker table will be drawn inside of a <div> with an ID defined by the
  // global datePickerDivID variable. If such a div doesn't yet exist on the HTML
  // document we're working with, add one.
  if (!document.getElementById(datePickerDivID)) {
    // don't use innerHTML to update the body, because it can cause global variables
    // that are currently pointing to objects on the page to have bad references
    //document.body.innerHTML += "<div id='" + datePickerDivID + "' class='dpDiv'></div>";
    var newNode = document.createElement("div");
    newNode.setAttribute("id", datePickerDivID);
    newNode.setAttribute("class", "dpDiv");
    newNode.setAttribute("style", "visibility: hidden;");
    document.body.appendChild(newNode);
  }
 
  // move the datepicker div to the proper x,y coordinate and toggle the visiblity

  var pickerDiv = document.getElementById(datePickerDivID);
  pickerDiv.style.position = "absolute";
  pickerDiv.style.left = x + "px";
  pickerDiv.style.top = y + "px";
  pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
  pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
  pickerDiv.style.zIndex = 10000;
 
  // draw the datepicker table
  refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
}


/**
This is the function that actually draws the datepicker calendar.
*/
function refreshDatePicker(dateFieldName, year, month, day)
{
  // if no arguments are passed, use today's date; otherwise, month and year
  // are required (if a day is passed, it will be highlighted later)
  var thisDay = new Date();
 
  if ((month >= 0) && (year > 0)) {
    thisDay = new Date(year, month, 1);
  } else {
    day = thisDay.getDate();
    thisDay.setDate(1);
  }
 
  // the calendar will be drawn as a table
  // you can customize the table elements with a global CSS style sheet,
  // or by hardcoding style and formatting elements below
  var crlf = "\r\n";
  var TABLE = "<table cols=7 class='dpTable'>" + crlf;
  var xTABLE = "</table>" + crlf;
  var TR = "<tr class='dpTR'>";
  var TR_title = "<tr class='dpTitleTR'>";
  var TR_days = "<tr class='dpDayTR'>";
  var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
  var xTR = "</tr>" + crlf;
  var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var TD_title = "<td colspan=5 class='dpTitleTD'>";
  var TD_buttons = "<td class='dpButtonTD'>";
  var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
  var TD_days = "<td class='dpDayTD'>";
  var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var xTD = "</td>" + crlf;
  var DIV_title = "<div class='dpTitleText'>";
  var DIV_selected = "<div class='dpDayHighlight'>";
  var xDIV = "</div>";
 
  // start generating the code for the calendar table
  var html = TABLE;
 
  // this is the title bar, which displays the month and the buttons to
  // go back to a previous month or forward to the next month
  html += TR_title;
  html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "&lt;") + xTD;
  html += TD_title + DIV_title + monthArrayLong[ thisDay.getMonth()] + " " + thisDay.getFullYear() + xDIV + xTD;
  html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "&gt;") + xTD;
  html += xTR;
 
  // this is the row that indicates which day of the week we're on
  html += TR_days;
  for(i = 0; i < dayArrayShort.length; i++)
    html += TD_days + dayArrayShort[i] + xTD;
  html += xTR;
 
  // now we'll start populating the table with days of the month
  html += TR;
 
  // first, the leading blanks
  for (i = 0; i < thisDay.getDay(); i++)
    html += TD + "&nbsp;" + xTD;
 
  // now, the days of the month
  do {
    dayNum = thisDay.getDate();
    TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";
    
    if (dayNum == day)
      html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
    else
      html += TD + TD_onclick + dayNum + xTD;
    
    // if this is a Saturday, start a new row
    if (thisDay.getDay() == 6)
      html += xTR + TR;
    
    // increment the day
    thisDay.setDate(thisDay.getDate() + 1);
  } while (thisDay.getDate() > 1)
 
  // fill in any trailing blanks
  if (thisDay.getDay() > 0) {
    for (i = 6; i > thisDay.getDay(); i--)
      html += TD + "&nbsp;" + xTD;
  }
  html += xTR;
 
  // add a button to allow the user to easily return to today, or close the calendar
  var today = new Date();
  var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[ today.getMonth()] + " " + today.getDate();
  html += TR_todaybutton + TD_todaybutton;
  html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>this month</button> ";
  html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>close</button>";
  html += xTD + xTR;
 
  // and finally, close the table
  html += xTABLE;
 
  document.getElementById(datePickerDivID).innerHTML = html;
  // add an "iFrame shim" to allow the datepicker to display above selection lists
  adjustiFrame();
}


/**
Convenience function for writing the code for the buttons that bring us back or forward
a month.
*/
function getButtonCode(dateFieldName, dateVal, adjust, label)
{
  var newMonth = (dateVal.getMonth () + adjust) % 12;
  var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
  if (newMonth < 0) {
    newMonth += 12;
    newYear += -1;
  }
 
  return "<button class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</button>";
}


/**
Convert a JavaScript Date object to a string, based on the dateFormat and dateSeparator
variables at the beginning of this script library.
*/
function getDateString(dateVal)
{
  var dayString = "00" + dateVal.getDate();
  var monthString = "00" + (dateVal.getMonth()+1);
  dayString = dayString.substring(dayString.length - 2);
  monthString = monthString.substring(monthString.length - 2);
 
  switch (dateFormat) {
    case "dmy" :
      return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
    case "ymd" :
      return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
    case "mdy" :
    default :
      return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
  }
}


/**
Convert a string to a JavaScript Date object.
*/
function getFieldDate(dateString)
{
  var dateVal;
  var dArray;
  var d, m, y;
 
  try {
    dArray = splitDateString(dateString);
    if (dArray) {
      switch (dateFormat) {
        case "dmy" :
          d = parseInt(dArray[0], 10);
          m = parseInt(dArray[1], 10) - 1;
          y = parseInt(dArray[2], 10);
          break;
        case "ymd" :
          d = parseInt(dArray[2], 10);
          m = parseInt(dArray[1], 10) - 1;
          y = parseInt(dArray[0], 10);
          break;
        case "mdy" :
        default :
          d = parseInt(dArray[1], 10);
          m = parseInt(dArray[0], 10) - 1;
          y = parseInt(dArray[2], 10);
          break;
      }
      dateVal = new Date(y, m, d);
    } else if (dateString) {
      dateVal = new Date(dateString);
    } else {
      dateVal = new Date();
    }
  } catch(e) {
    dateVal = new Date();
  }
 
  return dateVal;
}


/**
Try to split a date string into an array of elements, using common date separators.
If the date is split, an array is returned; otherwise, we just return false.
*/
function splitDateString(dateString)
{
  var dArray;
  if (dateString.indexOf("/") >= 0)
    dArray = dateString.split("/");
  else if (dateString.indexOf(".") >= 0)
    dArray = dateString.split(".");
  else if (dateString.indexOf("-") >= 0)
    dArray = dateString.split("-");
  else if (dateString.indexOf("\\") >= 0)
    dArray = dateString.split("\\");
  else
    dArray = false;
 
  return dArray;
}

/**
Update the field with the given dateFieldName with the dateString that has been passed,
and hide the datepicker. If no dateString is passed, just close the datepicker without
changing the field value.

Also, if the page developer has defined a function called datePickerClosed anywhere on
the page or in an imported library, we will attempt to run that function with the updated
field as a parameter. This can be used for such things as date validation, setting default
values for related fields, etc. For example, you might have a function like this to validate
a start date field:

function datePickerClosed(dateField)
{
  var dateObj = getFieldDate(dateField.value);
  var today = new Date();
  today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
 
  if (dateField.name == "StartDate") {
    if (dateObj < today) {
      // if the date is before today, alert the user and display the datepicker again
      alert("Please enter a date that is today or later");
      dateField.value = "";
      document.getElementById(datePickerDivID).style.visibility = "visible";
      adjustiFrame();
    } else {
      // if the date is okay, set the EndDate field to 7 days after the StartDate
      dateObj.setTime(dateObj.getTime() + (7 * 24 * 60 * 60 * 1000));
      var endDateField = document.getElementsByName ("EndDate").item(0);
      endDateField.value = getDateString(dateObj);
    }
  }
}

*/
function updateDateField(dateFieldName, dateString)
{
  var targetDateField = document.getElementsByName (dateFieldName).item(0);
  if (dateString)
    targetDateField.value = dateString;
 
  var pickerDiv = document.getElementById(datePickerDivID);
  pickerDiv.style.visibility = "hidden";
  pickerDiv.style.display = "none";
 
  adjustiFrame();
  targetDateField.focus();
 
  // after the datepicker has closed, optionally run a user-defined function called
  // datePickerClosed, passing the field that was just updated as a parameter
  // (note that this will only run if the user actually selected a date from the datepicker)
  if ((dateString) && (typeof(datePickerClosed) == "function"))
    datePickerClosed(targetDateField);
}


/**
Use an "iFrame shim" to deal with problems where the datepicker shows up behind
selection list elements, if they're below the datepicker. The problem and solution are
described at:

http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx
http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx
*/
function adjustiFrame(pickerDiv, iFrameDiv)
{
  // we know that Opera doesn't like something about this, so if we
  // think we're using Opera, don't even try
  var is_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
  if (is_opera)
    return;
  
  // put a try/catch block around the whole thing, just in case
  try {
    if (!document.getElementById(iFrameDivID)) {
      // don't use innerHTML to update the body, because it can cause global variables
      // that are currently pointing to objects on the page to have bad references
      //document.body.innerHTML += "<iframe id='" + iFrameDivID + "' src='javascript:false;' scrolling='no' frameborder='0'>";
      var newNode = document.createElement("iFrame");
      newNode.setAttribute("id", iFrameDivID);
      newNode.setAttribute("src", "javascript:false;");
      newNode.setAttribute("scrolling", "no");
      newNode.setAttribute ("frameborder", "0");
      document.body.appendChild(newNode);
    }
    
    if (!pickerDiv)
      pickerDiv = document.getElementById(datePickerDivID);
    if (!iFrameDiv)
      iFrameDiv = document.getElementById(iFrameDivID);
    
    try {
      iFrameDiv.style.position = "absolute";
      iFrameDiv.style.width = pickerDiv.offsetWidth;
      iFrameDiv.style.height = pickerDiv.offsetHeight ;
      iFrameDiv.style.top = pickerDiv.style.top;
      iFrameDiv.style.left = pickerDiv.style.left;
      iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
      iFrameDiv.style.visibility = pickerDiv.style.visibility ;
      iFrameDiv.style.display = pickerDiv.style.display;
    } catch(e) {
    }
 
  } catch (ee) {
  }
 
}



function FillCountry(cboCountry, cboState, sDefaultCountry){
	var sDefaultCountry, sDefault, sCountry
	
	cboCountry.options.length=0
	for(i=0;i<sCountryString.split("|").length;i++){
		sCountry = sCountryString.split("|")[i].split(":")[0];
		sCountrys = sCountryString.split("|")[i].split(":")[1];

		if (sDefaultCountry == sCountry) {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
		}
		else {sDefault=false;}
		alert(sCountryString.split("|")[i].split(":")[0]);
		if (sDefault) {cboCountry.options[i]=new Option(sCountrys,sCountry,sDefault,sDefault);}
		else {cboCountry.options[i]=new Option(sCountryString.split("|")[i].split(":")[1],sCountryString.split("|")[i].split(":")[0]);}
	}
}
if (navigator.appName=="Netscape"){
isNav=true
}

function FillState(cboCountry, cboState, sDefaultState){
	var sDefaultState, sState, sDefault
		
	cboState.options.length=0
	for(i=0;i<sStateArray[cboCountry.selectedIndex].split("|").length;i++){
		sState = sStateArray[cboCountry.selectedIndex].split("|")[i];
		
		if(sDefaultState == sState) {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
		} 
		else {sDefault=false;}
		
		if(sDefault) {cboState.options[i]=new Option(sState,sState,sDefault,sDefault)}
		else {cboState.options[i]=new Option(sState,sState);}
	}
}

var sCountryString = "|Angola:Angola|Botswana:Botswana|Lesotho:Lesotho|Malawi:Malawi|Mauritius:Mauritius|Mozambique:Mozambique|Namibia:Namibia|Tanzania:Tanzania|South Africa:South Africa|Swaziland:Swaziland|Zambia:Zambia|Zimbabwe:Zimbabwe|Other Country:Outro País"
		
var sStateArray = new Array()
sStateArray[0]=""
sStateArray[1]="|Bengo|Benguela|Bie|Cabinda|Cuando Cubango|Cuanza Norte|Cuanza Sul|Cunene|Huambo|Huila|Luanda|Lunda Norte|Lunda Sul|Malanje|Moxico|Namibe|Uige|Zaire"
sStateArray[2]="|Central|Chobe|Ghanzi|Kgalagadi|Kgatleng|Kweneng|North-East|North-West|South-East|Southern"
sStateArray[3]="|Berea|Butha-Buthe|Leribe|Mafeteng|Maseru|Mohales Hoek|Mokhotlong|Qacha's Nek|Quthing|Thaba-Tseka"
sStateArray[4]="|Balaka|Blantyre|Chikwawa|Chiradzulu|Chitipa|Dedza|Dowa|Karonga|Kasungu|Likoma|Lilongwe|Machinga|Mangochi|Mchinji|Mulanje|Mwanza|Mzimba|Nkhata Bay|Nkhotakota|Nsanje|Ntcheu|Ntchisi|Phalombe|Rumphi|Salima|Thyolo|Zomba"
sStateArray[5]="|Agalega Islands|Black River|Cargados Carajos Shoals|Flacq|Grand Port|Moka|Pamplemousses|Plaines Wilhems|Port Louis|Riviere du Rempart|Rodrigues|Savanne"
sStateArray[6]="|Cabo Delgado|Gaza|Inhambane|Manica|Maputo|Nampula|Niassa|Sofala|Tete|Zambezia"
sStateArray[7]="|Caprivi|Erongo|Hardap|Karas|Khomas|Kunene|Ohangwena|Kavango|Omaheke|Omusati|Oshana|Oshikoto|Otjozondjupa"
sStateArray[8]="|Arusha|Dar es Salaam|Dodoma|Iringa|Kagera|Kigoma|Kilimanjaro|Lindi|Mara|Mbeya|Morogoro|Mtwara|Mwanza|Pemba North|Pemba South|Pwani|Rukwa|Ruvuma|Shinyanga|Singida|Tabora|Tanga|Zanzibar Central/South|Zanzibar North|Zanzibar Urban/West"
sStateArray[9]="|Eastern Cape|Free State|Gauteng|KwaZulu-Natal|Mpumalanga|North-West|Northern Cape|Limpopo Province|Western Cape"
sStateArray[10]="|Hhohho|Lubombo|Manzini|Shiselweni"
sStateArray[11]="|Central|Copperbelt|Eastern|Luapula|Lusaka|North-Western|Northern|Southern|Western"
sStateArray[12]="|Bulawayo|Harare|Manicaland|Mashonaland Central|Mashonaland East|Mashonaland West|Masvingo|Matabeleland North|Matabeleland South|Midlands"
sStateArray[13]="Outra Região"


function setcookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)
	+ ";expires="+expire.toGMTString();
}

function readcookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function translate(str){
	var a=str;
	a=a.replace(/é/g,'&eacute;');
	a=a.replace(/á/g,'&aacute;');
	a=a.replace(/ú/g,'&uacute;');
	a=a.replace(/í/g,'&iacute;');
	a=a.replace(/ó/g,'&oacute;');
	a=a.replace(/è/g,'&egrave;');
	a=a.replace(/à/g,'&agrave;');
	a=a.replace(/ù/g,'&ugrave;');
	a=a.replace(/ì/g,'&igrave;');
	a=a.replace(/ò/g,'&ograve;');
	a=a.replace(/ê/g,'&ecirc;');
	a=a.replace(/â/g,'&acirc;');
	a=a.replace(/û/g,'&ucirc;');
	
	a=a.replace(/î/g,'&icirc;');
	a=a.replace(/ô/g,'&ocirc;');
	a=a.replace(/ã/g,'&atilde;');
	a=a.replace(/õ/g,'&otilde;');
	a=a.replace(/ç/g,'&ccedil;');
	a=a.replace(/É/g,'&Eacute;');
	a=a.replace(/Á/g,'&Aacute;');
	a=a.replace(/Ú/g,'&Uacute;');
	a=a.replace(/Í/g,'&Iacute;');
	a=a.replace(/Ó/g,'&Oacute;');
	a=a.replace(/È/g,'&Egrave;');
	a=a.replace(/À/g,'&Agrave;');
	a=a.replace(/Ù/g,'&Ugrave;');
	a=a.replace(/Ì/g,'&Igrave;');
	a=a.replace(/Ò/g,'&Ograve;');
	a=a.replace(/Ê/g,'&Ecirc;');
	a=a.replace(/Â/g,'&Acirc;');
	a=a.replace(/Û/g,'&Ucirc;');
	a=a.replace(/Î/g,'&Icirc;');
	a=a.replace(/Ô/g,'&Ocirc;');
	a=a.replace(/Ã/g,'&Atilde;');
	a=a.replace(/Õ/g,'&Otilde;');
	a=a.replace(/Ç/g,'&Ccedil;');
	a=a.replace(/°/g,'&ordf;');
	a=a.replace(/º/g,'&ordf;');
	a=a.replace(/&/g,'|amp|');
	a=a.replace(/"/g,'|ghil|');
	a=a.replace(/#and#/g,'&');
	return a;
}

function tosec(sec,minut,ora,zi,luna,an){
	return (parseInt(zi)*86400)+(parseInt(luna)*86400*30)+(parseInt(an)*86400*30*365)+(parseInt(ora)*3600)+(parseInt(minut)*60)+(parseInt(sec));
}

function mktime() {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: baris ozdil
    // +      input by: gabriel paderni 
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: FGFEmperor
    // +      input by: Yannoo
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: jakes
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Marc Palau
    // *     example 1: mktime(14, 10, 2, 2, 1, 2008);
    // *     returns 1: 1201871402
    // *     example 2: mktime(0, 0, 0, 0, 1, 2008);
    // *     returns 2: 1196463600
    // *     example 3: make = mktime();
    // *     example 3: td = new Date();
    // *     example 3: real = Math.floor(td.getTime()/1000);
    // *     example 3: diff = (real - make);
    // *     results 3: diff < 5
    // *     example 4: mktime(0, 0, 0, 13, 1, 1997)
    // *     returns 4: 883609200
    // *     example 5: mktime(0, 0, 0, 1, 1, 1998)
    // *     returns 5: 883609200
    // *     example 6: mktime(0, 0, 0, 1, 1, 98)
    // *     returns 6: 883609200
    
    var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;
 
    if (argc > 0){
        d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
    }
 
    var dateManip = {
        0: function(tt){ return d.setHours(tt); },
        1: function(tt){ return d.setMinutes(tt); },
        2: function(tt){ var set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
        3: function(tt){ var set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
        4: function(tt){ return d.setDate(tt+mb); },
        5: function(tt){ return d.setYear(tt+ma); }
    };
    
    for( i = 0; i < argc; i++ ){
        no = parseInt(argv[i]*1);
        if (isNaN(no)) {
            return false;
        } else {
            // arg is number, let's manipulate date object
            if(!dateManip[i](no)){
                // failed
                return false;
            }
        }
    }
 
    return Math.floor(d.getTime()/1000);
}
