function updateSearch(obj){
	if(obj.value == 'Search by Keyword or Drawing#') obj.value = '';
}


function checkAll(obj,obj_name){
	var check_elements = document.getElementsByName(obj_name+'[]');

	for(i=0;i< check_elements.length;i++){
		if(obj.checked == true) check_elements[i].checked = true;
		else check_elements[i].checked = false;
	}
}


function toggleContainer(obj_id){
	var obj = document.getElementById(obj_id);
	if (obj.style.display == 'none'){
		obj.style.display = '';					
	}else{
		obj.style.display = 'none';
	}
}

function toggleContainerSearch(link_id, obj_id){
	var link = document.getElementById(link_id);
	var obj = document.getElementById(obj_id);
	if (obj.style.display == 'none'){
		obj.style.display = '';
		link.innerHTML = '[Show Less]';
		_gaq.push(["_trackEvent", "Long Description", "Click","Show More"]);
	}else{
		obj.style.display = 'none';
		link.innerHTML = '[Show More]';
		_gaq.push(["_trackEvent", "Long Description", "Click","Show Less"]);
	}
}

function removeRecord(ref_id){
	var msg = "Are you sure you want to remove this tool result?";
	if(confirm(msg)){
		document.getElementById('ref_id').value = ref_id;
		document.account.submit();
	}else return false;
}

function toggle_interactive(act){
	var tool_count = document.getElementById('tool_count').value;
	var objShow = document.getElementById('show_int_button');
	var objHide = document.getElementById('hide_int_button');
	if (act == 'hide'){
		objHide.style.display = 'none';
		objShow.style.display = '';
		for (var x=1;x<tool_count;x++){
			var obj = document.getElementById('expand_'+x);
			obj.style.display = 'none';
		}
	}else{
		objShow.style.display = 'none';
		objHide.style.display = '';
		for (var x=1;x<tool_count;x++){
			var obj = document.getElementById('expand_'+x);
			obj.style.display = '';
		}
	}
	return false;
}

function toggle_notes(act){
	var tool_count = document.getElementById('tool_count').value;
	var objShow = document.getElementById('show_notes_button');
	var objHide = document.getElementById('hide_notes_button');
	if (act == 'hide'){
		objHide.style.display = 'none';
		objShow.style.display = '';
		for (var x=1;x<=tool_count;x++){
			var obj = document.getElementById('expand_'+x);
			obj.style.display = 'none';
		}
	}else{
		objShow.style.display = 'none';
		objHide.style.display = '';
		for (var x=1;x<=tool_count;x++){
			var obj = document.getElementById('expand_'+x);
			obj.style.display = '';
		}
	}
	return false;
}

function openToolLink(obj){
	if(obj.value !=0) {
		window.open(obj.value);
		obj.selectedIndex=0;
	}
}

function cycle_products(){
	if (parseInt($("#cycle_products_counter").val()) == 1){
		$("#cycle_products_counter").val(parseInt($("#cycle_products_counter").val()) + 1);
		var pars = "request_type=cycle_products";
		xhr = $.ajax({
			url: 'ajax_cycle.php',
			type: 'POST',
			data: pars,
			dataType: 'html',
			timeout: 40000,
			error: function(){
				//na
			},
			success: function(html){
				if (html.length > 100) $("#products_container").empty().html(html);
			}
		});		
	}else if (parseInt($("#cycle_products_counter").val()) == 0) $("#cycle_products_counter").val(parseInt($("#cycle_products_counter").val()) + 1);

	if (parseInt($("#cycle_products_counter").val()) > 1){
		_gaq.push(['_setAccount', 'UA-3337392-1']);
		_gaq.push(['_trackPageview']);
		_gaq.push(['_trackPageview', 'cycle_products'])
	}
}

function cycle_solutions(){
	if (parseInt($("#cycle_solutions_counter").val()) == 1){
		$("#cycle_solutions_counter").val(parseInt($("#cycle_solutions_counter").val()) + 1);
		var pars = "request_type=cycle_solutions";
		xhr = $.ajax({
			url: 'ajax_cycle.php',
			type: 'POST',
			data: pars,
			dataType: 'html',
			timeout: 40000,
			error: function(){
				//na
			},
			success: function(html){
				if (html.length > 100) $("#solutions_container").empty().html(html);
			}
		});		
	}else if (parseInt($("#cycle_solutions_counter").val()) == 0) $("#cycle_solutions_counter").val(parseInt($("#cycle_solutions_counter").val()) + 1);

	if (parseInt($("#cycle_solutions_counter").val()) > 1){
		_gaq.push(['_setAccount', 'UA-3337392-1']);
		_gaq.push(['_trackPageview']);
		_gaq.push(['_trackPageview', 'cycle_solutions'])
	}
}

function cycle_apc(){
	if (parseInt($("#cycle_apc_counter").val()) == 1){
		$("#cycle_apc_counter").val(parseInt($("#cycle_apc_counter").val()) + 1);
		var pars = "request_type=cycle_apc";
		xhr = $.ajax({
			url: 'ajax_cycle.php',
			type: 'POST',
			data: pars,
			dataType: 'html',
			timeout: 40000,
			error: function(){
				//na
			},
			success: function(html){
				if (html.length > 100) $("#apc_container").empty().html(html);
			}
		});		
	}else if (parseInt($("#cycle_apc_counter").val()) == 0) $("#cycle_apc_counter").val(parseInt($("#cycle_apc_counter").val()) + 1);

	if (parseInt($("#cycle_apc_counter").val()) > 1){
		_gaq.push(['_setAccount', 'UA-3337392-1']);
		_gaq.push(['_trackPageview']);
		_gaq.push(['_trackPageview', 'cycle_apc'])
	}
}

function get_project_updates(){
	$("#project_updates_container").hide();
	$("#project_updates_container_loading").show();
	var pars = '';
	$.ajax({
		url: 'ajax_project.php?request_type=get_project_updates_all',
		type: 'POST', data: pars, dataType: 'html', timeout: 10000,
		error: function(){ $("#project_updates_container_loading").hide();},
		success: function(html){ get_project_updates_response(html); }
	});
}

function get_project_updates_response(html){
	if (html.substr(0,1) == 1){ //is valid
		data = html.slice(1);
		$("#project_updates_container").html(data);
	}
	$("#project_updates_container_loading").hide();
	$("#project_updates_container").show();
}

