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',
		'www.sage.com/yourbusiness/productsandservices/ourdistributionnetworks|Autres pays');
		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;
}

/* Lightbox Nos Sites */
    var currentSiteDetail = 1;

    function displayNosSites() {
        $('#control_overlay').fadeIn();
        $('#modalWindowNewOurSitesContent').fadeIn();
        var posLeft = Math.round(($(window).width() - $('#modalWindowNewOurSitesContent').width()) / 2);
        $('#modalWindowNewOurSitesContent').css({'left':posLeft+'px'});
        
        $('.ourSitesSmallThumbnailContainer').bind('mouseover', function() {
            $('#ourSitesDetailId-'+currentSiteDetail).hide();
            $('#ourSitesThumbnailId-'+currentSiteDetail).removeClass('ourSitesSmallThumbnailSelected');
            currentSiteDetail = $(this).attr('id').replace('ourSitesThumbnailId-', '');
            $('#ourSitesThumbnailId-'+currentSiteDetail).addClass('ourSitesSmallThumbnailSelected');
            $('#ourSitesDetailId-'+currentSiteDetail).show();
        });
    }

    function closeNosSites() {
        $('#control_overlay').fadeOut();
        $('#modalWindowNewOurSitesContent').fadeOut();
    }

$(document).ready(function(){
	setCountrySelect();
	
	$(".colorboxNosSites").colorbox({inline:true, transition:"fade", width:"1050px", height:"585px", href:"#modalWindowNewOurSitesContent"});
   
	$('.ourSitesSmallThumbnailContainer').bind('mouseover', function() {
		$('#ourSitesDetailId-'+currentSiteDetail).hide();
		$('#ourSitesThumbnailId-'+currentSiteDetail).removeClass('ourSitesSmallThumbnailSelected');
		currentSiteDetail = $(this).attr('id').replace('ourSitesThumbnailId-', '');
		$('#ourSitesThumbnailId-'+currentSiteDetail).addClass('ourSitesSmallThumbnailSelected');
		$('#ourSitesDetailId-'+currentSiteDetail).show();
	});
});

function searchSageCarrieres()
{
	var redirectURL = getURLSageCarrieres();
	if(location.pathname+location.search!=redirectURL)
		location.href = redirectURL;
}

function getURLSageCarrieres() 
{
	var sURL = window.document.URL.toString();
	var newURL;

	if (sURL.indexOf('?')>0)
	{
		var arrParams = sURL.split('?');
			
		var arrURLParams = arrParams[1].split('&');
		
		var arrParamNames = new Array(arrURLParams.length);
		var arrParamValues = new Array(arrURLParams.length);
		
		var i = 0;
		for (i=0;i<arrURLParams.length;i++)
		{
			var sParam =  arrURLParams[i].split('=');
			arrParamNames[i] = sParam[0];
			if (sParam[1] != '')
				arrParamValues[i] = unescape(sParam[1]);
			else
				arrParamValues[i] = '';
		}
		
		for (i=0;i<arrURLParams.length;i++)
		{
			if(arrParamValues[i]!=''&arrParamNames[i]!='Domaine'&arrParamNames[i]!='LieuTravail'&arrParamNames[i]!='TypeContrat'&arrParamNames[i]!='Toutes')
				newURL = '&' + arrParamNames[i]+'='+ arrParamValues[i]
		}
		if(sgcLieuTravail.value>-1)
			newURL=newURL+'&LieuTravail='+sgcLieuTravail.value;
		if(sgcTypeContrat.value>-1)
			newURL=newURL+'&TypeContrat='+sgcTypeContrat.value;
		if(sgcDomaine.value>-1)
			newURL=newURL+'&Domaine='+sgcDomaine.value;
		if(sgcLieuTravail.value>-1||sgcTypeContrat.value>-1||sgcDomaine.value>-1)
			newURL=newURL+'&Toutes=1';

		newURL = location.pathname + '?' + newURL.substring(1);
	}
	else
		newURL = location.pathname;
return newURL;
}
