﻿window.onload = __sageOnLoad;

function __sageOnLoad() 
{
	setCurrentDate();
	setCountrySelect();
}

function setCountrySelect()
{
	var cSelect;
	if (document.getElementById)
	    cSelect=document.getElementById('countrySelect');
	else if (document.all)
	    cSelect = document.all('countrySelect');
	if(cSelect)
	{
		cSelect=cSelect.options;
		var x = new Array('www.softline.co.za|Afrique du Sud',
		'www.sage.de|Allemagne',
		'www.sagesoftware.com|Amerique du Nord',
		'www.sageasiapac.com|Asie',
		'www.sagesoftware.com.au|Australie',
		'www.sage.at|Autriche',
		'www.sage.be|Belgique',
		'www.sagesoftware.com|Canada',
		'www.sagechina.cn|Chine',
		'www.sage.es|Espagne',
		'www.sage.fr|France',
		'www.sagesoftware.co.in|Inde',
		'www.sage.ie|Irlande',
		'www.me.sage.com|Moyen Orient',
		'www.sage.be|Pays Bas',
		'www.symfonia.pl|Pologne',
		'www.sage.pt|Portugal',
		'www.sage.co.uk|Royaume Uni',
		'www.sageschweiz.ch|Suisse');
		var j=0;
		for (var i=0;i<x.length;i++)
		{
			j=x[i].indexOf('|');
			cSelect[i+1] = new Option(x[i].substring(j+1),'http://'+x[i].substring(0,j));
		}
		cSelect[0].selected = true;
	}
}

function countryChange(selectObj)
{
	window.location.href = selectObj.options[selectObj.selectedIndex].value;
}

function setCurrentDate()
{
	var cDate;
	if (document.getElementById)
	    cDate=document.getElementById('sDate');
	else if (document.all)
	    cDate = document.all('sDate');
	if(cDate)
	{
    		var am = new Array('Janvier', 'F\u00e9vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao\u00fbt', 'Septembre', 'Octobre', 'Novembre', 'D\u00e9cembre');
    		var date = new Date();
		var d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
		var m = am[date.getMonth()];
		var y = date.getYear() < 1000 ? date.getYear() + 1900 : date.getYear();
		cDate.innerHTML = d + ' ' + m + ' ' + y;
	}	
}

function PMECboGoPage(elm)
{
    var url=elm.options[elm.selectedIndex].value;
    if(url!=null && url.length > 0)
    window.location.href = url;
}

function submitSearch(link)
{
var textsearch;
if (document.getElementById) 
    textsearch = document.getElementById('txtSearch').value;
else if (document.all)
    textsearch = document.all('txtSearch').value;
if(textsearch.length>2)
	document.location.href='http://www.sage.fr' + link + '&Search=' + textsearch;
}