jQuery(function(){
	jQuery('#fmCheck').submit(function(event,params,options){
		if (typeof options == 'undefined'){
			var options = {
				show_inline_loader_for:'#btn_submit',
				callAfterSuccess:function(data){
					jQuery('#btn_submit').html('<span style="margin-right:82px;	margin-top:45px;">Redirecting...</span>');
				},
				callAfterFailed:function(data){
					jQuery('#btn_submit').html('<button class="button_check" type="submit"></button>');
				}
			}
		}
		return Goingup.Form.Submit(this,params,options);	
	});
	
	jQuery('a[href$=#thumb]').click(function(){
		var data = {
			'msg_title':'Thumbnail Viewer',
			'html':'<div align="center" class="thumb_loading"></div>'
		};
		
		Goingup.Dialog.Show(data);
		
		var options = {
			'url':window.location.href.replace(/#.*/,''),
			'params':{'do':'thumb_code','id':this.rel}
		}
		Goingup.Request(options)
		
		return false;
	});
	
	jQuery('a[href$=#export_csv]').click(function(){
		var url = window.location.href.replace(/#.*|\?.*/,'')+'?'+this.rel+'&do=export';
		window.location.href = url;
	});
	
//	jQuery('a[href$=#export_email]').click(function(){
//		var url = window.location.href.replace(/#.*|\?.*/,'')+'?'+this.rel;
//		var options = {
//			'url'	: url,
//			params	:{
//						'do'	:'export'
//					 }
//		};
//		
//		Goingup.Request(options);
//	});
	jQuery('a[href$=#export_print]').click(function(){
		var url = window.location.href.replace(/#.*|\?.*/,'')+'?'+this.rel+'&do=export';
		Goingup.popUpWindow(url,'100px','100px','550px','700px');
	});
	
	jQuery('a[href$=#export_email]').click(function(){
		var url = window.location.href.replace(/#.*|\?.*/,'')+'?'+this.rel;
		var data = {
			msg_title:'Export report to email',
			html:'<div>\
					<form id="fmEmail" action="'+url+'" method="get">\
						<input type="hidden" name="do" value="export" />\
    					<label>Email Address:</label> \
        				<input type="text" name="email" value="" size="45" /> \
    				</form>\
				  </div>',
			buttons:[
					{onclick:'Goingup.Dialog.Hide()',value:'Close','class':'ko'},
					{onclick:'Goingup.Dialog.OK()',value:'OK'}
				]
		}
		Goingup.Dialog.Show(data);		
	});
});
