//document.write("ñí_ó");
function getContactCities(a_intRegionID, a_strThisOffice) {
	$('#divOfficeList').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');
     //las peticiones ajax fueron modificadas, se le agrego a la url "index.php" al principio...por algun motivo el fichero .htacces no sobreescribe estas peticiones... (este cambio es momentario)
	$.get('/index.php/index/offices/region/' + a_intRegionID, {}, function(a_objResponse){
		var arrThisOffice = a_strThisOffice.split(',');

		$('#divOfficeList').html('');
		$('#divOfficeList').html(a_objResponse);

		if (a_intRegionID == arrThisOffice[0]) {
			$('#divOfficeList ul li a[rel=' + arrThisOffice[1] + ']').parent().remove();
			$("#divOfficeList ul li:first").before('<li><a class="aOfficeList-JQ-OFF" rel="' + arrThisOffice[1] + '" href="javascript:void(0);">' + arrThisOffice[2] + '</a></li>');//get(0)
			
			hilteOfficeList(arrThisOffice[1]);
			getContactInfo(arrThisOffice[1]);
		}

		else {
			hilteOfficeList($("#divOfficeList ul li:first a").attr('rel'));
			getContactInfo($("#divOfficeList ul li:first a").attr('rel'));
		}

		$('#divOfficeList ul li a').each(function(){$(this).click(function(){hilteOfficeList($(this).attr('rel')); getContactInfo($(this).attr('rel'))});});
		$('#divOfficeList').jScrollPane();
	}, 'text');
}

function getContactInfo(a_intOfficeID) {
	$('#divOfficesR').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');
    //las peticiones ajax fueron modificadas, se le agrego a la url "index.php" al principio...por algun motivo el fichero .htacces no sobreescribe estas peticiones... (este cambio es momentario)
	$.get('/index.php/index/officesinfo/office/' + a_intOfficeID, {}, function(a_objResponse){
		$('#divOfficesR').html('');
		$('#divOfficesR').html(a_objResponse);

	}, 'text');
}
//antes era a_intClientID, ahora es a_intCatID, debido a q ahora no se trabaja con clientes sino q con categorias
function getWorkCount(a_intCatID) {
	$('#divWorkContentR').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');
    //las peticiones ajax fueron modificadas, se le agrego a la url "index.php" al principio...por algun motivo el fichero .htacces no sobreescribe estas peticiones... (este cambio es momentario)
	$.get('/index.php/index/thework/cat/' + a_intCatID, {}, function(a_objResponse){
		$('#divWorkContentR').html('');
		$('#divWorkContentR').html(a_objResponse);
		getWorkInfo($('#divWorkContentR ul li:first a').attr('rel'));
		hilteWorkAction($('#divWorkContentR ul li:first a').attr('rel'));
		$('#divWorkContentR ul li a').each(function(){$(this).click(function(){hilteWorkAction($(this).attr('rel'));});});
	}, 'text');
}

function getWorkInfo(a_intWorkID) {
	$('#divTheWorkR').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');
     //las peticiones ajax fueron modificadas, se le agrego a la url "index.php" al principio...por algun motivo el fichero .htacces no sobreescribe estas peticiones... (este cambio es momentario)
	$.get('/index.php/index/viewwork/work/' + a_intWorkID, {}, function(a_objResponse){
		$('#divTheWorkR').html('');
		$('#divTheWorkR').html(a_objResponse);
		$('#divYTInfoL').jScrollPane();
		$('#divYTInfoLALT').jScrollPane();
	}, 'text');
}

function getPeopleBio(a_intPersonID) {
	$('#divPeopleRContent').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');
    //las peticiones ajax fueron modificadas, se le agrego a la url "index.php" al principio...por algun motivo el fichero .htacces no sobreescribe estas peticiones... (este cambio es momentario)
	$.get('/index.php/index/peoplebio/person/' + a_intPersonID, {}, function(a_objResponse){
		$('#divPeopleRContent').html('');
		//alert(a_objResponse);
		$('#divPeopleRContent').html(a_objResponse);
		$('#divPeopleRContent').jScrollPane();
	}, 'text');
}

function hiliteOfficeBubbles(a_intID) {
	$('#divOfficesL a').each(function(){
		if ($(this).attr('rel') == a_intID) {
			if (a_intID == 4) {
				$(this).addClass('aOfficeBubble1-JQ-ON');
			}
			else if (a_intID == 3) {
				$(this).addClass('aOfficeBubble2-JQ-ON');
			}
			else if (a_intID == 1) {
				$(this).addClass('aOfficeBubble3-JQ-ON');
			}
			else if (a_intID == 2) {
				$(this).addClass('aOfficeBubble4-JQ-ON');
			}
		}

		else {
			$(this).removeClass('aOfficeBubble1-JQ-ON');
			$(this).removeClass('aOfficeBubble2-JQ-ON');
			$(this).removeClass('aOfficeBubble3-JQ-ON');
			$(this).removeClass('aOfficeBubble4-JQ-ON');
		}
	});
}

function hilteMainNav(a_intID) {
	$('#divNav ul li a').each(function(){
		if ($(this).attr('rel') == a_intID) {
			$(this).addClass('aNav-JQ-ON');
			$(this).removeClass('aNav-JQ-OFF');
		}

		else {
			$(this).addClass('aNav-JQ-OFF');
			$(this).removeClass('aNav-JQ-ON');
		}
	});
}

function hilteOfficeList(a_intID) {
	$('#divOfficeList ul li a').each(function(){
		if ($(this).attr('rel') == a_intID) {
			$(this).addClass('aOfficeList-JQ-ON');
			$(this).removeClass('aOfficeList-JQ-OFF');
		}

		else {
			$(this).addClass('aOfficeList-JQ-OFF');
			$(this).removeClass('aOfficeList-JQ-ON');
		}
	});
}

function hilteWorkClient(a_intID) {
	$('#divWorkContentL ul li a').each(function(){
		if ($(this).attr('rel') == a_intID) {
			$(this).addClass('aWorkContentL-JQ-ON');
			$(this).removeClass('aWorkContentL-JQ-OFF');
		}

		else {
			$(this).addClass('aWorkContentL-JQ-OFF');
			$(this).removeClass('aWorkContentL-JQ-ON');
		}
	});
}

function hilteWorkAction(a_intID) {
	$('#divWorkContentR ul li a').each(function(){
		if ($(this).attr('rel') == a_intID) {
			$(this).addClass('aWorkContentR-JQ-ON');
			$(this).removeClass('aWorkContentR-JQ-OFF');
		}

		else {
			$(this).addClass('aWorkContentR-JQ-OFF');
			$(this).removeClass('aWorkContentR-JQ-ON');
		}
	});
}

function hiltePerson(a_intID) {
	if (!($.browser.msie && $.browser.version.substr(0,1)<7)) {
		$('#divPeopleM ul li a').each(function(){
			if ($(this).attr('rel') == a_intID) {
				$(this).addClass('aPeopleM-JQ-ON');
				$(this).removeClass('aPeopleM-JQ-OFF');
			}

			else {
				$(this).addClass('aPeopleM-JQ-OFF');
				$(this).removeClass('aPeopleM-JQ-ON');
			}
		});
	}
}

$(document).ready(function() {
	var arrThisOffice = strThisOffice.split(',');
	
	swfobject.embedSWF("/img/swf/pixelBoard.swf", "divPixelBoard", "950", "444", "8.0.0", "", {}, {}, {});
	swfobject.embedSWF("/img/swf/picMask.swf", "divFaceSWF", "306", "444", "8.0.0", "", {imagepath:"/img/swf/dude.jpg"}, {}, {})
	swfobject.embedSWF("/img/swf/grid.swf", "divBulbsSWF", "234", "444", "8.0.0", "", {}, {}, {})
	swfobject.embedSWF("/img/swf/fakeGif.swf", "divPSWF", "450", "444", "8.0.0", "", {}, {}, {})

	
	$('#aMN1').click(function(){$.scrollTo('#divIntro', 800); pageTracker._trackPageview('/Welcome');});
	$('#aMN2').click(function(){$.scrollTo('#divTheWork', 800); pageTracker._trackPageview('/TheWork');});
	$('#aMN3').click(function(){$.scrollTo('#divOffices', 800); pageTracker._trackPageview('/Worldwide');});
	$('#aMN4').click(function(){$.scrollTo('#divNews', 800); pageTracker._trackPageview('/News');});
	$('#aMN5').click(function(){$.scrollTo('#divContact', 800); pageTracker._trackPageview('/Contact');});
	$('#aMN6').click(function(){$.scrollTo('#divAbout', 800); pageTracker._trackPageview('/WhoWeAre');});
	$('#aMN7').click(function(){$.scrollTo('#divPeople', 800); pageTracker._trackPageview('/People');});
	
	
	$('#divNav ul li a').each(function(){$(this).click(function(){hilteMainNav($(this).attr('rel'));});});
	$('#divOfficesL a').each(function(){$(this).click(function(){hiliteOfficeBubbles($(this).attr('rel'));});});
	$('#divPeopleM ul li a').each(function(){$(this).click(function(){ getPeopleBio($(this).attr('rel')); hiltePerson($(this).attr('rel')); });});

	getWorkCount($('#divWorkContentL ul li:first a').attr('rel'))
	getContactCities(arrThisOffice[0], strThisOffice);
	hiliteOfficeBubbles(arrThisOffice[0]);
	getPeopleBio($('#divPeopleM ul li:first a').attr('rel'));
	hiltePerson($('#divPeopleM ul li:first a').attr('rel'));
	hilteMainNav($('#divNav ul li:first a').attr('rel'));
	hilteWorkClient($('#divWorkContentL ul li:first a').attr('rel'));

	$('#divPeopleMContent').jScrollPane();
	$('#divNewsRList').jScrollPane();
});