(function($){$.ic=function(){return this};$.ic=$.extend($.ic,{storage:{site_ID:0,module_ID:0,browserWarning_flag:false,modulesDirectory:'../application/modules/',dialogCallbacks:{},exclude_tabs:{},feature_scroll:0},initParts:{shrinkMe:function(){},initStorage:function(){},checkFireFox:function(){if(!$.browser.mozilla&&!jQuery.ic.storage.browser_warning_flag){alert('InControl2 currently supports only Firefox. Other browsers may not work.');jQuery.ic.storage.browser_warning_flag=true}},initPage:function(){jQuery.ic.switchSite();$('#loadingBit').hide();$('#wrapper').fadeIn(500);setTimeout("$.ic.checkTimeout();",60000)}},switchSite:function(siteID){$('.module_items').fadeOut(300);if(siteID){$.ic.loading()}MCE_clear();if(!siteID){siteID=0}$.ic.checkTimeout();$.getJSON('/html/index/switch?site_ID='+siteID,{},function(data,s){var html='';for(var proc in data){var but=data[proc];html+='<li><img class="moduleButton" src="images/'+but.pic+'" id="moduleButton_'+but.short_name+'" alt="'+but.name+'" onClick="jQuery.ic.loadModule(\''+but.short_name+'\');" /></li>'}$('.module_items').html(html);jQuery.ic.loadModule();$.ic.loading_stop();$('.module_items').fadeIn(300)})},loadModule:function(module){MCE_clear();if(module==undefined){module=''}$('#wrapper > #content > #content_body').fadeOut(300,function(){$.ic.loading()});$.get('module-loader?ajax=1&module='+module,function(xh,s){xh=$(xh);var longName=$('name',xh).text();var shortName=$('id',xh).text();var controller=$('controller',xh).text();if(!shortName||!controller){window.location='/html/login?timeout=1';return}$.ic.storage.excludetabs={};var e=$('excludetabs',xh).text().split(',');for(var proc in e){$.ic.storage.excludetabs[e[proc]]=true}$('#title_content').html(longName);$('jsIncludes > include',xh).each(function(){$.include($('file',this).text());eval($('init',this).text())});$('#content_body').load(controller+'?ajax=1&module='+shortName,function(xh,s){$.ic.loading_stop();$('#wrapper > #content > #content_body').fadeIn(300)})},'xml')},init:function(){for(var part in jQuery.ic.initParts){try{jQuery.ic.initParts[part]()}catch(err){}}},dialog_superbasic:function(tag,w,h,label){w=w==undefined?300:w;h=h==undefined?200:h;$('#__dialogBox__'+tag).dialog({draggable:false,resizable:false,title:label,stack:true,height:h,width:w,overlay:{background:'black',width:'100%',height:'100%',opacity:.15}})},dialog_basic:function(tag,w,h){w=w==undefined?300:w;h=h==undefined?200:h;$('#__dialogBox__'+tag).dialog({draggable:false,resizable:false,title:'Notice',stack:true,height:h,width:w,overlay:{background:'black',width:'100%',height:'100%',opacity:.15}})},dialog_graphic:function(tag,w,h){w=w==undefined?300:w;h=h==undefined?200:h;$('#__dialogBox__'+tag).dialog({draggable:false,resizable:false,title:'Loading',stack:true,modal:false,height:h,width:w,overlay:{background:'black',width:'100%',height:'100%',opacity:0}})},dialog_red:function(tag,w,h){w=w==undefined?300:w;h=h==undefined?200:h;$('#__dialogBox__'+tag).dialog({dialogClass:'redDialog',draggable:false,resizable:false,title:'Alert',stack:true,modal:false,height:h,width:w,overlay:{background:'black',width:'100%',height:'100%',opacity:0}})},alert:function(msg,callback,w,h){var rnd=Math.floor(Math.random()*1000000);if(callback&&typeof(callback)=='function'){$.ic.storage.dialogCallbacks['d'+rnd]=callback}else{h=w;w=callback}var buttons="<div class='buttons'><button class='dialogButton' onclick=\"$.ic.alert_part2('"+rnd+"');\" >OK</button></div>";$('body').append("<div class='ic2d' id='__dialogBox__"+rnd+"'></div>");$('#__dialogBox__'+rnd).html(msg+buttons);$.ic.dialog_basic(rnd,w,h);$('#__dialogBox__'+rnd+' .dialogButton').focus()},alert_part2:function(tag){var callback=$.ic.storage.dialogCallbacks['d'+tag];if(callback){(callback)()}$('body #__dialogBox__'+tag).dialog('destroy').remove()},error:function(msg,callback,w,h){var rnd=Math.floor(Math.random()*1000000);if(callback&&typeof(callback)=='function'){$.ic.storage.dialogCallbacks['d'+rnd]=callback}else{h=w;w=callback}var buttons="<div class='buttons'><button class='dialogButton' onclick=\"$.ic.error_part2('"+rnd+"');\" >OK</button></div>";$('body').append("<div class='ic2d' id='__dialogBox__"+rnd+"'></div>");$('#__dialogBox__'+rnd).html(msg+buttons);$.ic.dialog_red(rnd,w,h);$('#__dialogBox__'+rnd+' .dialogButton').focus()},error_part2:function(tag){var callback=$.ic.storage.dialogCallbacks['d'+tag];if(callback){(callback)()}$('body #__dialogBox__'+tag).dialog('destroy').remove()},notice:function(msg,w,h){var rnd=Math.floor(Math.random()*1000000);var buttons="<div class='buttons'><button class='dialogButton' onclick=\"$.ic.notice_part2('"+rnd+"');\" >OK</button></div>";$('body').append("<div class='ic2d' id='__dialogBox__"+rnd+"'></div>");$('#__dialogBox__'+rnd).html(msg+buttons);$.ic.dialog_basic(rnd,w,h);$('#__dialogBox__'+rnd+' .dialogButton').focus();setTimeout("$.ic.notice_part2('"+rnd+"');",1000)},notice_part2:function(tag){$('body #__dialogBox__'+tag).parent().fadeOut(200,function(){$('body #__dialogBox__'+tag).dialog('destroy').remove()})},confirm:function(msg,callback,w,h){var rnd=Math.floor(Math.random()*1000000);if(callback&&typeof(callback)=='function'){$.ic.storage.dialogCallbacks['d'+rnd]=callback}else{h=w;w=callback}var buttons="<div class='buttons'><button class='dialogButton' onclick=\"$.ic.confirm_part2('"+rnd+"','ok');\" >OK</button><button class='dialogButton cancel' onclick=\"$.ic.confirm_part2('"+rnd+"','cancel');\" >Cancel</button></buttons>";$('body').append("<div class='ic2d' id='__dialogBox__"+rnd+"'></div>");$('#__dialogBox__'+rnd).html(msg+buttons);$.ic.dialog_basic(rnd,w,h);$('#__dialogBox__'+rnd+' .cancel').focus()},confirm_part2:function(tag,action){var callback=$.ic.storage.dialogCallbacks['d'+tag];if(callback){(callback)(action=='ok')}$('body #__dialogBox__'+tag).dialog('destroy').remove()},prompt:function(q,value,callback,w,h){value=value?value:'';var rnd=Math.floor(Math.random()*1000000);if(callback&&typeof(callback)=='function'){$.ic.storage.dialogCallbacks['d'+rnd]=callback}else{h=w;w=callback}var input="<br /><input type='text' id='_input' class='textInput' value=\""+value+"\" />";var buttons="<div class='buttons'><button class='dialogButton' onclick=\"$.ic.prompt_part2('"+rnd+"','ok');\" >OK</button><button class='dialogButton' onclick=\"$.ic.prompt_part2('"+rnd+"','cancel');\" >Cancel</button></buttons>";$('body').append("<div class='ic2d' id='__dialogBox__"+rnd+"'></div>");$('#__dialogBox__'+rnd).html(q+input+buttons);$.ic.dialog_basic(rnd,w,h);$('#__dialogBox__'+rnd+' .textInput').focus()},prompt_part2:function(tag,action){var callback=$.ic.storage.dialogCallbacks['d'+tag];if(callback&&action!='cancel'){var _value=$('#__dialogBox__'+tag+' #_input').val();(callback)(_value)}$('body #__dialogBox__'+tag).dialog('destroy').remove()},loading:function(){var html="<center>Loading...</center>";$('body #__dialogBox__loading').remove();$('body').append("<div class='ic2d' id='__dialogBox__loading'></div>");$('#__dialogBox__loading').html(html);$.ic.dialog_graphic('loading')},loading_stop:function(){$('body #__dialogBox__loading').parent().fadeOut(300,function(){$('body #__dialogBox__loading').dialog('destroy').remove()})},superbasic:function(msg,callback,w,h,label){var rnd=Math.floor(Math.random()*1000000);if(callback&&typeof(callback)=='function'){$.ic.storage.dialogCallbacks['d'+rnd]=callback}else{label=h;h=w;w=callback}$('body').append("<div class='ic2d' id='__dialogBox__"+rnd+"'></div>");$('#__dialogBox__'+rnd).html(msg.replace(/#ID#/g,rnd));$.ic.dialog_superbasic(rnd,w,h,label)},superbasic_part2:function(tag){var callback=$.ic.storage.dialogCallbacks['d'+tag];if(callback){(callback)()}$('body #__dialogBox__'+tag).dialog('destroy').remove()},tooltip:function(thing){$.ic.alert($(thing).attr('title'))},checkTimeout:function(){$.get('/html/index/session',{},function(xh,s){if(!xh.match(/^1/)){window.location='/html/login?timeout=1'}else{setTimeout("$.ic.checkTimeout();",60000)}})},editProfile:function(){$.get('/myProfile.html',function(html){$.ic.superbasic(html,300,220,'Edit Profile')})},saveProfile:function(tag){var url='/html/index/saveprofile';sendVars={_email:$('#_email').val(),_pass0:$('#_pass0').val(),_pass1:$('#_pass1').val(),_pass2:$('#_pass2').val()};$.post(url,sendVars,function(xh,s){if(xh=='success'){$.ic.superbasic_part2(tag);$.ic.notice('Profile saved successfully.')}else{$('#_profileForm .errorOut').html(xh)}})},dragDrop:function(selector,accept,callback){},splash_ts:function(){var module=$('#ts_module').val();var name=$('#ts_name').val();var body=$('#ts_comments').val();$.post('splash/techsupport',{module:module,name:name,body:body},function(xh,s){if(xh=='success'){$.ic.alert("Your issue has been successfully submitted. A customer service representative will get back to you soon.")}})},splash_emergency:function(){var body=$('#emergency').val();$.post('splash/emergency',{body:body},function(xh,s){if(xh=='success'){$.ic.alert("Your issue has been successfully submitted. A customer service representative will get back to you soon.")}})},uploadProfilePic:function(){var url='/html/splash/uploadform';$.get(url,function(xh,s){$.ic.superbasic(xh,270,90,'Upload a Profile Pic')})},uploadProfilePicStart:function(){$.ic.loading()},uploadProfilePicComplete:function(r){$.ic.superbasic_part2($('#var_tag').val());$.ic.loading_stop();if(r.match(/\.jpg$/)){$('#info .profile_pic').attr('src',r+'?r='+Math.random())}else{$.ic.error(r)}},editProfileAdv:function(){$('#info .showinfo').hide();$('#info .showform').show()},saveProfileAdv:function(){var email=$('.showform #_profileEmailAdv').val();var password=$('.showform #_profilePasswordAdv').val();if(!email.match(/[^@]+@.+\.\w{2,4}$/)){$.ic.error('You must supply a valid email address')}else{var url='/html/splash/editprofile';$.post(url,{email:email,password:password},function(xh,s){$.ic.alert(xh);$('#info .showinfo ._profileEmailCurr').html(email);$('#info .showform').hide();$('#info .showinfo').show()})}}})})(jQuery);jQuery(function(){jQuery.ic.init()});
