/*
function GetXmlHttpObject() {


var xmlHttp=null;

try {  xmlHttp=new XMLHttpRequest();  }    // Firefox, Opera 8.0+, Safari
  catch (e) {
 	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } // Internet Explorer 
  catch (e)  {      
  			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  			 }
	}

return xmlHttp;
	
}
*/
//----------------------------------------------------------------------------------------

var no_search=0;

function list_cases(){
	
	$(document).ready(function(){
		//add loader---
		$('#content_list_td table tr:last').html('<td colspan="3" class="case_td" align="center"><img src="/core/graphics/ajax-loader/ajax-loader-circle.gif"></td>');
		//----
		var itype 				= $('#itype').val();
		
		
		if($('#scope').val()){
			 var scope 			= $('#scope').val();
		}
		
		if( $('#year\\(date\\)').val() ){
			var year 				= $('#year\\(date\\)').val();
		}
		
		var country 			= $('#country').val();
		var case_search 	= $('#search').val();
		var tag_search 		= $('#search_tag').val();
		var selected_lang = $('#lang_id').val();

		var search_type 	= $('#search_type').val();

		if(case_search == search_default){
			case_search = '';
		}

		if(case_search || search_type == 'content'){
			$('#type_tag_div').hide();
	}
		
	if( $('#search').val() ==	 ''){
		if(no_search >1){
			$('#search').val(search_default);
			no_search = 0;
		}else{
			no_search++;
		}
	}else{
		no_search = 0;
	}
	
	//bulid url-------------------	
	var last_path = '';
	var path_name = document.location.pathname.split('/');
	var build_path = '';
		
	while(path_name.length){
		
		next_path = path_name.shift();
		if( (next_path.length > 2 && next_path.indexOf('.') < 0 ) || ( last_path == 'press') ){
			build_path = build_path + '/' + next_path;
		}
		last_path = next_path;
		
	}
	//-------------------------
	
	
	$.post(build_path+'/inc/content_list.php',{
					'ax_scope':scope,
					'ax_year':year,
					'ax_itype':itype,
					'ax_country':country,
					'search':case_search,
					'tag_search':tag_search,
					'search_type':search_type,
					'lang':selected_lang },function(data){
						
						$('#content_list_td').html(data);
						
						
						
					}
				);
	
	
	
	});
	/*
	var itype 				= document.getElementById('itype').value;
	if(document.getElementById('scope')){
	var scope 				= document.getElementById('scope').value;
	}
	if(document.getElementById('year(date)')){
	var year 				= document.getElementById('year(date)').value;
	}
	var country 			= document.getElementById('country').value;
	var case_search 	= document.getElementById('search').value;
	var tag_search 		= document.getElementById('search_tag').value;
	var selected_lang = document.getElementById('lang_id').value;

	var search_type 	= document.getElementById('search_type').value;

	if(case_search == search_default){
		case_search = '';
	}

	if(case_search || search_type == 'content'){
		document.getElementById('type_tag_div').style.display= 'none';
	}
		
	if(document.getElementById('search').value ==	 ''){
		if(no_search >1){
			document.getElementById('search').value = search_default;
			no_search = 0;
		}else{
			no_search++;
		}
	}else{
		no_search = 0;
	}
	*/
	
	
					
					
					
					
/*
	var xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)  {
  	alert ("Your browser does not support AJAX!");
  	return;
  } 
  
  xmlHttp.onreadystatechange = function(){
				
			if(xmlHttp.readyState==4) {
     		if(xmlHttp.responseText){
     		
     			document.getElementById('content_list_td').innerHTML=xmlHttp.responseText;
     			//document.getElementById('type_tag_div').innerHTML='';
     			//var itype = document.getElementById('itype').value;
     			   		
    		}
  		}
	}

	var url="inc/content_list.php?";
			url=url+"ax_scope="+scope;
			url=url+"&ax_year="+year;
			url=url+"&ax_itype="+itype;
			url=url+"&ax_country="+country;
			url=url+"&search="+case_search;
			url=url+"&tag_search="+tag_search;
			url=url+"&search_type="+search_type;
			url=url+"&lang="+selected_lang;
			url=url+"&sid="+Math.random();

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
*/
}

function clearDefault(){
	
	if(document.getElementById('search').value == search_default){
		document.getElementById('search').value = '';
	}
	
	
}

function reset_search(){

	document.getElementById('search').value = search_default;
	document.getElementById('search_type').value = 'content';
	document.getElementById('itype').value = '0';
	document.getElementById('country').value ='0';
	list_cases();

	return false;

}
