function getContactCities(a_intRegionID) {
	$('#divOfficeList').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');

	$.get('/index/offices/region/' + a_intRegionID, {}, function(a_objResponse){
		$('#divOfficeList').html('');
		$('#divOfficeList').html(a_objResponse);
		getContactInfo($('#divOfficeList ul li:first a').attr('rel'));
		hilteOfficeList($('#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>');

	$.get('/index/officesinfo/office/' + a_intOfficeID, {}, function(a_objResponse){
		$('#divOfficesR').html('');
		$('#divOfficesR').html(a_objResponse);

	}, 'text');
}

function getWorkCount(a_intOfficeID) {
	$('#divWorkContentR').html('<p align="center"><img src="/img/ajax-loader-transparent.gif" height="16" width="16" align="absmiddle" alt="Loading ..." /></p>');

	$.get('/index/thework/office/' + a_intOfficeID, {}, 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>');

	$.get('/index/viewwork/work/' + a_intWorkID, {}, function(a_objResponse){
		$('#divTheWorkR').html('');
		$('#divTheWorkR').html(a_objResponse);
	}, 'text');
}

function hiliteOfficeBubbles(a_intID) {
	$('#divOfficesL a').each(function(){
		if ($(this).attr('rel') == a_intID) {
			if (a_intID == 1) {
				$(this).addClass('aOfficeBubble1-JQ-ON');
				//$(this).addClass('aOfficeBubble1');
				//$(this).css({'background-image':'url(/img/bg/office_bubbles.jpg)', 'background-position':'-1569px 0'});
			}
			else if (a_intID == 2) {
				$(this).addClass('aOfficeBubble2-JQ-ON');
				//$(this).addClass('aOfficeBubble2');
				//$(this).css({'background-image':'url(/img/bg/office_bubbles.jpg)', 'background-position':'-1316px -37px'});
			}
			else if (a_intID == 3) {
				$(this).addClass('aOfficeBubble3-JQ-ON');
				//$(this).addClass('aOfficeBubble3');
				//$(this).css({'background-image':'url(/img/bg/office_bubbles.jpg)', 'background-position':'-799px -110px'});
			}
			else if (a_intID == 4) {
				$(this).addClass('aOfficeBubble4-JQ-ON');
				//$(this).addClass('aOfficeBubble4');
				//$(this).css({'background-image':'url(/img/bg/office_bubbles.jpg)', 'background-position':'-528px -261px'});
			}

			/*$(this).addClass('aOfficeBubble1');
			$(this).addClass('aOfficeBubble2');
			$(this).addClass('aOfficeBubble3');
			$(this).addClass('aOfficeBubble4');*/
		}

		else {
			/*$(this).addClass('aOfficeBubble1');
			$(this).addClass('aOfficeBubble2');
			$(this).addClass('aOfficeBubble3');
			$(this).addClass('aOfficeBubble4');*/
			//$(this).css('background-image','none');
			$(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).css({'background-color':'#000', 'color':'#FFF'});
			$(this).addClass('aNav-JQ-ON');
			$(this).removeClass('aNav-JQ-OFF');
		}

		else {
//			$(this).css({'background-color':'#FFF', 'color':'#757575'});
			$(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 hilteWorkCity(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).css({'background-image':'url(/img/bg/37x37_black_circle.gif)'});
			//$(this).hover(function() {$(this).css({'background-image':'url(/img/bg/37x37_red_circle.gif)'})});
			$(this).addClass('aWorkContentR-JQ-ON');
			$(this).removeClass('aWorkContentR-JQ-OFF');
		}

		else {
			//$(this).css({'background-image':'url(/img/bg/37x37_red_circle.gif)'});
			//$(this).hover(function() {$(this).css({'background-image':'url(/img/bg/37x37_black_circle.gif)'})});
			$(this).addClass('aWorkContentR-JQ-OFF');
			$(this).removeClass('aWorkContentR-JQ-ON');
		}
	});
}

$(document).ready(function() {
	swfobject.embedSWF("img/swf/clients.swf", "divBrandBubblesM", "517", "444", "9.0.0", "", {}, {}, {});   
	swfobject.embedSWF("img/swf/pixelBoard.swf", "divPixelBoard", "950", "444", "8.0.0", "", {}, {}, {});
	swfobject.embedSWF("img/swf/picMask.swf", "divFaceSWF", "306", "444", "9.0.0", "", {}, {}, {});
	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('/Offices');});
	$('#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('#divHebrew', 800); pageTracker._trackPageview('/?????');});

	$('#divNewsRList').jScrollPane();
	$('#divNav ul li a').each(function(){$(this).click(function(){hilteMainNav($(this).attr('rel'));});});
	$('#divOfficesL a').each(function(){$(this).click(function(){hiliteOfficeBubbles($(this).attr('rel'));});});

//	$('#divWorkContentL ul li a').each(function(){$(this).click(function(){hilteWorkCity($(this).attr('rel'));});});
	getWorkCount($('#divWorkContentL ul li:eq(1) a').attr('rel'));
	getContactCities(2);
	hiliteOfficeBubbles(4);
	hilteMainNav($('#divNav ul li:first a').attr('rel'));
	hilteWorkCity($('#divWorkContentL ul li:eq(1) a').attr('rel'));
});