

////////////////////////////current con/////////////////////////////
////////////////////////////current con/////////////////////////////


$(".num_con_search_new").live("click",function(){

//alert("s");

//alert(current_con);
//alert(total_con);



$(".num_con_search_new").removeClass("num_active");
$(this).addClass("num_active");

current_con=$(this).attr("alt");




table=$("#table_name").html();
search_field=$("#search_field").val();
search_field_type=$("#search_field option:selected").attr("type");
search_type=$("#search_type").val();


if($("#search_text_options").val()=="" || $("#search_text_options").val()==null){
search=$("#search_text").val();	
}else{
search=$("#search_text_options").val();	
}

var_encrypt='';
$('.encrypt_var').each(function(){
var_encrypt+=$(this).attr('exam_id')+","+$(this).val()+"####";
	
});


end=(parseInt(current_con)* parseInt(num_rows))-1;
start=parseInt(end)-(parseInt(num_rows)-1);
current_mod=(current_con-1)%max_con;
num_rows=$("#rows_num").val();




$.post("decrypt.php",{

	value:$("#table_name").html()

},function(page){
//alert(page);	

page="load_"+page+"_search.php";


$("#load_wait").show();

end=num_rows;


//alert(sort);
//alert(sort_by);
////alert(search_field);
//alert(search_field_type);
//alert(search_type);
//alert(search);
//alert(table);
//alert(num_rows);
//alert(current_con); 
////alert(total_con);
//alert(num_rows);	
//alert("current_con"+current_con);
//alert("max_con"+max_con);





$("#load_wait").show();

//alert("num_rows"+num_rows);

$.post(page,{
"table":table,		
"start":start ,
"var_encrypt":var_encrypt,
"num_rows":num_rows ,
'search':search ,
'search_field':search_field ,
'search_field_type':search_field_type ,
'search_type':search_type ,
'sort':sort ,
'sort_by':sort_by  ,
'var_encrypt' : var_encrypt


},function(data){
$("#load_wait").hide();

all_data=data.split('####');


$("#load_view").html(all_data[0]);

total_num_rows=all_data[1];

//alert(num_rows);
//alert(all_data[1]);






});




});











});





////////////////////////////next_search/////////////////////////////
////////////////////////////next_search/////////////////////////////


$("#next_num_search_new").live("click",function(){

total_con=$("#num_rows").text()/$("#rows_num").val();

//alert(current_con);
//alert(total_con);

if(current_con<total_con){



current_con++;




//alert("jj");


$table=table=$("#table_name").html();
search_field=$("#search_field").val();
search_field_type=$("#search_field option:selected").attr("type");
search_type=$("#search_type").val();


if($("#search_text_options").val()=="" || $("#search_text_options").val()==null){
search=$("#search_text").val();	
}else{
search=$("#search_text_options").val();	
}


var_encrypt='';



$('.encrypt_var').each(function(){
var_encrypt+=$(this).attr('exam_id')+","+$(this).val()+"####";
	
});

end=(parseInt(current_con)* parseInt(num_rows))-1;
start=parseInt(end)-(parseInt(num_rows)-1);
current_mod=(current_con-1)%max_con;
num_rows=$("#rows_num").val();




$.post("decrypt.php",{

	value:$("#table_name").html()

},function(page){
//alert(page);	

page="load_"+page+"_search.php";


$("#load_wait").show();

end=num_rows;


//alert(sort);
//alert(sort_by);
////alert(search_field);
//alert(search_field_type);
//alert(search_type);
//alert(search);
//alert(table);
//alert(num_rows);
////alert(current_con);
////alert(total_con);
//alert(num_rows);	
//alert("current_con"+current_con);
//alert("max_con"+max_con);
//alert(var_encrypt);


current_mod=(current_con)%max_con;

//alert(current_mod);


//فى حالة عدم وجود الرقم التالى
if(current_mod!=0){
$(".num_con_search_new").removeClass("num_active");
$("#num_con_search_new"+current_con).addClass("num_active");
$("#next_num_search_new").attr("alt",parseInt($("#next_num_search_new").attr("alt"))-1);	
$("#prev_num_search_new").attr("alt",parseInt($("#prev_num_search_new").attr("alt"))-1);

//alert("xx");
}else{
//alert("xxx");
from=current_con ;
to=parseInt((current_con))+parseInt((max_con))-1;	
//alert(from);
//alert(to);
$(".num_con_search_new").show();
for(i=from;i>=to;i--){
before=parseInt(i)+parseInt(max_con);

$("#num_con_search_new"+before).attr("alt",i);
$("#num_con_search_new"+before).text(i);
$("#num_con_search_new"+before).attr("id","num_con_search_new"+i);	

if(i>total_con){ $("#num_con_search_new"+i).hide(); }
}

$(".num_con_search_new").removeClass("num_active");
$("#num_con_search_new"+current_con).addClass("num_active");

}




$("#load_wait").show();

//alert("num_rows"+num_rows);

$.post(page,{
"table":table,		
"start":start ,
"var_encrypt":var_encrypt,
"num_rows":num_rows ,
'search':search ,
'search_field':search_field ,
'search_field_type':search_field_type ,
'search_type':search_type ,
'sort':sort ,
'sort_by':sort_by 


},function(data){
$("#load_wait").hide();

all_data=data.split('####');


$("#load_view").html(all_data[0]);

total_num_rows=all_data[1];

//alert(num_rows);
//alert(all_data[1]);


total_rows=total_num_rows;


});




});









}

});







////////////////////////////prev_search/////////////////////////////
////////////////////////////prev_search/////////////////////////////


$("#prev_num_search_new").live("click",function(){

total_con=$("#num_rows").text()/$("#rows_num").val();

//alert(current_con);
//alert(total_con);

if(current_con>1){



current_con--;






table=$("#table_name").html();
search_field=$("#search_field").val();
search_field_type=$("#search_field option:selected").attr("type");
search_type=$("#search_type").val();


if($("#search_text_options").val()=="" || $("#search_text_options").val()==null){
search=$("#search_text").val();	
}else{
search=$("#search_text_options").val();	
}

var_encrypt='';
$('.encrypt_var').each(function(){
var_encrypt+=$(this).attr('exam_id')+","+$(this).val()+"####";
	
});

end=(parseInt(current_con)* parseInt(num_rows))-1;
start=parseInt(end)-(parseInt(num_rows)-1);
current_mod=(current_con-1)%max_con;
num_rows=$("#rows_num").val();




$.post("decrypt.php",{

	value:$("#table_name").html()

},function(page){
//alert(page);	

page="load_"+page+"_search.php";


$("#load_wait").show();

end=num_rows;


//alert(sort);
//alert(sort_by);
////alert(search_field);
//alert(search_field_type);
//alert(search_type);
//alert(search);
//alert(table);
//alert(num_rows);
////alert(current_con);
////alert(total_con);
//alert(num_rows);	
//alert("current_con"+current_con);
//alert("max_con"+max_con);



current_mod=(current_con)%max_con;

//alert(current_mod);


//فى حالة عدم وجود الرقم التالى
if(current_mod!=0){
$(".num_con_search_new").removeClass("num_active");
$("#num_con_search_new"+current_con).addClass("num_active");
$("#next_num_search_new").attr("alt",parseInt($("#next_num_search_new").attr("alt"))-1);	
$("#prev_num_search_new").attr("alt",parseInt($("#prev_num_search_new").attr("alt"))-1);

//alert("xx");
}else{
//alert("xxx");
from=current_con ;
to=parseInt((current_con))+parseInt((max_con))+1;	
//alert(from);
//alert(to);
$(".num_con_search_new").show();
for(i=from;i>=to;i--){
before=parseInt(i)+parseInt(max_con);

$("#num_con_search_new"+before).attr("alt",i);
$("#num_con_search_new"+before).text(i);
$("#num_con_search_new"+before).attr("id","num_con_search_new"+i);	

if(i>total_con){ $("#num_con_search_new"+i).hide(); }
}

$(".num_con_search_new").removeClass("num_active");
$("#num_con_search_new"+current_con).addClass("num_active");

}




$("#load_wait").show();

//alert("num_rows"+num_rows);

$.post(page,{
"table":table,		
"start":start ,
"var_encrypt":var_encrypt,
"num_rows":num_rows ,
'search':search ,
'search_field':search_field ,
'search_field_type':search_field_type ,
'search_type':search_type ,
'sort':sort ,
'sort_by':sort_by 


},function(data){
$("#load_wait").hide();

all_data=data.split('####');



$("#load_view").html(all_data[0]);

total_num_rows=all_data[1];

//alert(num_rows);
//alert(all_data[1]);


total_rows=total_num_rows;


});




});









}

});

