//===============================================================
//======BOOKMART=================================================
//===============================================================
//Function bookmark favorites
function bookmark_en(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_fr(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Ajouter aux favoris";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_es(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_de(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_it(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}
//===============================================================
//==========MENU=================================================
//===============================================================
//For references: http://www.dynamicdrive.com/dynamicindex1/navigate1.htm
//and for all browsers: http://codingforums.com/archive/index.php?t-70090.html
//...see also for another way: http://www.developpez.net/forums/showthread.php?t=219099

//Functions menu

var head="display:'block'"

function change(t){
	t = (t) ? t : window.event ? window.event : null;
	if (!t) return;
	if(!document.all) {
		document.all = document.getElementsByTagName('*');
		var ti, i = 0;
		while (ti = document.all.item(i))
		ti.sourceIndex = i++;
	}
	var tel, tid;
	tel = (t.target) ? t.target : t.srcElement;
	tid = tel.id;
	if (tid=="foldheader") {
		var srcIndex = tel.sourceIndex;
		var nested = document.all[srcIndex+1];
		if (nested.style.display=="none") {
			nested.style.display='block';
		}
		else {
			nested.style.display="none";
		}
	}
}

document.onclick=change

// end menu
//===============================================================
//======SWAP THE PICTURES========================================
//===============================================================
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//===============================================================
//==========WINDOWS==============================================
//===============================================================
//Open window email without menu
function windowContact()
{
	winref = window.open("","winContact","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=780,left=100,top=10")
}

//Open window privacy policy without menu
function windowPrivacyP()
{
	winref = window.open("","winPrivacyP","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=750,left=100,top=10")
}

//Open window about us without menu
function windowAboutUs()
{
	winref = window.open("","winAboutUs","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=750,left=100,top=20")
}

//Open window ads without menu
function windowAds()
{
	winref = window.open("","winAds","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=650,left=100,top=20")
}

//Open window weather without menu
function windowWeather()
{
	winref = window.open("","winWeather","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=850,height=650,left=100,top=20")
}

//Open window quiz without menu
function windowQuiz()
{
	winref = window.open("","winQuiz","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=650,left=100,top=20")
}

//Open window default without menu
function windowDefault()
{
	winref = window.open("","winDefault","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=650,left=100,top=20")
}

//Open window Translate without menu
function windowTranslate()
{
	winref = window.open("","winTranslate","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=700,height=675,left=100,top=20")
}

//Open window SendFriend without menu
function windowSendfriend()
{
	winref = window.open("","winSendfriend","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,width=560,height=450,left=100,top=20")
}

//Open window Newsletter without menu
function windowNewsletter()
{
	winref = window.open("","winNewsletter","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=560,height=650,left=100,top=10")
}
//===============================================================
//==================SCRIPTS======================================
//===============================================================
/* Function to validate. */
function valid_fr(leform)
{
   if (leform.email.value=="")
    {
            alert("Champ 'E-mail' non renseigné");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_en(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' field empty");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Please type a correct e-mail address.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Please type a correct e-mail address.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Please type a correct e-mail address.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Please type a correct e-mail address.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Please type a correct e-mail address.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_es(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' es incorrecto");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("El email es incorrecto.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("El email es incorrecto.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("El email es incorrecto.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("El email es incorrecto.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("El email es incorrecto.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_it(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' č errato");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Il email č errato.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Il email č errato.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Il email č errato.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Il email č errato.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Il email č errato.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_de(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' ist falsch");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Das email ist falsch.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Das email ist falsch.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Das email ist falsch.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Das email ist falsch.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Das email ist falsch.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function popup(mylink, popupNews)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href,popupNews,'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,width=170,height=320,left=750,top=180')
return false;
}


//-----------------
// AUTOMATIC SUBMIT
//-----------------
function formHandler(form)
{
var URL = document.form.select.options[document.form.select.selectedIndex].value;
window.location.href = URL;
}

//-----------------
// GET TIME
//-----------------
function GetTime() 
{ 
var dt = new Date();
var def = dt.getTimezoneOffset()/60;

var gmt = (dt.getHours() + def);
var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());

var GMT_br =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_br.value = (IfZero(GMT_br) + ending);

var GMT_du =check24(((gmt + 4) > 24) ? ((gmt + 4) - 24) : (gmt + 4));
document.clock.GMT_du.value = (IfZero(GMT_du) + ending);

var GMT_fk =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_fk.value = (IfZero(GMT_fk) + ending);

var GMT_ge =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_ge.value = (IfZero(GMT_ge) + ending);

var GMT_ln =check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
document.clock.GMT_ln.value = (IfZero(GMT_ln) + ending);

var GMT_ma =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_ma.value = (IfZero(GMT_ma) + ending);

var GMT_mi =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_mi.value = (IfZero(GMT_mi) + ending);

var GMT_mr =check24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));
document.clock.GMT_mr.value = (IfZero(GMT_mr) + ending);

var GMT_ny =check24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));
document.clock.GMT_ny.value = (IfZero(GMT_ny) + ending);

var GMT_pa =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_pa.value = (IfZero(GMT_pa) + ending);

var GMT_sh =check24(((gmt + 8) > 24) ? ((gmt + 8) - 24) : (gmt + 8));
document.clock.GMT_sh.value = (IfZero(GMT_sh) + ending);

var GMT_sf =check24(((gmt + (24-7)) > 24) ? ((gmt + (24-7)) - 24) : (gmt + (24-7)));
document.clock.GMT_sf.value = (IfZero(GMT_sf) + ending);

var GMT_sy =check24(((gmt + 10) > 24) ? ((gmt + 10) - 24) : (gmt + 10));
document.clock.GMT_sy.value = (IfZero(GMT_sy) + ending);

setTimeout("GetTime()", 1000);
}

function IfZero(num) 
{
return ((num <= 9) ? ("0" + num) : num);
}

function check24(hour) 
{
return (hour >= 24) ? hour - 24 : hour;
}

// ======================

/* Manage BBcode tags */

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2) 
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) 
{
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
