$(document).ready(function(){ 
		
	$('.dateRange').calendar({ dateFormat: 'YMD-',firstDay: 1,yearRange: '2000:2024' });
	$(".zebra tr:nth-child(odd)").css("background","#cccccc");

	$('.hovertable tr').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	$(".sup").hover(function(){
		$('.sub', this).show();
	},function(){
		$('.sub', this).hide('fast');
	});
  

$("#loading").bind("ajaxSend", function(){
   $(this).show();
 }).bind("ajaxComplete", function(){
   $(this).hide();
});
  
  
  $(".button").click(function () { 
		$(".button").removeClass("selected"); 
		$(this).addClass("selected"); 
	});
	  
});

function tabbar( id ){
	
	$("#tabhead div").click( function() { 
		$("#tabhead div").css({ backgroundColor:"#f2f2f2"})
		$(this).css({ backgroundColor:"#cccccc"})
	//alert($(this).text()); 
	});
	
	$('#tabbs div').hide();
	$('#'+id).show();
	
  }
  
function tabber( id, clas ){
	$('.'+clas).hide();
	$('#'+id).show();
  }
  

  function togling( id ){
    
	var et = $("#"+id).css("display");
	if(et=='none'){
		$('#'+id).slideDown('fast');
	}else{
		$('#'+id).slideUp('fast');
	}
  }
  
  function sliding( id ){
  	$('#'+id).toggle(400);
	/*var et = $("#"+id).css("display");
	if(et=='none'){$('#'+id).show('slow');
	}else{$('#'+id).hide('fast');}*/
  }
  
function dinload( id, get, post){
	///id - loading container id
	/// 
	
	
	
	if(id==''){return false;}
	var d = new Date();
	//
	var dcontrol = d.getHours();
	//var dcontrol = d.getMinutes();

//		$.getScript("http://localhost/server/webriye/core/js/jquery.js");
//		$.getScript("http://localhost/server/webriye/core/js/myfunc.js");
	$("#"+id).load("dinload.php"+get,{val: post, control: dcontrol });

}
	


/////////
function winclose(id){
	var parid = $(id).parents('div.window').attr('id');
	$('#'+parid).fadeOut();
}


/////// calendar selector
function calendar_selector(get, post){
	var year = $('#phpcalendary').val();
	var month = $('#phpcalendarm').val();
	var post = year+'-'+month;
	dinload('phpcalendarcontainer', get, post);
//	alert(get);
	
}




///////// required cheker
function checkForm(obj, elems) {
var element, pattern;
    for (var i = 0; i < obj.elements.length; i++) {
        element = obj.elements[i];
        // field
        if (elems != undefined)
            if (elems.join().indexOf(element.type) < 0) continue;
        // messg
        if (!element.getAttribute("check_message")) continue;
        if (pattern = element.getAttribute("check_pattern")) {  // check by reg
            pattern = new RegExp(pattern, "g");
            if (!pattern.test(element.value)) {
                alert(element.getAttribute("check_message"));
                element.focus();
                return false;
            }
        } else if(/^s*$/.test(element.value)) {  // check empty
            alert(element.getAttribute("check_message"));
            element.focus();
            return false;
        }
    }
return true;
}


	
	
	
	
	
	