
/********************************************************************/
/*                                                                  */
/*  Copyright (c) 2014 Genesis Mobile                               */
/*                                                                  */
/*  This obfuscated code was created by Jasob 4.1 Trial Version.    */
/*  The code may be used for evaluation purposes only.              */
/*  To obtain full rights to the obfuscated code you have to        */
/*  purchase the license key (http://www.jasob.com/Purchase.html).  */
/*                                                                  */
/********************************************************************/

(function(){if(!("jQuery"in window)){throw new Error("sg framework is require jQuery");}var toString={}.toString,slice=[].slice;var initCallbackList=[],customTagList={},customAttrList={},setStageFunc,setScaleModeFunc,progressImg;var version="1.0",scaleMode="none",scaleX=0,scaleY=0,stageWidth=0,stageHeight=0,$stage=null,$content=null,$body=null,$window=$(window);if(!("forEach"in Array.prototype)){Array.prototype.forEach=function(callback){for(var i=0;i<this.length;i++){callback.call(window,this[i]);}}}jQuery.fn.pointer=function(){return $(this).css("cursor",arguments[0]==false?"auto":"pointer");};jQuery.fn.cssVal=function(cssName){var num=parseFloat($(this).css(cssName));return isNaN(num)?0:num;};jQuery.fn.getCustomTag=function(tagName){var isRoot=(this==$);for(var o in customTagList){if(tagName==o){if(isRoot)return $("["+customTagList[o].identifier+"]");else return $(this).children("["+customTagList[o].identifier+"]");}}return $;};jQuery.getCustomTag=jQuery.fn.getCustomTag;function swapTag(obj,findTagName,swapTagName,identifier){if(document.querySelector(findTagName)){identifier=identifier?' '+identifier+' ':'';obj.html=obj.html.replace(new RegExp('<'+findTagName,'g'),'<'+swapTagName+identifier).replace(new RegExp('</'+findTagName+'>','g'),'</'+swapTagName+'>');}else{customTagList[findTagName].nothing=true;}};function replaceTagList(){var obj={html:document.body.innerHTML},customTagName,customAttrName,ctInfo,caInfo,i,j,k;for(customTagName in customTagList){ctInfo=customTagList[customTagName];swapTag(obj,customTagName,ctInfo.originTag,ctInfo.identifier);};var sgAttrNameReg=/\ssg([\-][\w]*){1,5}(\s)?=/gi,s1=obj.html.split('<'),s2,matchArr,r2=[];for(i=0;i<s1.length;i++){s2=s1[i].split('>');for(j=0;j<s2.length;j++){if(j%2==0){matchArr=s2[j].match(sgAttrNameReg);if(matchArr){for(k=0;k<matchArr.length;k++){s2[j]=s2[j].replace(matchArr[k]," data-"+matchArr[k].substr(1));}}}}r2.push(s2.join('>'));}obj.html=r2.join('<');document.body.innerHTML=obj.html;delete s1;delete s2;delete r2;delete obj;delete matchArr;$("[placeholder]").each(function(i,e){$(this).text("").attr("placeholder",$(this).attr("placeholder"));});var $customTag;for(customTagName in customTagList){ctInfo=customTagList[customTagName];if(ctInfo.nothing)continue;$customTag=$.getCustomTag(customTagName);if(sg.isFunction(ctInfo["initFunc"])){ctInfo["initFunc"].call(sg);}$customTag.each(function(index,element){$(element).data("_customTagName",customTagName);sg.setOption(element);if(/^sg-btn-/.test(customTagName))$(element).pointer();if(sg.isFunction(ctInfo["eachInitFunc"])){ctInfo["eachInitFunc"].call(element,element);}sg.initAttr(element);});if(ctInfo["eventName"]){$customTag.bind(ctInfo["eventName"],function(e){var ctname=$(this).data("_customTagName");if(!$(this).data("options").enabled)return;if(sg.isFunction(customTagList[ctname]["eventFunc"]))customTagList[ctname]["eventFunc"].call(this,this,e);sg.actionAttr(this);});};$customTag=null;};for(customAttrName in customAttrList){caInfo=customAttrList[customAttrName];if(caInfo.isForEveryTags){if(caInfo&&sg.isFunction(caInfo["init"])){$("[data-"+customAttrName+"]").each(function(i,element){sg.setOption(element);caInfo["init"].call(element,element,element.getAttribute("data-"+customAttrName));});}}}};var _ww,_hh,_ch,_msc;function applyScaleMode(){_ww=$window.width();_hh=$window.height();_ch=$content.height();_ch+=$content.cssVal("border-top-width")+$content.cssVal("border-bottom-width");_ch+=$content.cssVal("margin-top")+$content.cssVal("margin-bottom");_ch+=$content.cssVal("padding-top")+$content.cssVal("padding-bottom");switch(scaleMode){case "showall":_msc=Math.min(_ww/stageWidth,_hh/stageHeight);if(_ch-stageHeight<=1){if(_ch*_msc>_hh){$stage.css({"transform":"scale("+_msc+")","transform-origin":"0 0","left":((_ww-stageWidth*_msc)*0.5)+"px","top":0});$stage.parent().css({"overflow-y":"visible"});}else{$stage.css({"transform":"scale("+_msc+")","transform-origin":"0 0","left":((_ww-stageWidth*_msc)*0.5)+"px","top":((_hh-_ch*_msc)*0.5)+"px"});$stage.parent().css({"overflow-y":"hidden"});}}else{$stage.css({"transform":"scale("+_msc+")","transform-origin":"0 0","left":((_ww-stageWidth*_msc)*0.5)+"px","top":((_hh-stageHeight*_msc)*0.5)+"px"});$stage.parent().css({"overflow-y":"auto"});}scaleX=scaleY=_msc;break;case "noscale":scaleX=scaleY=1;$stage.css({"transform":"scale("+scaleX+")","transform-origin":"0 0"});break;case "exactfit":scaleX=_ww/stageWidth;scaleY=_hh/stageHeight;$stage.css({"transform":"scale("+scaleX+", "+scaleY+")","transform-origin":"0 0"});break;}};var sg={get version(){return version},get scaleMode(){return scaleMode},get scaleX(){return scaleX},get scaleY(){return scaleY},get stageWidth(){return stageWidth},get stageHeight(){return stageHeight},get $stage(){return $stage},get $content(){return $content},get $body(){return $body},get $window(){return $window},extend:function(prop){if(typeof prop!=="object"){throw new Error("sg.extend arguments is not Object!");}for(var name in prop){if(name in sg)prop[name]._super=sg[name];sg[name]=prop[name];}},super:function(){var _super=arguments.callee.caller._super;return sg.isFunction(_super)?_super.apply(this,arguments):null;}};sg.extend({isFunction:$.isFunction,isArray:$.isArray,isWindow:$.isWindow,isNumeric:$.isNumeric,isEmptyObject:$.isEmptyObject,inArray:$.inArray,type:$.type});sg.extend({addInit:function(callback){initCallbackList.push(callback);},setLoadingImage:function(path){progressImg=new Image();progressImg.setAttribute("data-sg-id","progressImg");progressImg["onload"]=function(e){this.style.left=(((window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)-this.width)*0.5)+"px";this.style.top=(((window.innerHeight||document.documentElement.clientWidth||document.body.clientWidth)-this.height)*0.5)+"px";if(!sg.isReady)document.body.appendChild(progressImg);else delete progressImg;};progressImg.src=path;progressImg.style.position="fixed";progressImg.style.visibility="visible";},setStage:function(elementOrSelector){setStageFunc=function(){var $temp=$(elementOrSelector);if($temp.length==0)throw new Error("setStage : $stage is not select. (selector : "+elementOrSelector+")");$temp.attr("data-sg-id","stage");$content=$("<div data-sg-id='content'></div>");$content.append($temp.contents());$temp.append($content).css("position","absolute");$temp.parent().css("overflow-x","hidden");if($temp.cssVal("border-top-width")==0){$temp.css("border","solid 1px rgba(255,255,255,0)");}stageWidth=$temp.width();stageHeight=$temp.height();$content.css({"min-height":stageHeight,"visibility":"hidden"});$stage=$temp;if(setScaleModeFunc){setScaleModeFunc.apply(sg);setScaleModeFunc=null;}};if(sg.isReady){setStageFunc.apply(sg);setStageFunc=null;}},setScaleMode:function(_scaleMode){scaleMode=_scaleMode;setScaleModeFunc=function(){$window.bind("resize",function(){applyScaleMode();});applyScaleMode();};if($stage){setScaleModeFunc.apply(this);setScaleModeFunc=null;}},setOption:function(target,options){var op={enabled:true};for(var o in options)op[o]=options[o];$(target).data("options",op);},addCustomAttr:function(obj){customAttrList[obj.name]={init:obj.init,action:obj.action,isForEveryTags:obj.applyAll}},addCustomTag:function(obj){customTagList[obj.name]={originTag:obj.originTag?obj.originTag:"div",identifier:obj.id?obj.id:"data-sg-id='"+obj.name+"'",eventName:obj.event,attrList:(function(list){if(!list)return null;else list=slice.call(list);var i=0,attrName;list.forEach(function(attrName){if(!(attrName in customAttrList))list.splice(i,1);else i++;});return list;})(obj.attr),initFunc:obj.init,eachInitFunc:obj.tagInit,eventFunc:obj.eventHandle}},initAttr:function(element){var customTagName=$(element).data("_customTagName"),attrList,attr,attrValue;if(customTagName){attrList=customTagList[customTagName].attrList;if(attrList){attrList.forEach(function(attrName){attr=customAttrList[attrName];attrValue=element.getAttribute("data-"+attrName);if(attr&&attr["init"]&& !attr.isForEveryTags){attr["init"].call(element,element,attrValue);}});}}},actionAttr:function(element){var customTagName=$(element).data("_customTagName"),attrList,attr,attrValue;if(customTagName){attrList=customTagList[customTagName].attrList;if(attrList){attrList.forEach(function(attrName){attr=customAttrList[attrName];attrValue=element.getAttribute("data-"+attrName);if(attr&&attr["action"]){attr["action"].call(element,element,attrValue);}});}}},hide:function(elementOrSelector){$(elementOrSelector).hide();},show:function(elementOrSelector){$(elementOrSelector).show();},fadeIn:function(elementOrSelector){$(elementOrSelector).fadeIn("slow");},fadeOut:function(elementOrSelector){$(elementOrSelector).fadeOut("slow");},enabled:function(elementOrSelector){return $(elementOrSelector).each(function(i,e){var $this=$(this);$this.css("cursor","pointer");var options=$this.data("options")||{};options.enabled=true;$this.data("options",options);});},disabled:function(elementOrSelector){return $(elementOrSelector).each(function(i,e){var $this=$(this);$this.css("cursor","default");var options=$this.data("options")||{};options.enabled=false;$this.data("options",options);});}});sg.extend({init:function(callback){function _init(){$body=$(document.body);replaceTagList();if(setStageFunc){setStageFunc.apply(sg);setStageFunc=null;}if("init"in window&&sg.isFunction(window["init"])){window["init"].apply(window);}if("initList"in window){initCallbackList=initCallbackList.concat(window["initList"]);}initCallbackList.forEach(function(initFunc){if(sg.isFunction(initFunc))initFunc.apply(window);});$("[data-sg-id='progressImg']").remove();$content=$("[data-sg-id='content']").css("visibility","visible");$stage=$("[data-sg-id='stage']");sg.isReady=true;setTimeout(function(){$window.trigger("resize");},0);};if($.isReady){_init.apply(window);if(sg.isFunction(callback))callback.apply(window);}else{$(document).ready(function(e){_init.apply(window);if(sg.isFunction(callback))callback.apply(window);});}}});window.sg=sg;return sg;})();