function chooseType(id){
	document.getElementById('searchTypeValue').value = id;
	document.getElementById('searchTypeMenu_1').className = '';
	document.getElementById('searchTypeMenu_2').className = '';
	document.getElementById('searchTypeMenu_'+id).className = 'checked';
	document.getElementById('searchTypeIcon').src = 'http://graphics.suite101.com/icon_searchfilter_'+id+'.gif';
	toggleSearchTypes();
}

function toggleSearchTypes(){
	var id = document.getElementById('searchTypeValue').value;
	if(document.getElementById('searchTypes').style.visibility != 'visible'){
		document.getElementById('searchTypeIcon').src = 'http://graphics.suite101.com/icon_searchfilter_'+id+'_active.gif';
		document.getElementById('searchTypes').style.visibility = 'visible';
	}else{
		document.getElementById('searchTypeIcon').src = 'http://graphics.suite101.com/icon_searchfilter_'+id+'.gif';
		document.getElementById('searchTypes').style.visibility = 'hidden';
	}
} var timeout	= 500;
var closetimer	= 0;
var prev_dropdown = 0;
var menu_active = 0;

//activate or deactive Top Nav
function toggleTopNav(dropdown){
	if (menu_active){
		menu_active = 0;
		closeTopNav();
	}else{
		menu_active = 1;
		openTopNav(dropdown);
	}
	clearSelection();
}

//open Top Nav heading
function openTopNav(dropdown){
	if (menu_active){
		cancelCloseTopNavTime();
		if(prev_dropdown) closeTopNav();
		if(document.getElementById(dropdown)) document.getElementById(dropdown).className = 'topnav_dropdown_visable';
		if(document.getElementById(dropdown+'_heading')) document.getElementById(dropdown+'_heading').className = 'topnav_heading_selected';
		prev_dropdown = dropdown
		menu_active = 1;
	}
}

// Close Top Nav heading
function closeTopNav(){
	if(prev_dropdown){
		if(document.getElementById(prev_dropdown)) document.getElementById(prev_dropdown).className = 'topnav_dropdown_hidden';
		if(document.getElementById(prev_dropdown+'_heading')) document.getElementById(prev_dropdown+'_heading').className = 'topnav_heading';
		prev_dropdown = 0
		menu_active = 0;
	}
}

//close Timer
function closeTopNavTime(){
	closetimer = window.setTimeout(closeTopNav, timeout);
}

// cancel close timer
function cancelCloseTopNavTime(){
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

//open Sub Nav heading
function openSubNav(subnav){
	if(document.getElementById(subnav+'_heading')) document.getElementById(subnav+'_heading').className = 'subnav_heading_selected';
	if(document.getElementById(subnav)) document.getElementById(subnav).className = 'subnav_dropdown_visable';
}

//close Sub Nav heading
function closeSubNav(subnav){
	if(document.getElementById(subnav+'_heading')) document.getElementById(subnav+'_heading').className = 'subnav_heading';
	if(document.getElementById(subnav)) document.getElementById(subnav).className = 'subnav_dropdown_hidden';
}

// stops text from being selected when double clicking it
function clearSelection() {
	var sel;
	if(document.selection && document.selection.empty){
		document.selection.empty() ;
	}else if(window.getSelection) {
		sel=window.getSelection();
		if(sel && sel.removeAllRanges)
			sel.removeAllRanges();
   }
} function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}
var http = createRequestObject();

function ajax(serverFile,target,popup) {
	if (popup && popup.length>=1) { 
		if (navigator.appName=="Netscape")
			winW = window.innerWidth;
		if (navigator.appName.indexOf("Microsoft")!=-1) 
			winW = document.body.clientWidth;

		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0){
			if (window.pageYOffset)
				ScrollTop = window.pageYOffset;
			else
				ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
		http.open("GET", '/ajax/'+serverFile+'&winW='+winW+'&scrollTop='+ScrollTop, true);
	} else {
		http.open("GET", '/ajax/'+serverFile, true);
	}
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
					document.getElementById(target).innerHTML = http.responseText;
				}
	}
	http.send(null);
}

function ajaxPost(serverFile,params,target,popup) {
	if (popup && popup.length>=1) { 
		if (navigator.appName=="Netscape")
			winW = window.innerWidth;
		if (navigator.appName.indexOf("Microsoft")!=-1) 
			winW = document.body.clientWidth;

		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0){
			if (window.pageYOffset)
				ScrollTop = window.pageYOffset;
			else
				ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
		params = params+'&winW='+winW+'&scrollTop='+ScrollTop;
	}
	
	http.open("POST", '/ajax/'+serverFile, true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
					document.getElementById(target).innerHTML = http.responseText;
				}
	}
	http.send(params);

} /* GCA - google custom ads */

var global_google_ads = new Array;
var gca = new Object ;
gca.ad_classes = '' ;
gca.ad_set_classes = '' ;
gca.ad_set_box_classes = '' ;
gca.ad_width = 336 ;
gca.start_pos = 0 ;
gca.ad_style = 1 ;

function google_ad_request_done(google_ads) { // called by google syndication script include
	if (google_ads.length == 0) {
		return;
	}

	global_google_ads = google_ads;
	return;
}

function gca_process_ad_unit(ad_index) {
	var s = '' ;
	switch(gca.ad_style) {
		case 1 :   // vertical -- case 2 to be horizontal
			s += 	
					'<div style="width:' + gca.ad_width + 'px; ">' +
					'<a href="' + global_google_ads[i].url + '" target="_blank">' +
						global_google_ads[i].line1 + 
					'</a>' + 
					'<br/>' +
					global_google_ads[i].line2 + 
					' ' +
					global_google_ads[i].line3 + 
					'<br/>' +
					'<a href="' + global_google_ads[i].url + '" target="_blank" style=" text-decoration:none; color:green; font-size:9pt; font-weight:normal;">' + 
						global_google_ads[i].visible_url + 
					'</span></a>' +
					'</div>' +
					'<br/>';
				
		break ;

		case 2 :   // horizontal 
			s += 	
					'<div style="width:' + gca.ad_width + 'px; float:left;">' +
						'<a href="' + global_google_ads[i].url + '" target="_blank">' +
							global_google_ads[i].line1 + 
						'</a>' + 
						'<br/>' +
						global_google_ads[i].line2 + 
						' ' +
						global_google_ads[i].line3 + 
						'<br/>' +
						'<a href="' + global_google_ads[i].url + '" target="_blank" style=" text-decoration:none; color:green; font-size:9pt; font-weight:normal;">' + 
							global_google_ads[i].visible_url + 
						'</span></a>' +
					'</div>';
				
		break ;
		
		case 3 :   // horizontal 
			s += 	
					'<li>' +
						'<a href="' + global_google_ads[i].url + '" target="_blank" style="font-weight:bold;">' +
							global_google_ads[i].line1 + 
						'</a>' + 

						global_google_ads[i].line2 + 
						' ' +
						global_google_ads[i].line3 + 
						'<br/>' +
						'<a href="' + global_google_ads[i].url + '" target="_blank">' + 
							global_google_ads[i].visible_url + 
						'</a>' +
					'</li>';
				
		break ;
		
		case 4 :   // horizontal 
			s += 	
					'<div style="margin-bottom:3px">' +
						'<a href="' + global_google_ads[i].url + '" target="_blank">' +
							global_google_ads[i].line1 + 
						'</a>' + ' ' +
						global_google_ads[i].line2 + 
						' ' +
						global_google_ads[i].line3 + ' ' +
						'<a href="' + global_google_ads[i].url + '" target="_blank" style=" text-decoration:none; color:green; font-size:9pt; font-weight:normal;">' + 
							global_google_ads[i].visible_url + 
						'</span></a>' +
					'</div>';
				
		break ;
		
		case 5 :   // horizontal 
			s += 	
					'<div style="width:' + gca.ad_width + 'px; float:left; margin-bottom:10px;">' +
						'<a href="' + global_google_ads[i].url + '" target="_blank">' +
							global_google_ads[i].line1 + 
						'</a>' + 
						'<br/>' +
						global_google_ads[i].line2 + 
						' ' +
						global_google_ads[i].line3 + 
						'<br/>' +
						'<a href="' + global_google_ads[i].url + '" target="_blank" style=" text-decoration:none; color:green; font-size:9pt; font-weight:normal;">' + 
							global_google_ads[i].visible_url + 
						'</span></a>' +
					'</div>';
				
		break ;
		
	} 
	
	
	return s ;
} 


function gca_process_ad_units(ad_count) { 
	var s = '';
	var for_start = -1;
	var for_end = 0;
	if (global_google_ads.length >= gca.start_pos) {
		for_start = gca.start_pos;
		if (global_google_ads.length >= gca.start_pos+ad_count) {
			for_end = gca.start_pos+ad_count ;
			gca.start_pos += ad_count ;
		} else {
			for_end = global_google_ads.length ;
			gca.start_pos += global_google_ads.length - gca.start_pos ;
		}
	}

	if (for_start >= 0) {
		for(i=for_start; i < for_end; ++i) {
			s += gca_process_ad_unit(i) ;
		}
	}
	
	gca.ad_classes = '' ;
	return s ;
}

function gca_display_ad_set(s) { 
	document.write(s);
}
function gca_display_nav_ad_set(s) { 
	document.write(s);
}

function gca_process_ad_set_label(s) {  //style="padding-bottom:' + gca.ad_container_pad + 'px"
	s = '<div><a href=\"' + google_info.feedback_url + '\" style="font-size:8pt;color:#888888;text-decoration:none; font-weight:normal;" target="_blank">Annonces Google</a></div>' + 
		'<div class="g_ad_bottomSpacer_small g_ad_topSpacer ' + gca.ad_set_box_classes + '" >' +
			s +
		'</div>' ;	
	gca.ad_set_box_classes = '' ;  //default for next time
	return s ;
}
function gca_process_nav_ad_set_label(s) {  //style="padding-bottom:' + gca.ad_container_pad + 'px"
	s = '<div class="adsbygoogle_label"><a href=\"' + google_info.feedback_url + '\" target="_blank"><span style="color:#888888;">Annonces Google</span></a></div>' +
		'<ul>' +
			s +
		'</ul>' ; 	
	gca.ad_set_box_classes = '' ;  //default for next time
	return s ;
}



function gca_process_ad_set_container(s) {
	s = '<div class="' + gca.ad_set_classes + '">' +
			s +
		'</div>' ;
	gca.ad_set_classes = '' ;
	return s ;
}
function gca_process_nav_ad_set_container(s) {
	s = '<div class="nav">' +
			s +
		'</div>' ;
	gca.ad_set_classes = '' ;
	return s ;
}


function create_google_ad_set(ad_count) { 
	var s = gca_process_ad_units(ad_count) ; 
	
	if (s != '') {
		s = gca_process_ad_set_label(s);
		s = gca_process_ad_set_container(s);
		gca_display_ad_set(s);
	}
	
}
function create_google_nav_ad_set(ad_count) { 
	var s = gca_process_ad_units(ad_count) ; 
	
	if (s != '') {
		s = gca_process_nav_ad_set_label(s);
		s = gca_process_nav_ad_set_container(s);
		gca_display_nav_ad_set(s);
	}
	
} 

