//ABQIAAAAIztAdtihHUoO6Kz9UP_HUhRIBbgrDO3vmMzxO8jgNiRBE-0KfBSLsX9u8j7Ft7IRO32Z-K40jdEW-A
// <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAIztAdtihHUoO6Kz9UP_HUhRIBbgrDO3vmMzxO8jgNiRBE-0KfBSLsX9u8j7Ft7IRO32Z-K40jdEW-A" type="text/javascript"></script>

var chinaDomain = "http://www.barronpartners.cn";
var usDomain = "http://www.barronpartners.com";
var dev = ["http://barronpartners.com.dev", "http://barronpartners.cn.dev"];
var qa = ["http://barronpartners.us.hulinda.com", "http://barronpartners.cn.hulinda.com"];
var prod = ["http://www.barronpartners.com", "http://www.barronpartners.cn"];
var domain= window.location.href
if(domain.indexOf("dev")>=0) {chinaDomain = dev[1]; usDomain= dev[0]}
else if(domain.indexOf("hulinda")>=0){ chinaDomain = qa[1]; usDomain= qa[0]}
else { chinaDomain = prod[1]; usDomain = prod[0]}

/*** the following link ids map to their id.html file **/
var navLinks = ['home', 
                'mission', 'team', 
                'philosophy', 'industries', 'recent', 
                'public', 'private', 
                'investment', 'postInvestment', 'competitive', 
                'testimonial', 
                'contact','directions',
                'legal'];

var chineseNavLinks = ['chome', 
                       'cmission', 'cteam', 
                       'cphilosophy', 'cindustries', 'crecent', 
                       'cpublic', 'cprivate', 
                       'cinvestment', 'cpostInvestment', 'ccompetitive', 
                       'ctestimonial', 
                       'ccontact','cdirections',
                       'clegal'];

var toggleLinks = ['company', 'investmentFocus', 'investmentTypes', 'benefits', 'contactUs'];

/** testimonial.html **/
var testimonials = ['spu', 'chwy', 'ceu', 'chme', 'wpcs', 'aob', 'fsin','wyy', 'tstc', 'si', '819', '587', 'gu5', 'orpn', '1155', 'singyes','bspm'];

/** recent.html **/
//var recentImages = 	['chinawired.png', 'skypeople.png', 'fuda.png', 'sino.png', 'skypeople.png', 'duchn.png', 'cdt.png', 'cmc.png',
  //                 	'csi.png', 'blackmoon.png', 'pharmasave.png', 'widepoint.png', 'aobo.png', 'lattice.png', 'addvantage.png', 'pac.png'
    //               	];	

 var recentImages = 	['chinawind1.png', 'chme1.png', 'skypeople1.png', 'ceu1.png', 'kunda1.png', 'snen1.png', 'bspm1.png', 'opai1.png',
                   	'hhbpf1.png', 'tstc1.png', 'skbo1.png', 'aob1.png', 'blank.png', 'blank.png', 'blank.png', 'blank.png'
                   	];	


window.onload = function() {
	
	var href = window.location.href;
	if(href.indexOf(".cn") >= 0)
		populateContent('cn', '');
	else
		populateContent('us', '');
};

/** initialize the left nav links and the right region with ajax calls **/
function populateContent(country, pageid){
	
	var href = window.location.href;
	var page = pageid;	
	var leftnav = "leftnav.html";
	if(country =='cn')
		leftnav = "cleftnav.html";
	if (href.indexOf('#') < 0){
		page = 'home';
		if (country == 'cn')
			page = 'chome';
	}
	else{
		var pos = href.indexOf('#'); 
		page = href.substr(pos+1);
			//alert(page);
	}	
	var url1 =  leftnav;
	getLeftNav(url1);	
		
	var url2 = page + ".html";	
	getContent(url2);		
	
}

//register the left nav links to the getContent
function registerLeftNavLinks(){	
	navLinks.each(function(menu){ 
		if ($(menu))
			$(menu).observe('click', getRightContent); 
	});
	chineseNavLinks.each(function(menu){ 
		//alert(menu.id)
		if ($(menu))
		$(menu).observe('click', getRightContent); 
	});
}


function getRightContent(event){
	var ele = Event.element(event);
	var url = ele.id +".html";
	//alert(url)
	getContent(url);
	highlightSelectedLink(ele.id);
	
}

/** translate the page to English or Chinese **/
function translateContent(country, page){
	var location = window.location.href; 	
	var newLocation = usDomain;
	if(country == 'cn')
		newLocation = chinaDomain;
	window.location = newLocation + "/" + "index.html#" + page;		
	
}

/** retrieve the content and display in the right region **/
function getContent(url){
	var ar = new Ajax.Request( url, { 
		contentType: 'application/json;charset=utf-8',
		method: 'get',
		onSuccess: function(transport){
						$('right_content').innerHTML = transport.responseText; 
						$('right_content').appear(); 
						if(url=="recent.html"|| url =="crecent.html")
						show_page('1');
		},
		onFailure: function(transport){$('right_content').innerHTML = "<p 'style=color:red'><b>Error Loading page.</b></p>"; }
	});
	
}
function getLeftNav(url){
	var ar = new Ajax.Request( url, { 
		contentType: 'application/json;charset=utf-8',
		method: 'get',
		onSuccess: function(transport){$('left_nav').innerHTML = transport.responseText; $('left_nav').appear(); registerLeftNavLinks();},
		onFailure: function(transport){$('left_nav').innerHTML = "<p 'style=color:red'><b>Error Loading page.</b></p>"; }
	});		
}

function toggle_sublinks(id)
{

	toggleLinks.each(function(item){
			if (id != item && $(item).style.display != 'none')
				Effect.toggle($(item), 'slide');	
	});
	
	
	if( id !='chome' && id!='home' && id!='ctestimonial' && id !='testimonial' )
		Effect.toggle($(id), 'slide'); 	
	return false;	
}

function highlightSelectedLink(id){
	
	navLinks.each(function(menu){ 
		if ($(menu))
			$(menu).style.color= '#333333';		
	});
	chineseNavLinks.each(function(menu){ 
		//alert(menu.id)
		if ($(menu))
			$(menu).style.color= '#333333'; 
	});

	if ( $(id) ) $(id).style.color = 'red';

	//reset the legal footer color to white
	if ($('legal')) $('legal').style.color = 'white'; 
	if ($('clegal')) $('clegal').style.color = 'white'; 
}

/*** recent.html paging **/
function show_page(pageNum){	
	//$('recent_invest_holder').style.display = "none";		
	var recentDivs = $$('#recent_invest_holder div');
	//alert("in");	
	/*recentDivs.each(function(div, index){
			var pos = index + parseInt(pageNum-1)*8;
			if( recentImages[pos] != "blank.png" ){
				//alert(recentImages[index])
				div.innerHTML = "<img src='images/" + recentImages[pos] + "' />";				
				div.appear();
			}else
				div.hide();
			
	});*/
	if(pageNum =='1'){		
	$('recent_invest_holder_page1').show();
	$('recent_invest_holder_page2').hide();
	}else
	{
	$('recent_invest_holder_page1').hide();
	$('recent_invest_holder_page2').show();		
	}
	//new Effect.Appear('recent_invest_holder', {duration:2});
}

function createPageLinks(){
	var size= recentImages.size();
	var pages = size/8;
	if ( size > pages*8)
		pages +=1; 
	var links = "";
	for (var i=1; i<= pages; i ++){
		links += " <a href='javascript:show_page(" + i + ")'>" + i + "</a> ";
	}
	if($('links')){
		$('links').update(links);
	}
}

/** team.html **/
function show_Bio(name){
	var people = ['andrew', 'olga', 'rebecca', 'alana', 'fernando', 'simon', 'rongyu', 'winnie', 'teresa', 'natalie'];

	
	for( var i=0; i< people.size(); i++){
		/*$(people[i]).hide();
		$('bioPhoto').appear();
		$('placeHolder').appear();*/
		$('us_side').hide();
		$('china_side').hide();
		$('hand').hide();
		$('bio_holder').appear();
		if( name == people[i] ){	
			$('bioPhoto').innerHTML = "<img src='images/" + people[i]+ "B.jpg' />";
			var tid = name+"T";
			var cid = name+"C";
			$('titleHeader').innerHTML = $(tid).innerHTML;
			$('bioContent').innerHTML =  $(cid).innerHTML;
			//$('bio_holder').appear();
		}		
	}		
}
function back_to_team(){
	$('bio_holder').hide();
	$('us_side').appear();
	$('hand').appear();
	$('china_side').appear();
	
}


/** testimonial.html paging **/
function back_to_testi(){
	testimonials.each(function(testi){
		if ($(testi) != null)
			$(testi).hide();	
	});
	$('testi_details').hide();
	$('testi_list').appear();

}
function show_testimonial(ticker){
	$('testi_list').hide();
	$('testi_details').show();
	$(ticker).appear();	
}

/** directions.html paging**/
function show_map(country){
		if(country == 'cn'){
			$('directions_holder').hide();
			$('cnmap').appear({duration: 2});
		}
		else
		{
			$('directions_holder').hide();
			$('usmap').appear({duration: 2});			
		}
}
function close_map(country){
	if(country == 'cn'){
		$('cnmap').hide();
		$('directions_holder').appear({duration: 2});
	}
	else
	{
		$('usmap').hide();
		$('directions_holder').appear({duration: 2});			
	}	
}

/** legal.html paging **/
function show_legal(pageNum){
	if(pageNum =='1'){
		$('legal_content2').hide();
		$('legal_content').appear({duration:2});		
	}
	else
	{
		$('legal_content').hide();
		$('legal_content2').appear({duration:2});
	}
}



