(function($){$.fn.jScrollTouch=function(showScroller,dragdealer){if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))||(navigator.userAgent.match(/iPad/i))){var isTouchScreen=1;}else{var isTouchScreen=0;}
$(this).css({'overflow':'auto','position':'relative'});return this.each(function(){var cont=$(this);var height=0;var cpos=cont.scrollTop()
cont.scrollTop(100000);height=cont.scrollTop();cont.scrollTop(cpos);var fullheight=height+cont.outerHeight();var scrollbarV_length=cont.innerHeight()*(cont.innerHeight()/fullheight)+2;var width=0;var lpos=cont.scrollLeft();cont.scrollLeft(100000);width=cont.scrollLeft();cont.scrollLeft(lpos);var fullwidth=width+cont.outerWidth();var scrollbarH_length=cont.innerWidth()*(cont.innerWidth()/fullwidth)+2;if(isTouchScreen){var scrollbarV=$('<div></div>');scrollbarV.css({'display':'none','position':'absolute','width':'5px','height':scrollbarV_length+'px','left':cont.innerWidth()-7+'px','top':0,'background':'black','border':'1px white solid','-webkit-border-radius':'5px','opacity':'0.9'});var scrollbarH=$('<div></div>');scrollbarH.css({'display':'none','position':'absolute','height':'5px','width':scrollbarH_length+'px','top':cont.innerHeight()-7+'px','left':0,'background':'black','border':'1px white solid','-webkit-border-radius':'5px','opacity':'0.9'});if(height)cont.append(scrollbarV);if(width)cont.append(scrollbarH);}
cont.bind('mousedown touchstart',function(e){cpos=cont.scrollTop();if(isTouchScreen){try{e=e.originalEvent.touches[0];}catch(e){e=window.event;}}
if(isTouchScreen&&showScroller){scrollbarV.show();scrollbarH.show();}
var sY=e.pageY;var sX=e.pageX;cont.bind('mousemove touchmove ',function(ev){if(isTouchScreen){ev.preventDefault();ev=ev.originalEvent.touches[0];}
var top=cpos-(ev.pageY-sY);var left=lpos-(ev.pageX-sX);cont.scrollTop(top);cpos=cont.scrollTop();sY=ev.pageY;cont.scrollLeft(left);lpos=cont.scrollLeft();sX=ev.pageX;if(isTouchScreen&&showScroller){scrollbarV.css({'left':Math.min(cont.innerWidth()-7+lpos,fullwidth)+'px','top':Math.min(cpos+cpos*cont.innerHeight()/fullheight,fullheight-scrollbarV_length)+'px'});scrollbarH.css({'top':Math.min(cont.innerHeight()-7+cpos,fullheight)+'px','left':Math.min(lpos+lpos*cont.innerWidth()/fullwidth,fullwidth-scrollbarH_length)+'px'});}
if(dragdealer)dragdealer.updateToValue();});cont.bind('mouseup touchend',function(ev){cont.unbind('mousemove touchmove mouseup touchend');if(isTouchScreen&&showScroller){scrollbarV.fadeOut();scrollbarH.fadeOut();}});});});}})(jQuery);(function($){var types=['DOMMouseScroll','mousewheel'];$.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var i=types.length;i;){this.addEventListener(types[--i],handler,false);}}else{this.onmousewheel=handler;}},teardown:function(){if(this.removeEventListener){for(var i=types.length;i;){this.removeEventListener(types[--i],handler,false);}}else{this.onmousewheel=null;}}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});function handler(event){var orgEvent=event||window.event,args=[].slice.call(arguments,1),delta=0,returnValue=true,deltaX=0,deltaY=0;event=$.event.fix(orgEvent);event.type="mousewheel";if(event.wheelDelta){delta=event.wheelDelta/120;}
if(event.detail){delta=-event.detail/3;}
deltaY=delta;if(orgEvent.axis!==undefined&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){deltaY=0;deltaX=-1*delta;}
if(orgEvent.wheelDeltaY!==undefined){deltaY=orgEvent.wheelDeltaY/120;}
if(orgEvent.wheelDeltaX!==undefined){deltaX=-1*orgEvent.wheelDeltaX/120;}
args.unshift(event,delta,deltaX,deltaY);return $.event.handle.apply(this,args);}})(jQuery);$.fn.breakly=function(chopAt,spaceCode){spaceCode|=8203;var zw=String.fromCharCode(spaceCode),re=new RegExp(/\B/),orig,idx,chopped,ch;function breakly(node){if(3==node.nodeType&&(orig=node.nodeValue).length>chopAt){idx=0;chopped=[];for(var i=0;i<orig.length;i++){ch=orig.substr(i,1);chopped.push(ch);if(null!=ch.match(re)){idx=0;continue;}
if(++idx==chopAt){ch=orig.substr(i+1,1);if(ch&&null==ch.match(re)){chopped.push(zw);idx=0;}}}
node.nodeValue=chopped.join('');}else{for(var i=0;i<node.childNodes.length;i++){breakly(node.childNodes[i]);}}}
return this.each(function(){breakly(this);})};(function($){var msOldDiv="";var dd=function(element,options)
{var sElement=element;var $this=this;var options=$.extend({height:120,visibleRows:7,rowHeight:23,showIcon:true,zIndex:9999,mainCSS:'dd',useSprite:false,onInit:'',style:''},options);this.ddProp=new Object();var selectedValue="";var actionSettings={};actionSettings.insideWindow=true;actionSettings.keyboardAction=false;actionSettings.currentKey=null;var ddList=false;var config={postElementHolder:'_msddHolder',postID:'_msdd',postTitleID:'_title',postTitleTextID:'_titletext',postChildID:'_child',postAID:'_msa',postOPTAID:'_msopta',postInputID:'_msinput',postArrowID:'_arrow',postInputhidden:'_inp'};var styles={dd:options.mainCSS,ddTitle:'ddTitle',arrow:'arrow',ddChild:'ddChild',ddTitleText:'ddTitleText',disabled:.30,ddOutOfVision:'ddOutOfVision'};var attributes={actions:"focus,blur,change,click,dblclick,mousedown,mouseup,mouseover,mousemove,mouseout,keypress,keydown,keyup",prop:"size,multiple,disabled,tabindex"};this.onActions=new Object();var elementid=$(sElement).attr("id");var inlineCSS=$(sElement).attr("style");options.style+=(inlineCSS==undefined)?"":inlineCSS;var allOptions=$(sElement).children();ddList=($(sElement).attr("size")>0||$(sElement).attr("multiple")==true)?true:false;if(ddList){options.visibleRows=$(sElement).attr("size");};var a_array={};var getPostID=function(id){return elementid+config[id];};var getOptionsProperties=function(option){var currentOption=option;var styles=$(currentOption).attr("style");return styles;};var matchIndex=function(index){var selectedIndex=$("#"+elementid+" option:selected");if(selectedIndex.length>1){for(var i=0;i<selectedIndex.length;i++){if(index==selectedIndex[i].index){return true;};};}else if(selectedIndex.length==1){if(selectedIndex[0].index==index){return true;};};return false;};var createA=function(currentOptOption,current,currentopt,tp){var aTag="";var aidoptfix=(tp=="opt")?getPostID("postOPTAID"):getPostID("postAID");var aid=(tp=="opt")?aidoptfix+"_"+(current)+"_"+(currentopt):aidoptfix+"_"+(current);var arrow="";var clsName="";if(options.useSprite!=false){clsName=' '+options.useSprite+' '+currentOptOption.className;}else{arrow=$(currentOptOption).attr("title");arrow=(arrow.length==0)?"":'<img src="'+arrow+'" align="absmiddle" /> ';};var sText=$(currentOptOption).text();var sValue=$(currentOptOption).val();var sEnabledClass=($(currentOptOption).attr("disabled")==true)?"disabled":"enabled";a_array[aid]={html:arrow+sText,value:sValue,text:sText,index:currentOptOption.index,id:aid};var innerStyle=getOptionsProperties(currentOptOption);if(matchIndex(currentOptOption.index)==true){aTag+='<a href="javascript:void(0);" class="selected '+sEnabledClass+clsName+'"';}else{aTag+='<a  href="javascript:void(0);" class="'+sEnabledClass+clsName+'"';};if(innerStyle!==false&&innerStyle!==undefined){aTag+=" style='"+innerStyle+"'";};aTag+=' id="'+aid+'">';aTag+=arrow+'<span class="'+styles.ddTitleText+'">'+sText+'</span></a>';return aTag;};var createATags=function(){var childnodes=allOptions;if(childnodes.length==0)return"";var aTag="";var aidfix=getPostID("postAID");var aidoptfix=getPostID("postOPTAID");childnodes.each(function(current){var currentOption=childnodes[current];if(currentOption.nodeName=="OPTGROUP"){aTag+="<div class='opta'>";aTag+="<span style='font-weight:bold;font-style:italic; clear:both;'>"+$(currentOption).attr("label")+"</span>";var optChild=$(currentOption).children();optChild.each(function(currentopt){var currentOptOption=optChild[currentopt];aTag+=createA(currentOptOption,current,currentopt,"opt");});aTag+="</div>";}else{aTag+=createA(currentOption,current,"","");};});return aTag;};var createChildDiv=function(){var id=getPostID("postID");var childid=getPostID("postChildID");var sStyle=options.style;sDiv="";sDiv+='<div id="'+childid+'" class="'+styles.ddChild+'"';if(!ddList){sDiv+=(sStyle!="")?' style="'+sStyle+'"':'';}else{sDiv+=(sStyle!="")?' style="border-top:1px solid #c3c3c3;display:block;position:relative;'+sStyle+'"':'';}
sDiv+='>';return sDiv;};var createTitleDiv=function(){var titleid=getPostID("postTitleID");var arrowid=getPostID("postArrowID");var titletextid=getPostID("postTitleTextID");var inputhidden=getPostID("postInputhidden");var sText="";var arrow="";if(elementid&&document.getElementById(elementid).options.length>0){sText=$("#"+elementid+" option:selected").text();arrow=$("#"+elementid+" option:selected").attr("title");};arrow=(arrow.length==0||arrow==undefined||options.showIcon==false||options.useSprite!=false)?"":'<img src="'+arrow+'" align="absmiddle" /> ';var sDiv='<div id="'+titleid+'" class="'+styles.ddTitle+'"';sDiv+='>';sDiv+='<span id="'+arrowid+'" class="'+styles.arrow+'"></span><span class="'+styles.ddTitleText+'" id="'+titletextid+'">'+arrow+'<span class="'+styles.ddTitleText+'">'+sText+'</span></span></div>';return sDiv;};var applyEventsOnA=function(){var childid=getPostID("postChildID");$("#"+childid+" a.enabled").bind("click",function(event){event.preventDefault();manageSelection(this);if(!ddList){$("#"+childid).unbind("mouseover");setInsideWindow(false);var sText=(options.showIcon==false)?$(this).text():$(this).html();setTitleText(sText);$this.close();};setValue();});};var createDropDown=function(){var changeInsertionPoint=false;var id=getPostID("postID");var titleid=getPostID("postTitleID");var titletextid=getPostID("postTitleTextID");var childid=getPostID("postChildID");var arrowid=getPostID("postArrowID");var sStyle=options.style;if($("#"+id).length>0){$("#"+id).remove();changeInsertionPoint=true;};var sDiv='<div id="'+id+'" class="'+styles.dd+'"';sDiv+=(sStyle!="")?' style="'+sStyle+'"':'';sDiv+='>';sDiv+=createTitleDiv();sDiv+=createChildDiv();sDiv+=createATags();sDiv+="</div>";sDiv+="</div>";if(changeInsertionPoint==true){var sid=getPostID("postElementHolder");$("#"+sid).after(sDiv);}else{$("#"+elementid).after(sDiv);};if(ddList){var titleid=getPostID("postTitleID");$("#"+titleid).hide();};var iWidth=$("#"+elementid).outerWidth()+12;$("#"+id).css("width",iWidth+"px");$("#"+childid).css("width",(iWidth)+"px");if(allOptions.length>options.visibleRows){var margin=parseInt($("#"+childid+" a:first").css("padding-bottom"))+parseInt($("#"+childid+" a:first").css("padding-top"));var iHeight=((options.rowHeight)*options.visibleRows)-margin;$("#"+childid).css("height",iHeight+"px");}else if(ddList){var iHeight=$("#"+elementid).height();$("#"+childid).css("height",iHeight+"px");};if(changeInsertionPoint==false){setOutOfVision();addRefreshMethods(elementid);};if($("#"+elementid).attr("disabled")==true){$("#"+id).css("opacity",styles.disabled);};applyEvents();$("#"+titleid).bind("mouseover",function(event){hightlightArrow(1);});$("#"+titleid).bind("mouseout",function(event){hightlightArrow(0);});applyEventsOnA();$("#"+childid+" a.disabled").css("opacity",styles.disabled);if(ddList){$("#"+childid).bind("mouseover",function(event){if(!actionSettings.keyboardAction){actionSettings.keyboardAction=true;$(document).bind("keydown",function(event){var keyCode=event.keyCode;actionSettings.currentKey=keyCode;if(keyCode==39||keyCode==40){event.preventDefault();event.stopPropagation();next();setValue();};if(keyCode==37||keyCode==38){event.preventDefault();event.stopPropagation();previous();setValue();};});}});};$("#"+childid).bind("mouseout",function(event){setInsideWindow(false);$(document).unbind("keydown");actionSettings.keyboardAction=false;actionSettings.currentKey=null;});$("#"+titleid).bind("click",function(event){setInsideWindow(false);if($("#"+childid+":visible").length==1){$("#"+childid).unbind("mouseover");}else{$("#"+childid).bind("mouseover",function(event){setInsideWindow(true);});$this.open();};});$("#"+titleid).bind("mouseout",function(evt){setInsideWindow(false);});if(options.showIcon&&options.useSprite!=false){setTitleImageSprite();};};var getByIndex=function(index){for(var i in a_array){if(a_array[i].index==index){return a_array[i];};};return-1;};var manageSelection=function(obj){var childid=getPostID("postChildID");if(!ddList){$("#"+childid+" a.selected").removeClass("selected");};var selectedA=$("#"+childid+" a.selected").attr("id");if(selectedA!=undefined){var oldIndex=(actionSettings.oldIndex==undefined||actionSettings.oldIndex==null)?a_array[selectedA].index:actionSettings.oldIndex;};if(obj&&!ddList){$(obj).addClass("selected");};if(ddList){var keyCode=actionSettings.currentKey;if($("#"+elementid).attr("multiple")==true){if(keyCode==17){actionSettings.oldIndex=a_array[$(obj).attr("id")].index;$(obj).toggleClass("selected");}else if(keyCode==16){$("#"+childid+" a.selected").removeClass("selected");$(obj).addClass("selected");var currentSelected=$(obj).attr("id");var currentIndex=a_array[currentSelected].index;for(var i=Math.min(oldIndex,currentIndex);i<=Math.max(oldIndex,currentIndex);i++){$("#"+getByIndex(i).id).addClass("selected");}}else{$("#"+childid+" a.selected").removeClass("selected");$(obj).addClass("selected");actionSettings.oldIndex=a_array[$(obj).attr("id")].index;};}else{$("#"+childid+" a.selected").removeClass("selected");$(obj).addClass("selected");actionSettings.oldIndex=a_array[$(obj).attr("id")].index;};};};var addRefreshMethods=function(id){var objid=id;document.getElementById(objid).refresh=function(e){$("#"+objid).msDropDown(options);};};var setInsideWindow=function(val){actionSettings.insideWindow=val;};var getInsideWindow=function(){return actionSettings.insideWindow;};var applyEvents=function(){var mainid=getPostID("postID");var actions_array=attributes.actions.split(",");for(var iCount=0;iCount<actions_array.length;iCount++){var action=actions_array[iCount];var actionFound=has_handler(action);if(actionFound==true){switch(action){case"focus":$("#"+mainid).bind("mouseenter",function(event){document.getElementById(elementid).focus();});break;case"click":$("#"+mainid).bind("click",function(event){$("#"+elementid).trigger("click");});break;case"dblclick":$("#"+mainid).bind("dblclick",function(event){$("#"+elementid).trigger("dblclick");});break;case"mousedown":$("#"+mainid).bind("mousedown",function(event){$("#"+elementid).trigger("mousedown");});break;case"mouseup":$("#"+mainid).bind("mouseup",function(event){$("#"+elementid).trigger("mouseup");});break;case"mouseover":$("#"+mainid).bind("mouseover",function(event){$("#"+elementid).trigger("mouseover");});break;case"mousemove":$("#"+mainid).bind("mousemove",function(event){$("#"+elementid).trigger("mousemove");});break;case"mouseout":$("#"+mainid).bind("mouseout",function(event){$("#"+elementid).trigger("mouseout");});break;};};};};var setOutOfVision=function(){var sId=getPostID("postElementHolder");$("#"+elementid).after("<div class='"+styles.ddOutOfVision+"' style='height:0px;overflow:hidden;position:absolute;' id='"+sId+"'></div>");$("#"+elementid).appendTo($("#"+sId));};var setTitleText=function(sText){var titletextid=getPostID("postTitleTextID");$("#"+titletextid).html(sText);};var next=function(){var titletextid=getPostID("postTitleTextID");var childid=getPostID("postChildID");var allAs=$("#"+childid+" a.enabled");for(var current=0;current<allAs.length;current++){var currentA=allAs[current];var id=$(currentA).attr("id");if($(currentA).hasClass("selected")&&current<allAs.length-1){$("#"+childid+" a.selected").removeClass("selected");$(allAs[current+1]).addClass("selected");var selectedA=$("#"+childid+" a.selected").attr("id");if(!ddList){var sText=(options.showIcon==false)?a_array[selectedA].text:a_array[selectedA].html;setTitleText(sText);};if(parseInt(($("#"+selectedA).position().top+$("#"+selectedA).height()))>=parseInt($("#"+childid).height())){$("#"+childid).scrollTop(($("#"+childid).scrollTop())+$("#"+selectedA).height()+$("#"+selectedA).height());};break;};};};var previous=function(){var titletextid=getPostID("postTitleTextID");var childid=getPostID("postChildID");var allAs=$("#"+childid+" a.enabled");for(var current=0;current<allAs.length;current++){var currentA=allAs[current];var id=$(currentA).attr("id");if($(currentA).hasClass("selected")&&current!=0){$("#"+childid+" a.selected").removeClass("selected");$(allAs[current-1]).addClass("selected");var selectedA=$("#"+childid+" a.selected").attr("id");if(!ddList){var sText=(options.showIcon==false)?a_array[selectedA].text:a_array[selectedA].html;setTitleText(sText);};if(parseInt(($("#"+selectedA).position().top+$("#"+selectedA).height()))<=0){$("#"+childid).scrollTop(($("#"+childid).scrollTop()-$("#"+childid).height())-$("#"+selectedA).height());};break;};};};var setTitleImageSprite=function(){if(options.useSprite!=false){var titletextid=getPostID("postTitleTextID");var sClassName=document.getElementById(elementid).options[document.getElementById(elementid).selectedIndex].className;if(sClassName.length>0){var sStyle1=getImageFromClassName("."+sClassName);var sStyle2=getImageFromClassName("."+options.useSprite);if(sStyle1!=null&&sStyle2!=null){var bgimage=sStyle2.backgroundImage.replace(/"/gi,"");bgimage=bgimage.replace(/..\//,"");}
$("#"+titletextid).find("."+styles.ddTitleText).css('background-image',bgimage);if(sStyle1.backgroundPosition!=undefined){$("#"+titletextid).find("."+styles.ddTitleText).css('background-position',sStyle1.backgroundPosition);};$("#"+titletextid).find("."+styles.ddTitleText).css('background-repeat','no-repeat');if(sStyle2.paddingLeft!=undefined){$("#"+titletextid).find("."+styles.ddTitleText).css('padding-left',sStyle2.paddingLeft);};$("#"+titletextid).find("."+styles.ddTitleText).css('padding-bottom','2px');};};};var setValue=function(){var childid=getPostID("postChildID");var allSelected=$("#"+childid+" a.selected");if(allSelected.length==1){var sText=$("#"+childid+" a.selected").text();var selectedA=$("#"+childid+" a.selected").attr("id");if(selectedA!=undefined){var sValue=a_array[selectedA].value;document.getElementById(elementid).selectedIndex=a_array[selectedA].index;};if(options.showIcon&&options.useSprite!=false)
setTitleImageSprite();}else if(allSelected.length>1){var alls=$("#"+elementid+" > option:selected").removeAttr("selected");for(var i=0;i<allSelected.length;i++){var selectedA=$(allSelected[i]).attr("id");var index=a_array[selectedA].index;document.getElementById(elementid).options[index].selected="selected";};};var sIndex=document.getElementById(elementid).selectedIndex;$this.ddProp["selectedIndex"]=sIndex;};var has_handler=function(name){if($("#"+elementid).attr("on"+name)!=undefined){return true;};var evs=$("#"+elementid).data("events");if(evs&&evs[name]){return true;};return false;};var checkMethodAndApply=function(){var childid=getPostID("postChildID");if(has_handler('change')==true){var currentSelectedValue=a_array[$("#"+childid+" a.selected").attr("id")].text;if(selectedValue!=currentSelectedValue){$("#"+elementid).trigger("change");};};if(has_handler('mouseup')==true){$("#"+elementid).trigger("mouseup");};if(has_handler('blur')==true){$(document).bind("mouseup",function(evt){$("#"+elementid).focus();$("#"+elementid)[0].blur();setValue();$(document).unbind("mouseup");});};};var hightlightArrow=function(ison){var arrowid=getPostID("postArrowID");if(ison==1)
$("#"+arrowid).css({backgroundPosition:'0px -768px'});else
$("#"+arrowid).css({backgroundPosition:'-25px -768px'});};var setOriginalProperties=function(){for(var i in document.getElementById(elementid)){if(typeof(document.getElementById(elementid)[i])!='function'&&document.getElementById(elementid)[i]!==undefined&&document.getElementById(elementid)[i]!==null){$this.set(i,document.getElementById(elementid)[i],true);};};};var getImageFromClassName=function(selectorText){if(document.styleSheets){for(var i=document.styleSheets.length-1;i>=0;i--){var styleSheet=document.styleSheets[i];var rules;var isCSSRules=false;if(styleSheet.cssRules){rules=styleSheet.cssRules;isCSSRules=true;}else if(styleSheet.rules){rules=styleSheet.rules;};if(rules){var fullText2=('.'+options.mainCSS+' .ddChild a'+selectorText).toLowerCase();var fullText=('.'+options.mainCSS+' .ddChild a'+selectorText+', .'+options.mainCSS+' .ddChild a'+selectorText+':visited').toLowerCase();for(var j=rules.length-1;j>=0;j--){if((rules[j].selectorText).toLowerCase()==fullText||(rules[j].selectorText).toLowerCase()==fullText2){var myStyle=new Object();for(var s in rules[j].style){if(typeof(rules[j].style[s])=="string"&&rules[j].style[s].length>0){myStyle[s]=rules[j].style[s];};};return myStyle;};};};};return null;}else{return null;};};var setValueByIndex=function(prop,val){if(getByIndex(val)!=-1){document.getElementById(elementid)[prop]=val;var childid=getPostID("postChildID");$("#"+childid+" a.selected").removeClass("selected");$("#"+getByIndex(val).id).addClass("selected");var sText=getByIndex(document.getElementById(elementid).selectedIndex).html;setTitleText(sText);};};var addRemoveFromIndex=function(i,action){if(action=='d'){for(var key in a_array){if(a_array[key].index==i){delete a_array[key];break;};};};var count=0;for(var key in a_array){a_array[key].index=count;count++;};};this.open=function(){if(($this.get("disabled",true)==true)||($this.get("options",true).length==0))return;var childid=getPostID("postChildID");if(msOldDiv!=""&&childid!=msOldDiv){$("#"+msOldDiv).slideUp("fast");$("#"+msOldDiv).css({zIndex:'0'});};if($("#"+childid).css("display")=="none"){$(document).bind("keydown",function(event){var keyCode=event.keyCode;if(keyCode==39||keyCode==40){event.preventDefault();event.stopPropagation();next();};if(keyCode==37||keyCode==38){event.preventDefault();event.stopPropagation();previous();};if(keyCode==27||keyCode==13){$this.close();setValue();};if($("#"+elementid).attr("onkeydown")!=undefined){document.getElementById(elementid).onkeydown();};});$(document).bind("keyup",function(event){if($("#"+elementid).attr("onkeyup")!=undefined){document.getElementById(elementid).onkeyup();};});$(document).bind("mouseup",function(evt){if(getInsideWindow()==false){$this.close();};});$("#"+childid).css({zIndex:options.zIndex});$("#"+childid).slideDown("fast",function(){if($this.onActions["onOpen"]!=null){eval($this.onActions["onOpen"])($this);};});if(childid!=msOldDiv){msOldDiv=childid;};};};this.close=function(){var childid=getPostID("postChildID");$(document).unbind("keydown");$(document).unbind("keyup");$(document).unbind("mouseup");$("#"+childid).slideUp("fast",function(event){checkMethodAndApply();$("#"+childid).css({zIndex:'0'});if($this.onActions["onClose"]!=null){eval($this.onActions["onClose"])($this);};});};this.selectedIndex=function(i){$this.set("selectedIndex",i);};this.set=function(prop,val,isLocal){if(prop==undefined||val==undefined)throw{message:"set to what?"};$this.ddProp[prop]=val;if(isLocal!=true){switch(prop){case"selectedIndex":setValueByIndex(prop,val);break;case"disabled":$this.disabled(val,true);break;case"multiple":document.getElementById(elementid)[prop]=val;ddList=($(sElement).attr("size")>0||$(sElement).attr("multiple")==true)?true:false;if(ddList){var iHeight=$("#"+elementid).height();var childid=getPostID("postChildID");$("#"+childid).css("height",iHeight+"px");var titleid=getPostID("postTitleID");$("#"+titleid).hide();var childid=getPostID("postChildID");$("#"+childid).css({display:'block',position:'relative'});applyEventsOnA();}
break;case"size":document.getElementById(elementid)[prop]=val;if(val==0){document.getElementById(elementid).multiple=false;};ddList=($(sElement).attr("size")>0||$(sElement).attr("multiple")==true)?true:false;if(val==0){var titleid=getPostID("postTitleID");$("#"+titleid).show();var childid=getPostID("postChildID");$("#"+childid).css({display:'none',position:'absolute'});var sText="";if(document.getElementById(elementid).selectedIndex>=0){var aObj=getByIndex(document.getElementById(elementid).selectedIndex);sText=aObj.html;manageSelection($("#"+aObj.id));};setTitleText(sText);}else{var titleid=getPostID("postTitleID");$("#"+titleid).hide();var childid=getPostID("postChildID");$("#"+childid).css({display:'block',position:'relative'});};break;default:try{document.getElementById(elementid)[prop]=val;}catch(e){};break;};};};this.get=function(prop,forceRefresh){if(prop==undefined&&forceRefresh==undefined){return $this.ddProp;};if(prop!=undefined&&forceRefresh==undefined){return($this.ddProp[prop]!=undefined)?$this.ddProp[prop]:null;};if(prop!=undefined&&forceRefresh!=undefined){return document.getElementById(elementid)[prop];};};this.visible=function(val){var id=getPostID("postID");if(val==true){$("#"+id).show();}else if(val==false){$("#"+id).hide();}else{return $("#"+id).css("display");};};this.add=function(opt,index){var objOpt=opt;var sText=objOpt.text;var sValue=(objOpt.value==undefined||objOpt.value==null)?sText:objOpt.value;var img=(objOpt.title==undefined||objOpt.title==null)?'':objOpt.title;var i=(index==undefined||index==null)?document.getElementById(elementid).options.length:index;document.getElementById(elementid).options[i]=new Option(sText,sValue);if(img!='')document.getElementById(elementid).options[i].title=img;var ifA=getByIndex(i);if(ifA!=-1){var aTag=createA(document.getElementById(elementid).options[i],i,"","");$("#"+ifA.id).html(aTag);}else{var aTag=createA(document.getElementById(elementid).options[i],i,"","");var childid=getPostID("postChildID");$("#"+childid).append(aTag);applyEventsOnA();};};this.remove=function(i){document.getElementById(elementid).remove(i);if((getByIndex(i))!=-1){$("#"+getByIndex(i).id).remove();addRemoveFromIndex(i,'d');};if(document.getElementById(elementid).length==0){setTitleText("");}else{var sText=getByIndex(document.getElementById(elementid).selectedIndex).html;setTitleText(sText);};$this.set("selectedIndex",document.getElementById(elementid).selectedIndex);};this.disabled=function(dis,isLocal){document.getElementById(elementid).disabled=dis;var id=getPostID("postID");if(dis==true){$("#"+id).css("opacity",styles.disabled);$this.close();}else if(dis==false){$("#"+id).css("opacity",1);};if(isLocal!=true){$this.set("disabled",dis);};};this.form=function(){return(document.getElementById(elementid).form==undefined)?null:document.getElementById(elementid).form;};this.item=function(){if(arguments.length==1){return document.getElementById(elementid).item(arguments[0]);}else if(arguments.length==2){return document.getElementById(elementid).item(arguments[0],arguments[1]);}else{throw{message:"An index is required!"};};};this.namedItem=function(nm){return document.getElementById(elementid).namedItem(nm);};this.multiple=function(is){if(is==undefined){return $this.get("multiple");}else{$this.set("multiple",is);};};this.size=function(sz){if(sz==undefined){return $this.get("size");}else{$this.set("size",sz);};};this.addMyEvent=function(nm,fn){$this.onActions[nm]=fn;};this.fireEvent=function(nm){eval($this.onActions[nm])($this);};var updateCommonVars=function(){$this.set("version",$.msDropDown.version);$this.set("author",$.msDropDown.author);};var init=function(){createDropDown();setOriginalProperties();updateCommonVars();if(options.onInit!=''){eval(options.onInit)($this);};};init();};$.msDropDown={version:2.2,author:"Marghoob Suleman",create:function(id,opt){return $(id).msDropDown(opt).data("dd");}};$.fn.extend({msDropDown:function(options)
{return this.each(function()
{var mydropdown=new dd(this,options);$(this).data('dd',mydropdown);});}});})(jQuery);(function($){$.toJSON=function(o)
{if(typeof(JSON)=='object'&&JSON.stringify)
return JSON.stringify(o);var type=typeof(o);if(o===null)
return"null";if(type=="undefined")
return undefined;if(type=="number"||type=="boolean")
return o+"";if(type=="string")
return $.quoteString(o);if(type=='object')
{if(typeof o.toJSON=="function")
return $.toJSON(o.toJSON());if(o.constructor===Date)
{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array)
{var ret=[];for(var i=0;i<o.length;i++)
ret.push($.toJSON(o[i])||"null");return"["+ret.join(",")+"]";}
var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number")
name='"'+k+'"';else if(type=="string")
name=$.quoteString(k);else
continue;if(typeof o[k]=="function")
continue;var val=$.toJSON(o[k]);pairs.push(name+":"+val);}
return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);return eval("("+src+")");};$.secureEvalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
return eval("("+src+")");else
throw new SyntaxError("Error parsing JSON, source is not valid.");};$.quoteString=function(string)
{if(string.match(_escapeable))
{return'"'+string.replace(_escapeable,function(a)
{var c=_meta[a];if(typeof c==='string')return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};})(jQuery);if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());;(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};$scrollTo.window=function(scope){return $(window)._scrollable();};$.fn._scrollable=function(){return this.map(function(){var elem=this,isWin=!elem.nodeName||$.inArray(elem.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)
return elem;var doc=(elem.contentWindow||elem).document||elem.ownerDocument||elem;return $.browser.safari||doc.compatMode=='BackCompat'?doc.body:doc.documentElement;});};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
if(typeof settings=='function')
settings={onAfter:settings};if(target=='max')
target=9e9;settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)
duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this._scrollable().each(function(){var elem=this,$elem=$(elem),targ=target,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break;}
targ=$(targ,this);case'object':if(targ.is||targ.style)
toff=(targ=$(targ)).offset();}
$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,old=elem[key],max=$scrollTo.max(elem,axis);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(targ.css('margin'+Pos))||0;attr[key]-=parseInt(targ.css('border'+Pos+'Width'))||0;}
attr[key]+=settings.offset[pos]||0;if(settings.over[pos])
attr[key]+=targ[axis=='x'?'width':'height']()*settings.over[pos];}else{var val=targ[pos];attr[key]=val.slice&&val.slice(-1)=='%'?parseFloat(val)/100*max:val;}
if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&settings.queue){if(old!=attr[key])
animate(settings.onAfterFirst);delete attr[key];}});animate(settings.onAfter);function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target,settings);});};}).end();};$scrollTo.max=function(elem,axis){var Dim=axis=='x'?'Width':'Height',scroll='scroll'+Dim;if(!$(elem).is('html,body'))
return elem[scroll]-$(elem)[Dim.toLowerCase()]();var size='client'+Dim,html=elem.ownerDocument.documentElement,body=elem.ownerDocument.body;return Math.max(html[scroll],body[scroll])
-Math.min(html[size],body[size]);};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(jQuery);(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}
if(p==this){return false;}
var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}
if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);(function($){var baseClasses=/ui-checkbox|ui-radio/;$.widget('ui.checkBox',{options:{hideInput:true,addVisualElement:true,addLabel:false,_delegated:false},_create:function(){var that=this,opts=this.options;if(!this.element.is(':radio,:checkbox')){if($.nodeName(this.element[0],'input')){return false;}
this._addDelegate();this.updateContainer();return false;}
this.labels=$([]);this.checkedStatus=false;this.disabledStatus=false;this.hoverStatus=false;this.radio=(this.element.is(':radio'));this.visualElement=$([]);if(opts.hideInput){this.element.addClass('ui-helper-hidden-accessible');if(opts.addVisualElement){this.visualElement=$('<span />').addClass(this.radio?'ui-radio':'ui-checkbox');this.element.after(this.visualElement[0]);}}
if(opts.addLabel){this.labels=$('label[for='+this.element.attr('id')+']').addClass(this.radio?'ui-radio':'ui-checkbox');}
if(!opts._delegated){this._addEvents();}
this.initialized=true;this.reflectUI({type:'initialReflect'});return undefined;},updateContainer:function(){if(!this.element.is(':radio,:checkbox')&&!$.nodeName(this.element[0],'input')){$('input',this.element[0]).filter(function(){return!($.data(this,'checkBox'));}).checkBox($.extend({},this.options,{_delegated:true}));}},_addDelegate:function(){var opts=this.options,toggleHover=function(e,that){if(!that){return;}
that.hover=!!(e.type=='focus'||e.type=='mouseenter'||e.type=='focusin'||e.type=='mouseover');that._changeStateClassChain.call(that);return undefined;};this.element.bind('click',function(e){if(!$.nodeName(e.target,'input')){return;}
var inst=($.data(e.target)||{}).checkBox;if(!inst){return;}
inst.reflectUI.call(inst,e.target,e);}).bind('focusin.checkBox focusout.checkBox',function(e){if(!$.nodeName(e.target,'input')){return;}
var inst=($.data(e.target)||{}).checkBox;toggleHover(e,inst);});if(opts.hideInput){this.element.bind('usermode',function(e){if(!e.enabled){return;}
$('input',this).each(function(){var inst=($.data(this)||{}).checkBox;(inst&&inst.destroy.call(inst,true));});});}
if(opts.addVisualElement){this.element.bind('mouseover.checkBox mouseout.checkBox',function(e){if(!$.nodeName(e.target,'span')){return;}
var inst=($.data($(e.target).prev()[0])||{}).checkBox;toggleHover(e,inst);}).bind('click.checkBox',function(e){if(!$.nodeName(e.target,'span')||!baseClasses.test(e.target.className||'')){return;}
$(e.target).prev()[0].click();return false;});}
if(opts.addLabel){this.element.delegate('label.ui-radio, label.ui-checkbox','mouseenter.checkBox mouseleave.checkBox',function(e){var inst=($.data(document.getElementById($(this).attr('for')))||{}).checkBox;toggleHover(e,inst);});}},_addEvents:function(){var that=this,opts=this.options,toggleHover=function(e){if(that.disabledStatus){return false;}
that.hover=(e.type=='focus'||e.type=='mouseenter');that._changeStateClassChain();return undefined;};this.element.bind('click.checkBox',$.proxy(this,'reflectUI')).bind('focus.checkBox blur.checkBox',toggleHover);if(opts.hideInput){this.element.bind('usermode',function(e){(e.enabled&&that.destroy.call(that,true));});}
if(opts.addVisualElement){this.visualElement.bind('mouseenter.checkBox mouseleave.checkBox',toggleHover).bind('click.checkBox',function(e){that.element[0].click();return false;});}
if(opts.addLabel){this.labels.bind('mouseenter.checkBox mouseleave.checkBox',toggleHover);}},_changeStateClassChain:function(){var allElements=this.labels.add(this.visualElement),stateClass='',baseClass='ui-'+((this.radio)?'radio':'checkbox');if(this.checkedStatus){stateClass+='-checked';allElements.addClass(baseClass+'-checked');}else{allElements.removeClass(baseClass+'-checked');}
if(this.disabledStatus){stateClass+='-disabled';allElements.addClass(baseClass+'-disabled');}else{allElements.removeClass(baseClass+'-disabled');}
if(this.hover){stateClass+='-hover';allElements.addClass(baseClass+'-hover');}else{allElements.removeClass(baseClass+'-hover');}
baseClass+='-state';if(stateClass){stateClass=baseClass+stateClass;}
function switchStateClass(){var classes=this.className.split(' '),found=false;$.each(classes,function(i,classN){if(classN.indexOf(baseClass)===0){found=true;classes[i]=stateClass;return false;}
return undefined;});if(!found){classes.push(stateClass);}
this.className=classes.join(' ');}
this.labels.each(switchStateClass);this.visualElement.each(switchStateClass);},destroy:function(onlyCss){this.element.removeClass('ui-helper-hidden-accessible');this.visualElement.addClass('ui-helper-hidden');if(!onlyCss){var o=this.options;this.element.unbind('.checkBox');this.visualElement.remove();this.labels.unbind('.checkBox').removeClass('ui-state-hover ui-state-checked ui-state-disabled');}},disable:function(){this.element[0].disabled=true;this.reflectUI({type:'manuallyDisabled'});},enable:function(){this.element[0].disabled=false;this.reflectUI({type:'manuallyenabled'});},toggle:function(e){this.changeCheckStatus((this.element.is(':checked'))?false:true,e);},changeCheckStatus:function(status,e){if(e&&e.type=='click'&&this.element[0].disabled){return false;}
this.element.attr({'checked':status});this.reflectUI(e||{type:'changeCheckStatus'});return undefined;},propagate:function(n,e,_noGroupReflect){if(!e||e.type!='initialReflect'){if(this.radio&&!_noGroupReflect){$(document.getElementsByName(this.element.attr('name'))).checkBox('reflectUI',e,true);}
return this._trigger(n,e,{options:this.options,checked:this.checkedStatus,labels:this.labels,disabled:this.disabledStatus});}
return undefined;},reflectUI:function(e){var oldChecked=this.checkedStatus,oldDisabledStatus=this.disabledStatus;this.disabledStatus=this.element.is(':disabled');this.checkedStatus=this.element.is(':checked');if(this.disabledStatus!=oldDisabledStatus||this.checkedStatus!==oldChecked){this._changeStateClassChain();(this.disabledStatus!=oldDisabledStatus&&this.propagate('disabledChange',e));(this.checkedStatus!==oldChecked&&this.propagate('change',e));}}});})(jQuery);(function(){var cloneEls=new Object();var numColsById=new Object();var uniqueId=0;function _layoutElement(elDOM,settings,balance){var colHeight;var colWidth;var col;var currentColEl;var cols=new Array();var colNum=0;var colSet=0;var el=jQuery(elDOM);numColsById[elDOM.id]=settings.columns;el.empty();function _newColumn(){colNum++;col=document.createElement("DIV");col.className=settings.column;el.append(col);currentColEl=col;colWidth=jQuery(col).width();cols.push(col);for(var j=0;j<subnodes.length;j++){newEl=subnodes[j].cloneNode(false);if(j==0||innerContinued){jQuery(newEl).addClass(settings.continued);}
currentColEl.appendChild(newEl);currentColEl=newEl;}}
function _getMarginBottom(currentColEl){var marginBottom=parseInt(jQuery(currentColEl).css("marginBottom"));if(marginBottom.toString()=='NaN'){marginBottom=0;}
var currentColElParents=jQuery(currentColEl).parents();for(var j=0;j<currentColElParents.length;j++){if(currentColElParents[j]==elDOM){break;}
var curMarginBottom=parseInt(jQuery(currentColElParents[j]).css("marginBottom"));if(curMarginBottom.toString()!='NaN'){marginBottom=Math.max(marginBottom,curMarginBottom);}}
return marginBottom;}
function _skipToNextNode(){while(currentEl&&currentColEl&&!currentEl.nextSibling){currentEl=currentEl.parentNode;currentColEl=currentColEl.parentNode;var node=subnodes.pop();if(node=="A"){href=null;}}
if(currentEl){currentEl=currentEl.nextSibling;}}
var maxHeight=settings.height?settings.height:parseInt(el.css("maxHeight"));if(balance||isNaN(maxHeight)||maxHeight==0){col=document.createElement("DIV");col.className=settings.column;jQuery(col).append(jQuery(cloneEls[elDOM.id]).html());el.append(col);var lineHeight=parseInt(el.css("lineHeight"));if(!lineHeight){lineHeight=Math.ceil(parseInt(el.css("fontSize"))*1.2);}
colHeight=Math.ceil(jQuery(col).height()/settings.columns);if(colHeight%lineHeight>0){colHeight+=lineHeight;}
elDOM.removeChild(col);if(maxHeight>0&&colHeight>maxHeight){colHeight=maxHeight;}}else{colHeight=maxHeight;}
var minHeight=settings.minHeight?settings.minHeight:parseInt(el.css("minHeight"));if(minHeight){colHeight=Math.max(colHeight,minHeight);}
var currentEl=cloneEls[elDOM.id].children(":first")[0];var subnodes=new Array();var href=null;var lastNodeType=0;_newColumn();if(colHeight==0||colWidth==0){return false;}
while(currentEl){if(currentEl.nodeType==1){var newEl;var $currentEl=jQuery(currentEl);if($currentEl.hasClass("dontSplit")||$currentEl.is(settings.dontsplit)){var newEl=currentEl.cloneNode(true);currentColEl.appendChild(newEl);if(col.offsetHeight>colHeight){_newColumn();}
_skipToNextNode();}else{var newEl=currentEl.cloneNode(false);currentColEl.appendChild(newEl);if(col.offsetHeight-_getMarginBottom(currentColEl)>colHeight){currentColEl.removeChild(newEl);var toBeInsertedEl=newEl;_newColumn();currentColEl.appendChild(toBeInsertedEl);newEl=toBeInsertedEl;}
if(currentEl.firstChild){subnodes.push(currentEl.cloneNode(false));currentColEl=newEl;currentEl=currentEl.firstChild;}else{_skipToNextNode();}}
lastNodeType=1;}else if(currentEl.nodeType==3){var newEl=document.createTextNode("");currentColEl.appendChild(newEl);var marginBottom=_getMarginBottom(currentColEl);var words=currentEl.data.split(" ");for(var i=0;i<words.length;i++){if(lastNodeType==3){newEl.appendData(" ");}
newEl.appendData(words[i]);currentColEl.removeChild(newEl);currentColEl.appendChild(newEl);if(col.offsetHeight-marginBottom>colHeight){newEl.data=newEl.data.substr(0,newEl.data.length-words[i].length-1);var innerContinued;if(jQuery(currentColEl).text()==""){jQuery(currentColEl).remove();innerContinued=false;}else{innerContinued=true;}
_newColumn();newEl=document.createTextNode(words[i]);currentColEl.appendChild(newEl);}
lastNodeType=3;}
_skipToNextNode();lastNodeType=0;}else{_skipToNextNode();lastNodeType=currentEl.nodeType;}}
return cols;};jQuery.fn.columnize=function(settings){settings=jQuery.extend({column:"column",continued:"continued",columns:2,balance:true,height:false,minHeight:false,cache:true,dontsplit:""},settings);this.each(function(){var jthis=jQuery(this);var id=this.id;if(!id){id="jcols_"+uniqueId;this.id=id;uniqueId++;}
if(!cloneEls[this.id]||!settings.cache){cloneEls[this.id]=jthis.clone(true);}
var cols=_layoutElement(this,settings,settings.balance);if(!cols){jthis.append(cloneEls[this.id].children().clone(true));}});return this;}})();
