﻿standardprice={
	el:{
		bPriceQuotation:null,
		popImg:null,
		bPopClose:null
	},
	initEl:function(){
		var el=this.el;
		el.bPriceQuotation=$('.btnprice > a');
		el.popImg=$('.imagefullpop');
		el.bPopClose=$('.close', el.popImg);
	},
	// config method
	afterPopShowFuncs:[],
	afterPopShow:function(func){
		if(typeof(func)=='function')
			this.afterPopShowFuncs.push(func);
	},
	doAfterPopShow:function(){
		$.each(this.afterPopShowFuncs, function(i,o){
			if(typeof(o)=='function') o();
		});
	},
	// end
	initEvents:function(){
		var _this=this; var el=this.el;
		el.bPriceQuotation.unbind('click').bind('click', function(){
			el.popImg.fadeIn(400, function(){
				// กรณีที่มี func คือมาจาก ipad ดังนั้น else จะตกในกรณีที่เป็น web browser
				if(_this.afterPopShowFuncs.length>0){
					_this.doAfterPopShow();
				}else{
					setTimeout(function(){
						var qScroll=$('.quotation-scroll');
						qScroll.height($('img', qScroll).height());
					}, 3000);
				}
			});
		});
		el.bPopClose.unbind('click').bind('click', function(){
			el.popImg.fadeOut();
		});
	},
	init:function(){
		this.initEl();
		this.initEvents();
	}
};
$(function(){
	standardprice.init();
});
