// JavaScript Document
$(document).ready(function() {			
	// من أجل Highlight عند المرور فوق السطر، بالإضافة إلى Click
	$("table#viewGrid tbody tr").mouseover( function() {
			$(this).addClass("trHighlight");
		}).mouseout( function() {
			$(this).removeClass("trHighlight");
	});

	$("table#viewGrid tbody tr").click( function() {
			if (!$(this).hasClass("trClick")) { $(this).addClass("trClick");}
				else { $(this).removeClass("trClick");	 }
	});
	
	
	// Color switch
	$('div#content tr:odd').addClass('odd');
	$('div#content tr:even').addClass('even');

	//وضع المؤشر على أول حقل
	$("#commentForm input:first").focus();
	

	// validate start -----------------------------------------
	$("#commentForm").validate();
	// validate end -------------------------------------------
	
	
	//من أجل عمل mask
	$("input[@maskFormat]").each(function() {
		$(this).mask($(this).attr("maskFormat"));
	});
	
	
	//للبحث
	$("form[action~=&action=view]").attr("method","get");
	//$("form[action~=&action=view]").attr("onclick","go_search(this); return false;");
	$("form[action~=&action=view]").submit(function() {
		var lurl = window.location.href;
		lurl = lurl.replace("action=search", "action=view");
		window.location= lurl + '&' + $(this).serialize();
		return false;
	});
});


function ajax_get_value(url, block , callback ) {

$.get(url,function(data, callback){		
		$(block).html(data);
		callback;  	
	  });

} 


function ShowRow(){
var row = document.getElementById("captionRow");
if (row.style.display == 'none') row.style.display = '';
}
 

function HideRow(){
var row = document.getElementById("captionRow");
if (row.style.display == '') row.style.display = 'none';
}


function ShowVC1(){
var row  = document.getElementById("v1_Row");
var row1 = document.getElementById("v2_Row");
var row3 = document.getElementById("v3_Row");
var row4 = document.getElementById("v4_Row");
var row5 = document.getElementById("v5_Row");
if (row.style.display == 'none') row.style.display = ''; row5.style.display = ''; row1.style.display = 'none'; row3.style.display = 'none'; row4.style.display = 'none';
}


function ShowVC2(){
var row = document.getElementById("v2_Row");
var row1 = document.getElementById("v1_Row");
var row3 = document.getElementById("v3_Row");
var row4 = document.getElementById("v4_Row");
var row5 = document.getElementById("v5_Row");
if (row.style.display == 'none') row.style.display = ''; row3.style.display = ''; row4.style.display = ''; row1.style.display = 'none';  row5.style.display = 'none';
}

//يستخدم في Paging.php
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

 
