dv = {
	init: {
		order_details_page: function() {
			//alert('order_details_page');
			$('.diagnos_details_open').click(function(e){
				e.preventDefault();	
				var $obj = $('.det_part_more');
				$obj.html('');
				var $orderid = $('#orderid').val();
				var $itemid = $('#itemid').val();
				var $base_url = $('#base_url').val();
				//get data
				if( $obj.css('display') == 'none'){
						$('#dia_diagnos_tab').css('background-color','#4C90C9');
						$.ajax({
						  url: $base_url+'clientspace/aj_order_diagnos',
						  data: 'orderid=' + $orderid + '&itemid=' + $itemid,
						  dataType: 'json',
						  type: 'post',
						  success: function (j) {
							$('.det_part_more').html(j.html);
							$obj.show('fast');
						  }
						});
					}else{
						$obj.hide("fast").html('');
						$('#dia_diagnos_tab').css('background-color','#fff');
					}					
			});
		}
		
	},
	act:{
		reg_type_btns: function() {
			//$('#private_reg_btn').click(function(){});
		},
		diagnos_det: function() {
			$('#dia_confirm_btn').click(function(e){
				e.preventDefault();	
				
				var $base_url = $('#base_url').val();
				var $orderid = $('#orderid').val();
				var $invoiceid = $('#invoiceid').val();
					
				var $data_str = 'orderid=' + $orderid + '&invoiceid=' + $invoiceid;
				
				$.ajax({
				  url: $base_url+'clientspace/aj_confirm_diagnos',
				  data: $data_str,
				  dataType: 'json',
				  type: 'post',
				  success: function (j) {
					if(j.redirect) {
						window.location = j.redirect;
					}	
				  }
				});
			});
			$('#dia_pdf_btn').click(function(e){
				e.preventDefault();	
				
				var $base_url = $('#base_url').val();
				var $orderid = $('#orderid').val();
				var $itemid = $('#itemid').val();
				var $invoiceid = $('#invoiceid').val();
					
				var $data_str = 
					'orderid=' + $orderid + 
					'&itemid=' + $itemid + 
					'&invoiceid=' + $invoiceid;
				
				$.ajax({
				  url: $base_url+'clientspace/aj_create_diagnos_pdf',
				   data: $data_str,
				  dataType: 'json',
				  type: 'post',
				  success: function (j) {
					//if(j.redirect) {
					//	window.location = j.redirect;
					//}	
					if(j.link) {
						$('#click_to_open_pdf').attr('href',j.link).click();
						$('#open_pdf').css('visibility','visible');

					}
				  }
				});
			});	
		}
	},	
	valid:{
		text: function(string, len){
			var length = string.length;
			if(length >= len) {
				return true;
			}else{
				return false;
			}
		},
		equals: function( str1, str2 ) {
			if(str1 == str2) {
				return true;
			} else {
				return false;
			}
		}
	},
	test:{
		dialog: function () {
			window.location = "http://www.google.com/";
		}
	}
}
