(function($){
	jQuery.fn.DShowImages=function(options){		options=jQuery.extend({
			box_show: 		false,
			id_gallery:		'id_dshowimages',
			zoom_min:			false,
			speed:				500,
			win_width:		$(window).width(),
			win_height:		$(window).height(),
			zoom_width:		450,
			zoom_height:	352
		},options);
		options.box_show=jQuery(document.createElement('div')).attr({id:'id_large_images',className:'d_large_images'});
		$(document.body).append(options.box_show);
		return $(this).each(function(){
			if(this.id==options.id_gallery){				$(this).addClass('images_border_view');
				$(this).click(function(){_init_now(this);});
				$(this).mouseover(function(){$(this).attr('className','images_border_hover');});
				$(this).mouseout(function(){$(this).attr('className','images_border_view');});
			}
		});
		function _init_now(obj){
			options.win_width=$(window).width();
			options.win_height=$(window).height();
			var pa_offset=$(obj).offset();
			var pa_width=$(obj).width();
			var pa_height=$(obj).height();
			var tblData='<table border="0" id="tbl_dshowimages" class="view_images_large" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" bordercolor="#DDDDDD" width="100%">';
			tblData+='<tr><td width="100%" align=center><img src="'+$(obj).attr('rel')+'"></td></tr>';
			tblData+='<tr><td width="100%" align=center bgcolor="#FFFFFF" class="title_images_large">'+$(obj).attr('title')+'</td></tr>';
			tblData+='</table>';
			$(options.box_show).html(tblData);
			$(options.box_show).css({width:pa_width,height:pa_height,left:pa_offset.left,top:pa_offset.top,display:'block'});
			$(options.box_show).unbind('click');
			//options.zoom_width=$('#tbl_dshowimages').width();
			//options.zoom_height=$('#tbl_dshowimages').height();
			var slide_left=(options.win_width/2)-(options.zoom_width/2);
			var slide_top=((options.win_height/2)-(options.zoom_height/2))+$(document).scrollTop();
			if(slide_top<0){slide_top=0;}
			$(options.box_show).animate({width:options.zoom_width,height:options.zoom_height,top:slide_top,left:slide_left},options.speed);
			$(options.box_show).click(function(){				if(options.zoom_min){pa_width=pa_height=0;}
				$(this).animate({width:pa_width,height:pa_height,top:pa_offset.top,left:pa_offset.left},options.speed,0,function(){
					$(this).css('display','none');
				});
			});
		}
	}
})(jQuery);

(function($){
	jQuery.fn.DDialog=function(options){
		options=jQuery.extend({
			id_gallery:		false,
			id_dialog:		'#id_DDialog',
			id_close:			'#id_close_dialog',
			id_frame:			'#id_frmDDialog',
			speed:				500,
			zoom_width:		500,
			zoom_height:	250,
			click_close:	false,
			win_width:		$(window).width(),
			win_height:		$(window).height()
		},options);
		return $(this).each(function(){
			if(this.id==options.id_gallery){
				$(this).click(function(){					_init_now(this);
				});
			}
		});
		function _init_now(obj){			options.win_width=$(window).width();
			options.win_height=$(window).height();			var slide_left=(options.win_width/2)-(options.zoom_width/2);
			var slide_top=((options.win_height/2)-(options.zoom_height/2))+$(document.body).scrollTop();
			$(options.id_dialog).animate({width:options.zoom_width,height:options.zoom_height,top:slide_top,left:slide_left},options.speed,0,function(){				$(options.id_frame).attr('src',$(obj).attr('rel'));
			});
			_close_box(obj);
		}
		function _close_box(obj){			$(options.id_close).click(function(){
				$(this).unbind('click');
				$(options.id_dialog).animate({width:0,height:0},options.speed,0,function(){
					$(options.id_dialog).hide();
				});
			});		}
	}
})(jQuery);

(function($){
	jQuery.fn.DSearch=function(options){
		options=jQuery.extend({
			id_dialog:	'#id_DSearchAdvance',
			speed: 500,
			width:100,
			height: 120
		},options);
		$(this).click(function(){
			_init_now(this);
		});
		function _init_now(obj){
			if($(options.id_dialog).is(':hidden')){
				$(options.id_dialog).animate({height:options.height},options.speed);
			}else{
				$(options.id_dialog).animate({height:2},options.speed,0,function(){
					$(options.id_dialog).hide();
				});
			}
		}
	}
})(jQuery);

(function($){
	jQuery.fn.DShowMovie=function(options){
		options=jQuery.extend({
			id_gallery:		false,
			id_dialog:		'#id_DDialog',
			id_close:			'#id_close_dialog',
			id_frame:			'#id_MoviePlayer',
			speed:				500,
			zoom_width:		400,
			zoom_height:	400,
			click_close:	false,
			win_width:		$(window).width(),
			win_height:		$(window).height()
		},options);
		return $(this).each(function(){
			if(this.id==options.id_gallery){
				$(this).click(function(){
					_init_now(this);
				});
			}
		});
		function _init_now(obj){
			options.win_width=$(window).width();
			options.win_height=$(window).height();
			var slide_left=(options.win_width/2)-(options.zoom_width/2);
			var slide_top=((options.win_height/2)-(options.zoom_height/2))+$(document.body).scrollTop();
			var path_player=m_movies='';
			$(options.id_dialog).animate({width:options.zoom_width,height:options.zoom_height,top:slide_top,left:slide_left},options.speed,0,function(){
				$(options.id_frame).attr('src',$(obj).attr('rel'));
			});
			_close_box(obj);
		}
		function _close_box(obj){
			$(options.id_close).click(function(){
				$(this).unbind('click');
				$(options.id_dialog).animate({width:0,height:0},options.speed,0,function(){
					$(options.id_dialog).hide();
				});
			});
		}
	}
})(jQuery);

(function($){
	jQuery.fn.DShowBox=function(options){
		options=jQuery.extend({
			id_gallery:		false,
			id_frame	:		false,
			id_dialog:		'#id_DBox',
			id_close:			'#id_close_dbox',
			speed:				500,
			zoom_width:		400,
			zoom_height:	400,
			pos_x:				-1,
			pos_y:				-1,
			win_width:		$(window).width(),
			win_height:		$(window).height()
		},options);
		return $(this).each(function(){
			if(this.id==options.id_gallery){
				$(this).click(function(){
					_init_now(this);
				});
			}
		});
		function _init_now(obj){
			options.win_width=$(window).width();
			options.win_height=$(window).height();
			var slide_left=(options.win_width/2)-(options.zoom_width/2);
			var slide_top=((options.win_height/2)-(options.zoom_height/2))+$(document).scrollTop();
			if(options.pos_x!=-1){slide_left=$(obj).offset().left;}
			if(options.pos_y!=-1){slide_top=$(obj).offset().top+20;}
			var path_player=m_movies='';
			$(options.id_dialog).animate({width:options.zoom_width,height:options.zoom_height,top:slide_top,left:slide_left},options.speed,0,function(){				if(options.id_frame){					$(options.id_frame).attr('src',$(obj).attr('rel'));				}			});
			_close_box(obj);
		}
		function _close_box(obj){
			$(options.id_close).click(function(){
				$(this).unbind('click');
				$(options.id_dialog).animate({width:0,height:0},options.speed,0,function(){
					$(options.id_dialog).hide();
				});
			});
		}
	}
})(jQuery);
