/**** /community/_scripts/citypicker.js ****/

function calculateHW() {
    var viewWidth, viewHeight, bodyWidth, bodyHeight; bodyHeight = $(document).height(); bodyWidth = $(document).width(); if (self.innerHeight)
    { viewWidth = self.innerWidth; viewHeight = self.innerHeight; }
    else if (document.documentElement && document.documentElement.clientHeight) { viewWidth = document.documentElement.clientWidth; viewHeight = document.documentElement.clientHeight; }
    else if (document.body) { viewWidth = document.body.clientWidth; viewHeight = document.body.clientHeight; }
    if (viewWidth < 982) { bodyWidth = 982; }
    if (bodyHeight < viewHeight) { bodyHeight = viewHeight; }
    $('#dim_bg').css('height', bodyHeight); $('#dim_bg iframe').css('height', bodyHeight); $('#popupcitypicker').css('height', bodyHeight); $('#dim_bg').css('width', bodyWidth); $('#dim_bg iframe').css('width', bodyWidth); $('#popupcitypicker').css('width', bodyWidth); if (etagHelper) { etagHelper.addEtag({ "etag": "<%=this.CurrentPageContext.Etag %>" }); } 
}
function popupCityPicker() { if ($('#popupcitypicker').val() != undefined) { $('#dim_bg').show(); $('#dim_bg').css('opacity', 0.7).fadeTo('slow', 0.7); $('#popupcitypicker').show(); $('#popupcitypicker').css('opacity', 1).fadeTo('slow', 1); } }
function closeCityPicker() { $('#dim_bg').hide(); $('#popupcitypicker').hide(); }
function getCities(strValue) {
    var idx = cityPickerJson.length; while (idx) {
        idx--; if (cityPickerJson[idx].v == strValue)
            return cityPickerJson[idx].c;
    }
    return "";
}
function makeOptionsFragment(jsonCities) {
    var oFrag = document.createDocumentFragment(); var oTextNode = null, oElement = null, oAttribute = null; var idx = jsonCities.length; while (idx) { idx--; oText = document.createTextNode(jsonCities[idx].t); oElement = document.createElement("option"); oElement.appendChild(oText); oElement.setAttribute("value", jsonCities[idx].v); oFrag.appendChild(oElement); }
    return oFrag;
}
function pickState(oElem) { var oTarget = document.getElementById("ddlCity"); oTarget.options.length = 1; var cities = getCities(oElem.value); var oFrag = makeOptionsFragment(cities); oTarget.appendChild(oFrag); }
function pickCity(oElem) { window.location = "?citycode=" + oElem.value; }
/**** /community/_scripts/teacherbox.js ****/

var browser_webkit=jQuery.browser.webkit;function clearInputs(){jQuery('input:text, input:password, textarea').each(function(){var _el=jQuery(this);_el.data('val',_el.val());_el.bind('focus',function(){if(_el.val()==_el.data('val'))_el.val('');}).bind('blur',function(){if(_el.val()==''||_el.val()==' ')_el.val(_el.data('val'));});});}
function ieHover(h_list,h_class){if(jQuery.browser.msie&&jQuery.browser.version<7){if(!h_class)var h_class='hover';jQuery(h_list).mouseenter(function(){jQuery(this).addClass(h_class);}).mouseleave(function(){jQuery(this).removeClass(h_class);});}}
function applyTab20(){jQuery('input:checkbox').customCheckbox();clearInputs();jQuery('div.scrollable2').customScrollV();jQuery('a.teacher_popup').fancybox({'overlayColor':'#000','overlayOpacity':0.7,'modal':true});jQuery('.popup a.close').click(function(){jQuery.fancybox.close();});}
function getCaretPos(obj){if(obj){obj.focus();if(obj.selectionStart){return obj.selectionStart;}
else if(document.selection){var sel=document.selection.createRange();var clone=sel.duplicate();sel.collapse(true);clone.moveToElementText(obj);clone.setEndPoint('EndToEnd',sel);return clone.text.length;}
return 0;}}
function setCaretPos(obj,pos){if(obj){if(obj.setSelectionRange){obj.setSelectionRange(pos,pos);}
else if(this.createTextRange){var range=this.createTextRange();range.collapse(true);range.moveEnd('character',pos);range.moveStart('character',pos);range.select();}}}
var types=['DOMMouseScroll','mousewheel'];jQuery.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;}};jQuery.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 args=[].slice.call(arguments,1),delta=0,returnValue=true;event=jQuery.event.fix(event||window.event);event.type="mousewheel";if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;args.unshift(event,delta);return jQuery.event.handle.apply(this,args);}
jQuery.fn.customScrollV=function(_options){var _options=jQuery.extend({lineWidth:11},_options);return this.each(function(){var _box=jQuery(this);if(_box.is(':visible')){if(_box.children('.scroll-content').length==0){var line_w=_options.lineWidth;var scrollBar=jQuery('<div class="scroll-bar"><div class="scroll-up"></div><div class="scroll-line"><div class="scroll-slider"></div></div><div class="scroll-down"></div></div>');_box.wrapInner('<div class="scroll-content"><div class="scroll-hold"></div></div>').append(scrollBar);var scrollContent=_box.children('.scroll-content');var scrollSlider=scrollBar.find('.scroll-slider');var scrollSliderH=scrollSlider.parent();var scrollUp=scrollBar.find('.scroll-up');var scrollDown=scrollBar.find('.scroll-down');var box_h=_box.height();var slider_h=0;var slider_f=0;var cont_h=scrollContent.height();var _f=false;var _f1=false;var _f2=true;var _t1,_t2,_s1,_s2;_box.css({position:'relative',overflow:'hidden',height:box_h});scrollContent.css({position:'absolute',top:0,left:0,zIndex:1,height:'auto'});scrollBar.css({position:'absolute',top:0,right:0,zIndex:2,width:line_w,height:box_h,overflow:'hidden'});scrollUp.css({width:line_w,height:line_w,overflow:'hidden',cursor:'pointer'});scrollDown.css({width:line_w,height:line_w,overflow:'hidden',cursor:'pointer'});slider_h=scrollBar.height();if(scrollUp.is(':visible'))slider_h-=scrollUp.height();if(scrollDown.is(':visible'))slider_h-=scrollDown.height();scrollSliderH.css({position:'relative',width:line_w,height:slider_h,overflow:'hidden'});slider_h=0;scrollSlider.css({position:'absolute',top:0,left:0,width:line_w,height:slider_h,overflow:'hidden',cursor:'pointer'});box_h=_box.height();cont_h=scrollContent.height();if(box_h<cont_h){_f=true;slider_h=Math.round(box_h/cont_h*scrollSliderH.height());if(slider_h<5)slider_h=5;scrollSlider.height(slider_h);slider_h=scrollSlider.outerHeight();slider_f=(cont_h-box_h)/(scrollSliderH.height()-slider_h);_s1=(scrollSliderH.height()-slider_h)/15;_s2=(scrollSliderH.height()-slider_h)/3;scrollContent.children('.scroll-hold').css('padding-right',scrollSliderH.width());}
else{_f=false;scrollBar.hide();scrollContent.css({width:_box.width(),top:0,left:0});scrollContent.children('.scroll-hold').css('padding-right',0);}
var _top=0;scrollUp.mousedown(function(){_top-=_s1;scrollCont();_t1=setTimeout(function(){_t2=setInterval(function(){_top-=4/slider_f;scrollCont();},20);},500);}).mouseup(function(){if(_t1)clearTimeout(_t1);if(_t2)clearInterval(_t2);}).mouseleave(function(){if(_t1)clearTimeout(_t1);if(_t2)clearInterval(_t2);});scrollDown.mousedown(function(){_top+=_s1;scrollCont();_t1=setTimeout(function(){_t2=setInterval(function(){_top+=4/slider_f;scrollCont();},20);},500);}).mouseup(function(){if(_t1)clearTimeout(_t1);if(_t2)clearInterval(_t2);}).mouseleave(function(){if(_t1)clearTimeout(_t1);if(_t2)clearInterval(_t2);});scrollSliderH.click(function(e){if(_f2){_top=e.pageY-scrollSliderH.offset().top;scrollCont();}
else{_f2=true;}});var t_y=0;scrollSlider.mousedown(function(e){t_y=e.pageY-jQuery(this).position().top;_f1=true;}).mouseup(function(){_f1=false;});jQuery('body').mousemove(function(e){if(_f1){_f2=false;_top=e.pageY-t_y;scrollCont();}}).mouseup(function(){_f1=false;});document.body.onselectstart=function(){if(_f1)return false;}
_box.bind('mousewheel',function(event,delta){if(_f){_top-=delta*_s1;scrollCont();if((_top>0)&&(_top+slider_h<scrollSliderH.height()))return false;}});function scrollCont(){if(_top<0)_top=0;else if(_top+slider_h>scrollSliderH.height())_top=scrollSliderH.height()-slider_h;scrollSlider.css('top',_top);scrollContent.css('top',-_top*slider_f);}
this.scrollResize=function(){box_h=_box.height();cont_h=scrollContent.height();if(box_h<cont_h){_f=true;scrollBar.show();slider_h=Math.round(box_h/cont_h*scrollSliderH.height());if(slider_h<5)slider_h=5;scrollSlider.height(slider_h);slider_h=scrollSlider.outerHeight();slider_f=(cont_h-box_h)/(scrollSliderH.height()-slider_h);if(cont_h+scrollContent.position().top<box_h)scrollContent.css('top',-(cont_h-box_h));_top=-scrollContent.position().top/slider_f;scrollSlider.css('top',_top);_s1=(scrollSliderH.height()-slider_h)/15;_s2=(scrollSliderH.height()-slider_h)/3;scrollContent.children('.scroll-hold').css('padding-right',scrollSliderH.width());}
else{_f=false;scrollBar.hide();scrollContent.css({top:0,left:0});scrollContent.children('.scroll-hold').css('padding-right',0);}}}
else{this.scrollResize();}}});}
jQuery.fn.customCheckbox=function(_options){var _options=jQuery.extend({checkboxStructure:'<div></div>',checkboxDisabled:'disabled',checkboxDefault:'checkboxArea',checkboxChecked:'checkboxAreaChecked'},_options);return this.each(function(){var checkbox=jQuery(this);if(!checkbox.hasClass('outtaHere')&&checkbox.is(':checkbox')){var replaced=jQuery(_options.checkboxStructure);this._replaced=replaced;if(checkbox.is(':disabled'))replaced.addClass(_options.checkboxDisabled);else if(checkbox.is(':checked'))replaced.addClass(_options.checkboxChecked);else replaced.addClass(_options.checkboxDefault);replaced.click(function(){if(checkbox.is(':checked'))checkbox.removeAttr('checked');else checkbox.attr('checked','checked');changeCheckbox(checkbox);});checkbox.click(function(){changeCheckbox(checkbox);});replaced.insertBefore(checkbox);checkbox.addClass('outtaHere');}});function changeCheckbox(_this){_this.change();if(_this.is(':checked'))_this.get(0)._replaced.removeClass().addClass(_options.checkboxChecked);else _this.get(0)._replaced.removeClass().addClass(_options.checkboxDefault);}}
var teacherBoxContent;function chinaheaderbg(){jQuery("#partnerheader").addClass("ctr_cn");}
function GetRandom(n){var igetrandom=Math.floor(Math.random()*n+1)
return igetrandom;}
function LoadTeachers(){jQuery.ajax({url:"../dailylesson/lessonhandler.ashx?operate=getteacherbox",type:"GET",dataType:"json",timeout:5000,async:true,cache:true,error:function(XMLHttpRequest,textStatus,errorThrown){alert('Error getting information...'+textStatus);return false;},success:function(data){teacherBoxContent=data;BindTeacherBox(teacherBoxContent);SetCountdown();}});}
var rotationNumber=0;function BindTeacherBox(data){var currentTeachers;rotationNumber=data.RotationNumber;currentTeachers=new Array();if(data.RotationNumber==0){currentTeachers=data.Teachers.slice(0,4);}
else if(data.RotationNumber==1){currentTeachers=data.Teachers.slice(4,8);}
else{currentTeachers=data.Teachers.slice(8,12);}
var teacherItems=jQuery("ul.teacher-list li");for(var i=0;i<teacherItems.length;i++){var j=i>=4?i-4:i;teacherItems.eq(i).find("strong").text(currentTeachers[j].Name);teacherItems.eq(i).find(".photo img").css("left","0px");teacherItems.eq(i).find(".photo img").css("top",(data.RotationNumber*4+parseInt(j))*(-66)+"px");teacherItems.eq(i).find(".photo img").attr("alt",currentTeachers[j].Name);teacherItems.eq(i).find(".flag").eq(0).css("left","0px");teacherItems.eq(i).find(".flag").eq(0).css("top",GetTeacherFlagCSSTopValue(currentTeachers[j].Flag));teacherItems.eq(i).find(".teacher_popup").attr("name",i);}
jQuery(".teacher_popup").click(function(){var k=this.name==""?0:this.name;if(k>4&&k<8){k=k-4;}
else if(k>7&&k<12){k=k-8;}
jQuery(".popup .text-box P").text(jQuery("ul.teacher-list li").eq(k).find(".text-box P").text());jQuery(".popup .photo img").css("left","0px");jQuery(".popup .photo img").css("top",(rotationNumber*4+parseInt(k))*(-66)+"px");jQuery(".popup .photo img").attr("alt",currentTeachers[k].Name);jQuery(".popup .text-box strong").text(currentTeachers[k].Name);jQuery(".popup .flag").css("left","0px");jQuery(".popup .flag").css("top",GetTeacherFlagCSSTopValue(currentTeachers[k].Flag));});data.RotationNumber++;if(data.RotationNumber>2){data.RotationNumber=0;}}
function GetTeacherFlagCSSTopValue(flag){var value;if(flag.indexOf("au.gif")!=-1){value="-792px";}
else if(flag.indexOf("ca.gif")!=-1){value="-815px";}
else if(flag.indexOf("unitedkingdom.gif")!=-1){value="-838px";}
else if(flag.indexOf("us.gif")!=-1){value="-861px";}
return value;}
function SetCountdown(){var now=new Date();var minuteLeft=59-now.getMinutes();var secondLeft=59-now.getSeconds();if(minuteLeft<10){minuteLeft="0"+minuteLeft}
if(secondLeft<10){secondLeft="0"+secondLeft}
jQuery(".countdown .num").text(minuteLeft+":"+secondLeft);if(minuteLeft==0&&secondLeft==0){BindTeacherBox(teacherBoxContent);}
setTimeout(SetCountdown,1000);}
function getUrlParam(){var _tbox=document.location.search.substring(document.location.search.indexOf("tbox")+5,document.location.search.indexOf("tbox")+6);if(_tbox!=null){return _tbox;}
return"";}
function initSlider(){var _parentSlide='div.box';var _linkSlide='.opener';var _slideBlock='div.slide-box';var _openClassS='active';var _durationSlide=500;jQuery(_parentSlide).each(function(){if(!jQuery(this).is('.'+_openClassS)){jQuery(this).find(_slideBlock).css('display','none');}});jQuery(_linkSlide,_parentSlide).click(function(){if(jQuery(this).parents(_parentSlide).is('.'+_openClassS)){jQuery(this).parents(_parentSlide).removeClass(_openClassS);jQuery(this).parents(_parentSlide).find(_slideBlock).slideUp(_durationSlide);}else{jQuery(this).parents(_parentSlide).addClass(_openClassS);jQuery(this).parents(_parentSlide).find(_slideBlock).slideDown(_durationSlide);}
return false;});if(getUrlParam()=='2'){if(jQuery(_linkSlide).parents(_parentSlide).is('.'+_openClassS)){jQuery(_linkSlide).parents(_parentSlide).removeClass(_openClassS);jQuery(_linkSlide).parents(_parentSlide).find(_slideBlock).slideUp(_durationSlide);}else{jQuery(_linkSlide).parents(_parentSlide).addClass(_openClassS);jQuery(_linkSlide).parents(_parentSlide).find(_slideBlock).slideDown(_durationSlide);}}}
function _mainPopup(){var i=0;var _mainPopupId='_mainPopupId'
var _parentSlide='div.popup-block';var _linkSlide='.open';var _slideBlock='div.popup';var _openClass='active';var _durationSlide=500;var _Yoff=20;var _Xoff=-10;jQuery(_parentSlide).each(function(_ind){var content=jQuery(this).find('.popup').html();jQuery("body").append("<div id='"+_mainPopupId+_ind+"' class='mainpopup'><div class='mainpopup-w1'><div class='mainpopup-w2'><div class='mainpopup-w3'><div class='close'><a href='#'>"+blurbclose+"</a></div>"+content+"</div></div><span class='mainpopup-bottom'>&nbsp;</span></div></div>");jQuery("#"+_mainPopupId+(_ind)).css({position:'absolute',display:'none'});})
var _popups=jQuery('.mainpopup');var _links=jQuery(_parentSlide+" "+_linkSlide);_links.click(function(){var _index=_links.index(jQuery(this));if(!jQuery(this).hasClass(_openClass)){var _off=jQuery(this).offset();jQuery(this).addClass(_openClass);_popups.eq(_index).css({display:'block',top:(_off.top+_Yoff)+"px",left:(_off.left+_Xoff)+"px"})}else{jQuery(this).removeClass(_openClass);_popups.eq(_index).hide();}
return false;})
if(getUrlParam()=='3'){var _index=_links.index(jQuery(_links));if(!jQuery(_links).hasClass(_openClass)){var _off=jQuery(_links).offset();jQuery(_links).addClass(_openClass);_popups.eq(_index).css({display:'block',top:(_off.top+_Yoff)+"px",left:(_off.left+_Xoff)+"px"})}else{jQuery(_links).removeClass(_openClass);_popups.eq(_index).hide();}}
_popups.each(function(){var _this=jQuery(this);jQuery('div.close a',_this).click(function(){_this.hide();_links.eq(_popups.index(_this)).removeClass(_openClass);return false;});})}

/**** USB-CMMTY2 09/06/2010 06:10:11 ****/
