var randomValueCookieMaker = new Class({ initialize: function(options) { this.options = Object.extend({ cookieName: false, limit: 10, days: 999, domain: false
}, options || {}); if(this.options.cookieName) this.verify(); else { dbug.log('you must specify a cookie name.'); return false;}
}, verify: function() { this.val = Cookie.get(this.options.cookieName); if (!$type.isNumber(this.val)) { this.val = this.makeRand(); this.saveVal();}
}, saveVal: function(val) { this.val = $pick(val, this.val); if (this.options.domain) Cookie.set(this.options.cookieName, this.val, {duration:this.options.days, domain:this.options.domain}); else Cookie.set(this.options.cookieName, this.val, this.options.days);}, makeSeed: function() { today=new Date(); seed = (today.getTime()*9301+49297) % 233280; return seed/(233280.0);}, makeRand: function() { return Math.ceil(this.makeSeed()*this.options.limit);}
}); var simpleTemplateParser = { STP: {}, parseTemplate: function(template, object, regexOptions, wrappers) { var STP = this.STP; STP.template = template; STP.object = object; STP.regexOptions = $pick(regexOptions, 'ig'); STP.wrappers = $pick(wrappers, {before:'%', after:'%'}); return STP.result = this.runParser(STP.object, STP.template, STP.regexOptions);}, runParser: function(object, string, regexOptions){ for(value in object){ switch($type(object[value])){ case 'string':
string = this.tmplSubst(value, object[value], string, regexOptions); break; case 'number':
string = this.tmplSubst(value, object[value], string, regexOptions); break; case 'object':
string = this.runParser(object[value]); break; case 'array':
string = this.tmplSubst(value, object[value].toString(), string, regexOptions); break;}
}
return string;}, tmplSubst: function(key, value, string, regexOptions){ return string.replace(this.STP.wrappers.before+key+this.STP.wrappers.after, value, regexOptions);}
}; function fixPNG(myImage)
{ try { var arVersion = navigator.appVersion.split("MSIE"); var version = parseFloat(arVersion[1]); if ((version >= 5.5) && (version < 7) && (document.body.filters)){ myImage = $(myImage); var vis = myImage.visible(); if(!vis) myImage.show(); var width = $(myImage).offsetWidth; var height = $(myImage).offsetHeight; if(!vis) myImage.hide(); var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""; var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""; var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "; var imgStyle = "display:inline-block;" + myImage.style.cssText; var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + width + "px; height:" + height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"; myImage.outerHTML = strNewHTML;}
} catch(e) {}
}; if(window.ie6) window.onDomReady(function(){$$('img.fixPNG').each(function(png){fixPNG(png)});}); var IframeShim = new Class({ initialize: function (options){ this.setOptions({}, options); el = options.element; var shim = new Element('iframe'); this.id = options.name + "_shim"; shim.id = this.id; try{ if(!$(el).getStyle('z-Index'))
$(el).setStyle('z-Index',0);}catch(e){ $(el).setStyle('z-Index',0);}
shim.setStyles({ 'position': 'absolute', 'zIndex': $(el).getStyle('z-Index')-1, 'border': 'none', 'filter': 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
}); shim.setProperties({ 'src':'javascript:void(0);', 'frameborder':'0', 'scrolling':'no'
}).inject(el,'after'); if(options.display) this.show(); else this.hide(); shim = null;}, position: function(shim){ shim = shim || this.id; var el = this.options.element; var wasVis = $(el).getStyle('display')!='none'; if(! wasVis) $(el).setStyle('display','block'); this.left = $(el).getLeft(); this.top = $(el).getTop(); this.width = $(el).offsetWidth; this.height = $(el).offsetHeight; if(! wasVis) $(el).setStyle('display','none'); if($type(this.options.margin)){ this.width = this.width-(this.options.margin*2); this.height = this.height-(this.options.margin*2); this.left = this.left + this.options.margin; this.top = this.top + this.options.margin;}
if($type(this.options.offset)){ this.left = this.left-this.options.offset.left; this.top = this.top-this.options.offset.top;}
$(shim).setStyles({ 'left': this.left + 'px', 'width': this.width + 'px', 'height': this.height + 'px', 'top': this.top + 'px'
});}, hide: function(){ $(this.id).setStyle('display','none');}, show: function(){ $(this.id).setStyle('display','block'); this.position();}, remove: function(){ $(this.id).remove();}
}); IframeShim.implement(new Options); var iframeShim = IframeShim; var InputValidator = new Class({ initialize: function(className, options){ this.setOptions({ errorMsg: 'Validation failed.', test: function(field){return true}
}, options); this.className = className;}, test: function(field){ if($(field)) return this.options.test($(field), this.getProps(field)); else return false;}, getError: function(field){ var err = this.options.errorMsg; if($type(err) == "function") err = err($(field), this.getProps(field)); return err;}, getProps: function(field){ if($(field) && $(field).getProperty('validatorProps')){ try { return Json.evaluate($(field).getProperty('validatorProps'));}catch(e){ return {}}
} else { return {}
}
}
}); InputValidator.implement(new Options); var FormValidator = new Class({ initialize: function(form, options){ this.setOptions({ fieldSelectors:"input, select, textarea", useTitles:false, evaluateOnSubmit:true, evaluateFieldsOnBlur: true, onFormValidate: function(isValid, form){}, onElementValidate: function(isValid, field){}
}, options || {}); try { this.form = $(form); if(this.options.evaluateOnSubmit) this.form.addEvent('submit', this.onSubmit.bind(this)); if(this.options.evaluateFieldsOnBlur) this.watchFields();}catch(e){ }
}, watchFields: function(){ try{ this.form.getElementsBySelector(this.options.fieldSelectors).each(function(el){ el.addEvent('blur', this.validateField.pass(el, this));}, this);}catch(e){ }
}, onSubmit: function(event){ if(!this.validate()) new Event(event).stop();}, reset: function() { this.form.getElementsBySelector(this.options.fieldSelectors).each(this.resetField, this);}, validate : function() { var result = this.form.getElementsBySelector(this.options.fieldSelectors).map(function(field) { return this.validateField(field);}, this); result = result.every(function(val){ return val;}); this.fireEvent('onFormValidate', [result, this.form]); return result;}, validateField: function(field){ field = $(field); var result = true; if(field){ var validators = field.className.split(" ").some(function(cn){ return FormValidator.getValidator(cn);}); result = field.className.split(" ").map(function(className){ var test = this.test(className,field); return test;}, this); result = result.every(function(val){ return val;}); if(validators){ if(result) field.addClass('validation-passed').removeClass('validation-failed'); else field.addClass('validation-failed').removeClass('validation-passed');}
}
return result;}, getPropName: function(className){ return '__advice'+className;}, test: function(className, field){ field = $(field); var isValid = true; if(field) { var validator = FormValidator.getValidator(className); if(validator && this.isVisible(field)) { isValid = validator.test(field); if(!isValid && validator.getError(field)){ var advice = this.makeAdvice(className, field, validator.getError(field)); this.showAdvice(className, field);} else this.hideAdvice(className, field); this.fireEvent('onElementValidate', [isValid, field]);}
}
return isValid;}, showAdvice: function(className, field){ var advice = this.getAdvice(className, field); if(advice && !field[this.getPropName(className)] && (advice.getStyle('display') == "none" || advice.getStyle('visiblity') == "hidden" || advice.getStyle('opacity')==0)){ field[this.getPropName(className)] = true; if(advice.smoothShow) advice.smoothShow(); else advice.setStyle('display','block');}
}, hideAdvice: function(className, field){ var advice = this.getAdvice(className, field); if(advice && field[this.getPropName(className)]) { field[this.getPropName(className)] = false; if(advice.smoothHide) advice.smoothHide(); else advice.setStyle('display','block');}
}, isVisible : function(field) { while(field.tagName != 'BODY') { if($(field).getStyle('display') == "none") return false; field = field.parentNode;}
return true;}, getAdvice: function(className, field) { return $('advice-' + className + '-' + this.getFieldId(field))
}, makeAdvice: function(className, field, error){ var errorMsg = this.options.useTitles ? $pick(field.title, error):error; var advice = this.getAdvice(className, field); if(!advice){ advice = new Element('div').addClass('validation-advice').setProperty( 'id','advice-'+className+'-'+this.getFieldId(field)).setStyle('display','none').appendText(errorMsg); switch (field.type.toLowerCase()) { case 'radio':
var p = $(field.parentNode); if(p) { p.adopt(advice); break;}
default: advice.injectAfter($(field));};} else{ advice.setHTML(errorMsg);}
return advice;}, getFieldId : function(field) { return field.id ? field.id : field.id = "input_"+field.name;}, resetField: function(field) { field = $(field); if(field) { var cn = field.className.split(" "); cn.each(function(className) { var prop = this.getPropName(className); if(field[prop]) this.hideAdvice(className, field); field.removeClass('validation-failed'); field.removeClass('validation-passed');}, this);}
}
}); FormValidator.implement(new Options); FormValidator.implement(new Events); Object.extend(FormValidator, { validators:[], add : function(className, options) { this.validators[className] = new InputValidator(className, options);}, addAllThese : function(validators) { $A(validators).each(function(validator) { this.add(validator[0], validator[1]);}, this);}, getValidator: function(className){ return FormValidator.validators[className] = $pick(FormValidator.validators[className], false);}
}); FormValidator.add('IsEmpty', { errorMsg: false, test: function(element) { if(element.type == "select-one"||element.type == "select")
return !(element.selectedIndex >= 0 && element.options[element.selectedIndex].value != ""); else
return ((element.getValue() == null) || (element.getValue().length == 0));}
}); FormValidator.addAllThese([ ['required', { errorMsg: function(element){return 'This field is required.'}, test: function(element) { return !FormValidator.getValidator('IsEmpty').test(element);}
}], ['minLength', { errorMsg: function(element, props){ if($type(props.minLength))
return 'Please enter at least ' + props.minLength + ' characters (you entered ' + element.getValue().length + ' characters).'; else return '';}, test: function(element, props) { if($type(props.minLength)) return (element.getValue().length >= $pick(props.minLength, 0)); else return true;}
}], ['maxLength', { errorMsg: function(element, props){ if($type(props.maxLength))
return 'Please enter no more than ' + props.maxLength + ' characters (you entered ' + element.getValue().length + ' characters).'; else return '';}, test: function(element, props) { return (element.getValue().length <= $pick(props.maxLength, 10000));}
}], ['validate-number', { errorMsg: 'Please enter a valid number in this field.', test: function(element) { return FormValidator.getValidator('IsEmpty').test(element) || !/[^\d+$]/.test(element.getValue());}
}], ['validate-digits', { errorMsg: 'Please use numbers only in this field. Please avoid spaces or other characters such as dots or commas.', test: function(element) { return FormValidator.getValidator('IsEmpty').test(element) || (!/[^a-zA-Z]/.test(element.getValue()) && /[\d]/.test(element.getValue()));}
}], ['validate-alpha', { errorMsg: 'Please use letters only (a-z) in this field.', test: function (element) { return FormValidator.getValidator('IsEmpty').test(element) || /^[a-zA-Z]+$/.test(element.getValue())
}
}], ['validate-alphanum', { errorMsg: 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', test: function(element) { return FormValidator.getValidator('IsEmpty').test(element) || !/\W/.test(element.getValue())
}
}], ['validate-date', { errorMsg: 'Please use this date format: mm/dd/yyyy. For example 03/17/2006 for the 17th of March, 2006.', test: function(element) { if(FormValidator.getValidator('IsEmpty').test(element)) return true; var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/; if(!regex.test(element.getValue())) return false; var d = new Date(element.getValue().replace(regex, '$1/$2/$3')); return (parseInt(RegExp.$1, 10) == (1+d.getMonth())) &&
(parseInt(RegExp.$2, 10) == d.getDate()) &&
(parseInt(RegExp.$3, 10) == d.getFullYear() );}
}], ['validate-email', { errorMsg: 'Please enter a valid email address. For example fred@domain.com .', test: function (element) { return FormValidator.getValidator('IsEmpty').test(element) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(element.getValue());}
}], ['validate-url', { errorMsg: 'Please enter a valid URL.', test: function (element) { return FormValidator.getValidator('IsEmpty').test(element) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(element.getValue());}
}], ['validate-date-au', { errorMsg: 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', test: function(element) { if(FormValidator.getValidator('IsEmpty').test(element)) return true; var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/; if(!regex.test(element.getValue())) return false; var d = new Date(element.getValue().replace(regex, '$2/$1/$3')); return (parseInt(RegExp.$2, 10) == (1+d.getMonth())) &&
(parseInt(RegExp.$1, 10) == d.getDate()) &&
(parseInt(RegExp.$3, 10) == d.getFullYear() );}
}], ['validate-currency-dollar', { errorMsg: 'Please enter a valid $ amount. For example $100.00 .', test: function(element) { return FormValidator.getValidator('IsEmpty').test(element) || /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(element.getValue());}
}], ['validate-one-required', { errorMsg: 'Please enter something for at least one of the above options.', test: function (element) { var p = element.parentNode; var options = p.getElements('input'); return $A(options).some(function(el) { return el.getValue();});}
}] ]); var Modalizer = new Class({ defaultModalStyle: { 'display':'block', 'position':'fixed', 'top':'0px', 'left':'0px', 'width':(window.getScrollWidth()+300)+'px', 'height':(window.getScrollHeight()+300)+'px', 'z-index':5000, 'background-color':'#333', 'opacity':.8
}, setModalOptions: function(options){ this.modalOptions = $merge({ elementsToHide: 'select', onModalHide: Class.empty, onModalShow: Class.empty, hideOnClick: true, modalStyle: {}
}, options || {});}, setModalStyle: function (styleObject){ this.modalOptions.modalStyle = styleObject; this.modalStyle = $merge(this.defaultModalStyle, styleObject); if($('modalOverlay'))$('modalOverlay').setStyles(this.modalStyle); return(this.modalStyle);}, modalShow: function(options){ var overlay = null; if($('modalOverlay')) overlay = $('modalOverlay'); if(options)this.setModalOptions(options); if(!overlay){ overlay = new Element('div').setProperty('id','modalOverlay').injectInside(document.body);}
overlay.setStyles(this.setModalStyle(this.modalOptions.modalStyle)); if(window.ie6) overlay.setStyle('position','absolute'); if(this.modalOptions.hideOnClick) { $('modalOverlay').removeEvents('click').addEvent('click', function(){ this.modalHide();}.bind(this));}
this.modalOptions.onModalShow(); $('modalOverlay').show('block'); return this;}, modalHide: function(){ this.togglePopThroughElements(1); this.modalOptions.onModalHide(); if($('modalOverlay'))$('modalOverlay').hide(); return this;}, togglePopThroughElements: function(opacity){ $$(this.modalOptions.elementsToHide).each(function(sel){ sel.setStyle('opacity', opacity);});}
}); var modalizer = Modalizer; function stickyWinHTML (caption, body, options){ this.options = $merge({ width: '300px', css: "body{font-family:verdana; font-size:11px; background-color:#bed1e7}"+ "div.DefaultStickyWin{width:%width%}"+ "div.DefaultStickyWin div.top_ul{background:url(%baseHref%full.png) top left no-repeat !important; background:url(%baseHref%full.gif) top left no-repeat; height:30px; width:15px; float:left}"+ "div.DefaultStickyWin div.top_ur{position:relative; left:0px !important; left:-4px; background:url(%baseHref%full.png) top right !important; background:url(%baseHref%full.gif) top right; height:30px; margin:0px 0px 0px 15px !important; margin-right:-4px; padding:0px}"+ "div.DefaultStickyWin h1.caption{margin:0; padding:0; font-weight:bold; color:#555; font-size:14px; position:relative; top:8px; left:5px; width:%h1Width%}"+ "div.DefaultStickyWin div.middle{background:url(%baseHref%body.png) top left repeat-y!important; background:url(%baseHref%body.gif) top left repeat-y; margin-right:20px}"+ "div.DefaultStickyWin div.body{background:url(%baseHref%body.png) top right repeat-y !important; background:url(%baseHref%body.gif) top right repeat-y; padding:8px 30px 8px 0px; margin-left:5px; position:relative; right:-20px}"+ "div.DefaultStickyWin div.bottom_ll{background:url(%baseHref%full.png) bottom left no-repeat!important; background:url(%baseHref%full.gif) bottom left no-repeat; width:15px; height:15px; float:left}"+ "div.DefaultStickyWin div.bottom_lr{background:url(%baseHref%full.png) bottom right !important; background:url(%baseHref%full.gif) bottom right; position:relative; left:0px !important; left:-4px; margin:0px 0px 0px 15px !important; margin-right:-4px; height:15px}"+ "div.DefaultStickyWin div.closeButton{width:13px; height:13px; background:url(%baseHref%closebtn.gif); float:right; margin:10px 15px 0px 0px; cursor:pointer}"+ "div.DefaultStickyWin div.closeButton:hover{background:url(%baseHref%closebtn_over.gif)}", baseHref: 'http://www.cnet.com/html/rb/assets/global/stickyWinHTML/'
}, options); window.onDomReady(function(){ try { if(!$('defaultStickyWinStyle')) { this.options.h1Width = (this.options.width.toInt()-50)+'px'; var css = simpleTemplateParser.parseTemplate(this.options.css, this.options); new Element('style').setProperty('id','defaultStickyWinStyle').injectInside($$('head')[0]).appendText(css);}
}catch(e){dbug.log('error: %s',e);}
}.bind(this)); caption = $pick(caption, '%caption%'); body = $pick(body, '%body'); var container = new Element('div').setProperty('class', 'DefaultStickyWin'); var h1Caption = new Element('h1').addClass('caption')
if($(caption)) h1Caption.adopt(caption); else h1Caption.setHTML(caption); var bodyDiv = new Element('div').addClass('body')
if($(body)) bodyDiv.adopt(body); else bodyDiv.setHTML(body); container.adopt( new Element('div').addClass('top').adopt( new Element('div').addClass('top_ul') ).adopt( new Element('div').addClass('top_ur').adopt( new Element('div').addClass('closeButton').addClass('closeSticky') ).adopt(h1Caption)
) ); container.adopt( new Element('div').addClass('middle').adopt( new Element('div').addClass('body_left') ).adopt(bodyDiv) ); container.adopt( new Element('div').addClass('bottom').adopt( new Element('div').addClass('bottom_ll') ).adopt( new Element('div').addClass('bottom_lr')
) ); return container;}; var StickyWin = new Class({ initialize: function(options){ options.id = options.id || 'StickyWin_'+new Date().getTime(); this.setOptions({ onDisplay: Class.empty, onClose: Class.empty, closeClassName: 'closeSticky', content: '', zIndex: 10000, className: '', position: 'center', offset: {x:0,y:0}, relativeTo: document.body, width: false, height: false, timeout: -1, allowMultipleByClass: false, allowMultiple: true, showNow: true, useIframeShim: true, iframeShimSelector: ''
}, options); this.makeWindow(); if(this.options.content) this.setContent(this.options.content); if(this.options.showNow) this.show();}, makeWindow: function(){ this.destroyOthers(); if(!$(this.options.id)) { this.win = new Element('div').setProperty('id', this.options.id).addClass(this.options.className).addClass('StickyWinInstance').addClass('clearfix').setStyles({ 'display':'none', 'position':'absolute', 'zIndex':this.options.zIndex
}).injectInside(document.body);} else this.win = $(this.options.id); if(this.options.width && $type(this.options.width.toInt())=="number") this.win.setStyle('width', this.options.width.toInt() + 'px'); if(this.options.height && $type(this.options.height.toInt())=="number") this.win.setStyle('height', this.options.height.toInt() + 'px'); return this;}, show: function(){ this.fireEvent('onDisplay'); if(!this.positioned) this.position(); this.showWin(); if(this.options.useIframeShim) this.showIframeShim(); this.visible = true; return this;}, showWin: function(){ this.win.show();}, hide: function(){ this.fireEvent('onClose'); this.hideWin(); if(this.options.useIframeShim) this.hideIframeShim(); this.visible = false; return this;}, hideWin: function(){ this.win.hide();}, destroyOthers: function() { if(!this.options.allowMultipleByClass || !this.options.allowMultiple) { $$('div.StickyWinInstance').each(function(sw) { if(!this.options.allowMultiple || (!this.options.allowMultipleByClass && sw.hasClass(this.options.className)))
sw.remove();}, this);}
}, setContent: function(html) { if($type(html) == "string") this.win.setHTML(html); else if ($(html)) this.win.adopt(html); this.win.getElements('.'+this.options.closeClassName).each(function(el){ el.addEvent('click', this.hide.bind(this));}, this); return this;}, position: function(){ this.positioned = true; this.win.setPosition({ relativeTo: this.options.relativeTo, position: this.options.position, offset: this.options.offset
}); if(this.shim) this.shim.position(); return this;}, makeIframeShim: function(){ if(!this.shim){ this.shim = new IframeShim({ element: (this.options.iframeShimSelector)?this.win.getElement(this.options.iframeShimSelector) : $('StickyWinOverlay') || this.win, display: false, name: 'StickyWinShim'
});}
}, showIframeShim: function(){ if(this.options.useIframeShim) { this.makeIframeShim(); this.shim.show();}
}, hideIframeShim: function(){ if(this.options.useIframeShim)
this.shim.hide();}, destroy: function(){ this.win.remove(); if(this.options.useIframeShim) this.shim.remove(); if($('StickyWinOverlay'))$('StickyWinOverlay').remove();}
}); StickyWin.implement(new Options); StickyWin.implement(new Events); var stickyWin = StickyWin; var StickyWinFx = StickyWin.extend({ getDefaultOptions: function(){ }, initialize: function(options){ this.parent($merge({ fade: true, fadeDuration: 150, fadeTransition: Fx.Transitions.sineInOut, draggable: false, dragOptions: {}, dragHandleSelector: 'h1.caption', resizable: false, resizeOptions: {}, resizeHandleSelector: ''
}, options)); if(this.options.draggable) this.makeDraggable(); if(this.options.resizable) this.makeResizable();}, hideWin: function(){ if(this.options.fade) this.fade(1,0); else this.win.hide();}, showWin: function(){ if(this.options.fade) { this.fade(0,1);} else this.win.show();}, fade: function(from,to){ if(!this.fadeFx) { this.win.setStyles({ 'opacity':'0', 'display':'block'
}); this.fadeFx = this.win.effect('opacity', { duration: this.options.fadeDuration, transition: this.options.fadeTransition
});}
if (to > 0) this.win.setStyle('display','block'); this.fadeFx.custom(from,to).chain(function(){ if(to == 0) this.win.setStyle('display', 'none');}.bind(this)); return this;}, makeDraggable: function(){ dbug.log('you must include Drag.js, cannot make draggable');}, makeResizable: function(){ dbug.log('you must include Drag.js, cannot make resizable');}
}); if(typeof Drag != "undefined"){ StickyWinFx.implement({ makeDraggable: function(){ if(this.options.useIframeShim) { this.makeIframeShim(); var dragComplete = this.options.dragOptions.onComplete || Class.empty; this.options.dragOptions.onComplete = function(){ dragComplete(); this.shim.position();}.bind(this);}
if(this.options.dragHandleSelector) { var handle = this.win.getElement(this.options.dragHandleSelector); if (handle) handle.setStyle('cursor','move'); this.options.dragOptions.handle = handle;}
this.win.makeDraggable(this.options.dragOptions);}, makeResizable: function(){ if(this.options.useIframeShim) { this.makeIframeShim(); var resizeComplete = this.options.resizeOptions.onComplete || Class.empty; this.options.resizeOptions.onComplete = function(){ resizeComplete(); this.shim.position();}.bind(this);}
if(this.options.resizeHandleSelector) this.options.resizeOptions.handle = this.win.getElement(this.options.resizeHandleSelector); this.win.makeResizable(this.options.resizeOptions);}
});}
var modalWinBase = { initialize: function(options){ options = options||{}; this.setModalOptions($merge(options.modalOptions||{}, { onModalHide: function(){ this.hide(false);}.bind(this)
})); this.parent(options);}, show: function(showModal){ if($pick(showModal, true))this.modalShow(); this.parent();}, hide: function(hideModal){ if($pick(hideModal, true))this.modalHide(); this.parent();}
}; var StickyWinModal = StickyWin.extend(modalWinBase); StickyWinModal.implement(new Modalizer); var StickyWinFxModal = (typeof StickyWinFx != "undefined")?StickyWinFx.extend(modalWinBase):Class.empty; try { StickyWinFxModal.implement(new Modalizer());}catch(e){}
var simpleErrorPopup = function(msghdr, msg) { var msg = '<p class="errorMsg clearfix">' + '<img src="http://www.cnet.com/html/rb/assets/global/simple.error.popup/icon_problems_sm.gif"'+ ' class="bang clearfix" style="float: left; width: 30px; height: 30px; margin: 3px 5px 5px 0px;">' + msg + '</p>'; var body = stickyWinHTML(msghdr, msg, {width: '250px'}); return new StickyWinModal({ content: body, position: 'center', allowMultiple: false
});}; var DatePicker = new Class({ defaultCss: 'div.calendarHolder{width:210px; height:182px; padding-left:8px; padding-top:1px; '+ 'background:url(http://www.cnet.com/html/rb/assets/global/datePicker/calendar.back.png) no-repeat} '+ '* html div.calendarHolder {background:url(http://www.cnet.com/html/rb/assets/global/datePicker/calendar.back.gif) no-repeat}'+ 'table.datePicker * {font-size:11px; line-height:16px;} '+ 'table.datePicker{margin:6px 0px 0px 0px; width:190px; padding:0px 5px 0px 5px} '+ 'table.datePicker td{cursor:pointer; text-align:center} '+ 'table.datePicker img.closebtn{margin-top:2px} '+ 'tr.dateNav{height:22px; margin-top:8px} '+ 'tr.dayNames td{color:#666; font-weight:bold; border-bottom:1px solid #ddd} '+ 'table.datePicker tr.dayRow td:hover{background:#ccc} '+ 'td.today{color:#bb0904} '+ 'td.otherMonthDate{border:1px solid #fff; color:#666; background:#f3f3f3} '+ 'td.selectedDate{border:1px solid #20397b; background:#dcddef}', fullDay: 86400000, initialize: function(input, options){ var StickyWinToUse = (typeof StickyWinFx == "undefined")?StickyWin:StickyWinFx; this.setOptions({ calendarId: false, months: ["January","February","March","April","May","June","July", "August","September","October","November","December"], days: ["Su","Mo","Tu","We","Th","Fr","Sa"], stickyWinOptions: { position: "bottomLeft", offset: {x:10, y:10}, fadeDuration: 400
}, stickyWinToUse: StickyWinToUse, draggable: true, dragOptions: {}, additionalShowLinks:[], showOnInputFocus: true, useDefaultCss: true, hideCalendarOnPick: true, onPick: Class.empty, onShow: Class.empty, onHide: Class.empty
}, options); if(!this.options.calendarId) this.options.calendarId = "popupCalendar" + new Date().getTime(); this.input = $(input); if(this.options.useDefaultCss)this.writeCss(); this.setUpObservers(); this.getCalendar();}, setUpObservers: function(){ if (this.options.showOnInputFocus) this.input.addEvent('focus', this.show.bind(this)); this.input.addEvent('blur', this.updateInput.bind(this)); this.options.additionalShowLinks.each(function(lnk){$(lnk).addEvent('click', this.show.bind(this))}, this);}, writeCss: function(css) { css = $pick(css,this.defaultCss); window.onDomReady(function(){ try { if(!$('datePickerStyle'))
new Element('style').setProperty('id','datePickerStyle').injectInside($$('head')[0]).appendText(css);}catch(e){dbug.log('error: %s',e);}
});}, updateInput: function(date){ if(!$type(date) == "string" || (date && !date.getTime)) date = this.input.getValue(); var dateStr = this.formatDate(this.validDate(date)); if($type(dateStr) == "string") { this.input.value = dateStr; return dateStr;}
return date;}, validDate: function(val) { val = $pick(val, this.input.getValue()); val = val.replace(/^\s+|\s+$/g,""); var asDate = Date.parse(val); if (isNaN(asDate)) asDate = Date.parse(val.replace(/[^\w\s]/g,"/")); if (isNaN(asDate)) asDate = Date.parse(val.replace(/[^\w\s]/g,"/") + "/" + new Date().getFullYear()); if (!isNaN(asDate)) { var newDate = new Date(asDate); if (newDate.getFullYear() < 2000 && val.indexOf(newDate.getFullYear()) < 0) { newDate.setFullYear(newDate.getFullYear() + 100);}
return newDate;} else return asDate;}, formatDate: function (date) { try { var fd = ((date.getUTCMonth() < 9) ? "0" : "") + (date.getUTCMonth()+1) + "/"; fd += ((date.getUTCDate() < 10) ? "0" : "") + date.getUTCDate() + "/"; fd += date.getUTCFullYear(); return fd;} catch(e){return date}
}, zeroHourGMT: function(date) { date.setTime(date.getTime() - date.getTime() % 86400000); return date;}, getCalendar: function() { if(!this.calendar) { var cal = new Element("table").setProperties({ 'id': this.options.calendarId, 'border':'0', 'cellpadding':'0', 'cellspacing':'0'
}); cal.addClass('datePicker'); $(cal.insertRow(0).insertCell(0)).appendText("x"); for (var c=0;c<6;c++) $(cal.rows[0]).adopt(cal.rows[0].cells[0].cloneNode(true)); for (var r=0;r<7;r++) $(cal.rows[0].parentNode).adopt(cal.rows[0].cloneNode(true)); $(cal.rows[1]).addClass('dayNames'); for (var r=2;r<8;r++) $(cal.rows[r]).addClass('dayRow'); for (var d=0;d<7;d++) cal.rows[1].cells[d].firstChild.data = this.options.days[d]; for (var t=6;t>3;t--) cal.rows[0].deleteCell(t); $(cal.rows[0]).addClass('dateNav'); if(!window.ie6)cal.rows[0].cells[0].firstChild.data=String.fromCharCode(9668); else cal.rows[0].cells[0].firstChild.data="<"; cal.rows[0].cells[1].colSpan=4; if(!window.ie6) cal.rows[0].cells[2].firstChild.data=String.fromCharCode(9658); else cal.rows[0].cells[2].firstChild.data=">"; cal.rows[0].cells[3].firstChild.data=String.fromCharCode(215); $(cal.rows[0].cells[3].setHTML('')).adopt(this.getCloseImg()); cal.addEvent('click', this.clickCalendar.bind(this)); this.calendar = cal; this.container = new Element('div').adopt(cal).addClass('calendarHolder'); this.options.stickyWinOptions.content = this.container; this.options.stickyWinOptions.showNow = false; this.options.stickyWinOptions.relativeTo = this.input; this.stickyWin = new this.options.stickyWinToUse(this.options.stickyWinOptions); if(this.options.draggable) { try { this.stickyWin.win.makeDraggable(Object.extend(this.options.dragOptions, { handle:cal.rows[0].cells[1], onDrag:function(){ if(this.stickyWin.shim) this.stickyWin.shim.show.bind(this.stickyWin)
}.bind(this)
})); cal.rows[0].cells[1].setStyle('cursor', 'move');} catch(e) {}
}
}
return this.calendar;}, getCloseImg: function(){ var closer = new Element("img").setProperty('src', 'http://www.cnet.com/html/rb/assets/global/simple.error.popup/closebtn.gif'); closer.addEvents({ 'mouseover': function(){ closer.src = closer.src.replace('.gif', '_over.gif');}, 'mouseout':function(){ closer.src = closer.src.replace('_over.gif', '.gif');}, 'click': this.hide.bind(this)
}).setStyles({ width: '13px', height: '13px'
}).addClass('closebtn'); return closer;}, hide: function(){ this.stickyWin.hide(); this.fireEvent('onHide');}, show: function(){ this.today = this.zeroHourGMT(new Date()); this.inputDate = new Date(this.updateInput()); this.refDate = isNaN(this.inputDate) ? this.today : this.zeroHourGMT(new Date(this.inputDate)); this.getCalendar(); this.fillCalendar(this.refDate); this.stickyWin.show(); this.fireEvent('onShow');}, clickCalendar: function(e) { e = new Event(e); if (!e.target.firstChild || !e.target.firstChild.data) return null; var val = e.target.firstChild.data; if (val.charCodeAt(0) > 9600 || val == "<" || val == ">") { var newRef = this.calendar.rows[2].cells[0].refDate - this.fullDay; if (val.charCodeAt(0) != 9668 && val != "<") newRef = this.calendar.rows[7].cells[6].refDate + this.fullDay; this.fillCalendar(new Date(newRef)); return null;}
if (e.target.refDate) { var newDate = new Date(e.target.refDate); this.input.value = this.formatDate(newDate); this.input.fireEvent("change"); this.input.fireEvent("blur"); this.fireEvent('onPick'); if(this.options.hideCalendarOnPick) this.hide();}
}, fillCalendar: function (forDate) { var startDate = new Date(forDate.getTime()); startDate.setUTCDate(1); startDate.setTime(startDate.getTime() - (this.fullDay * startDate.getUTCDay())); this.calendar.rows[0].cells[1].firstChild.data = this.options.months[forDate.getUTCMonth()] + " " + forDate.getUTCFullYear(); var atDate = startDate; this.calendar.getElements('td').each(function (el){ el.removeClass('selectedDate').removeClass('otherMonthDate').removeClass('today');}); for (var w=2; w<8; w++) for (var d=0; d<7; d++) { var td = this.calendar.rows[w].cells[d]; td.firstChild.data = atDate.getUTCDate(); td.refDate = atDate.getTime(); if(atDate.getTime() == this.today.getTime()) td.addClass('today'); if(atDate.getTime() == this.refDate.getTime()) td.addClass('selectedDate'); if(atDate.getUTCMonth() != forDate.getUTCMonth()) td.addClass('otherMonthDate'); atDate.setTime(atDate.getTime() + this.fullDay);}
}
}); DatePicker.implement(new Options); DatePicker.implement(new Events); var PopupDetail = new Class({ visible: false, observed: false, hasData: false, initialize: function(html, options){ this.setOptions({ observer: false, observerAction: 'mouseover', closeOnMouseOut: true, linkPopup: false, data: {}, templateOptions: {}, useAjax: false, ajaxOptions:{}, ajaxLink: false, delayOn: 100, delayOff: 100, stickyWinOptions:{}, stickyWinToUse: StickyWinFx, showNow: false
}, options); this.html = ($(html))?$(html).innerHTML:html; if(this.options.showNow) this.show.delay(this.options.delayOn, this); this.setUpObservers();}, setUpObservers: function(){ var opt = this.options; if($(opt.observer) && opt.observerAction) { $(opt.observer).addEvent(opt.observerAction, function(){ this.observed = true; this.show.delay(opt.delayOn, this);}.bind(this)); if(opt.observerAction == "mouseover" && this.options.closeOnMouseOut){ $(opt.observer).addEvent("mouseout", function(){ this.observed = false; this.hide.delay(opt.delayOff, this);}.bind(this));}
}
return this;}, makePopup: function(){ if(!this.stickyWin){ var opt = this.options; this.content = this.parseTemplate(this.html, opt.data); this.stickyWin = new opt.stickyWinToUse($merge(opt.stickyWinOptions, { relativeTo: opt.observer || document.body, showNow: false, content: this.content, allowMultipleByClass: true
})); if($(opt.linkPopup) || $type(opt.linkPopup)=='string') { this.stickyWin.win.setStyle('cursor','pointer').addEvent('click', function(){ window.location.href = ($type(url)=='string')?url:url.src;});}
this.stickyWin.win.addEvent('mouseover', function(){ this.observed = true;}.bind(this)); this.stickyWin.win.addEvent('mouseout', function(){ this.observed = false; if(opt.closeOnMouseOut) this.hide.delay(opt.delayOff, this);}.bind(this));}
return this;}, getContent: function(){ try { new Ajax((this.options.ajaxLink || this.options.observer.href), $merge(this.options.ajaxOptions, { onComplete: this.show.bind(this)
}) ).request();} catch(e) { dbug.log('ajax error on PopupDetail: %s', e);}
}, show: function(jsonObject){ var opt = this.options; if(jsonObject) this.jsonData = jsonObject; if(this.observed && !this.visible) { if(opt.useAjax && !this.jsonData) { this.cursorStyle = $(opt.observer).getStyle('cursor'); $(opt.observer).setStyle('cursor', 'wait'); this.getContent(); return false;} else { if(this.cursorStyle) $(opt.observer).setStyle('cursor', this.cursorStyle); if(opt.useAjax) opt.data = Json.evaluate(this.jsonData); this.makePopup(); this.stickyWin.show(); this.visible = true; return this;}
}
}, hide: function(){ if(!this.observed){ if(this.stickyWin)this.stickyWin.hide(); this.visible = false; return this;}
}
}); PopupDetail.implement(simpleTemplateParser); PopupDetail.implement(new Options); var popupDetail = PopupDetail; var PopupDetailCollection = new Class({ popupDetailObjs: [], initialize: function(options) { this.setOptions({ details: [], observers: [], links: [], ajaxLinks: [], template: '', popupDetailOptions: {}
}, options || {}); var ln = this.options.ajaxLinks.length; if(ln <= 0) ln = this.options.details.length; if (this.options.observers.length != ln)
dbug.log("warning: observers and details are out of synch"); this.makePopupDetails();}, makePopupDetails: function(){ this.popupDetailObjs = this.options.observers.map(function(observer, index){ var opt = this.options.popupDetailOptions; var sw = opt.stickyWinToUse || false; if (sw) opt.stickyWinToUse = {}; var popupOptions = $copy(opt); if(sw) popupOptions.stickyWinToUse = sw; var pd = new PopupDetail(this.options.template, $merge(popupOptions, { data: $pick(this.options.details[index], {}), observer: this.options.observers[index], linkItem: $pick(this.options.links[index], $pick(opt.linkItem, false)), ajaxLink: $pick(this.options.ajaxLinks[index], false)
})); return pd;}, this);}
}); PopupDetailCollection.implement(new Options); var popupDetails = new Class({ initialize: function(options){ var pdcOptions = Object.extend(options,{ popupDetailOptions: { stickyWinOptions: { position: $pick(options.observeCorner, 'upperLeft'), offset: { x: options.offsetx || 0, y: options.offsety || 0
}, useIframeShim: (options.iframeShimSelector)?true:false
}
}, delayOn: $pick(options.effectDelayOn, 0), delayOff: $pick(options.effectDelayOff, 0)
}); var pdc = new popupDetailCollection(pdcOptions); return pdc;}
}); var popDetailsList = popupDetails; var CNETcarousel = new Class({ initialize: function(container, options){ this.container = $(container); if(!this.container.hasClass('hasCarousel')){ this.container.addClass('hasCarousel'); this.slides = []; this.buttons = []; this.setOptions({ onRotate: Class.empty, onStop: Class.empty, onAutoPlay: Class.empty, onShowSlide: Class.empty, slidesSelector: ".slide", buttonsSelector: ".button", slideInterval: 4000, transitionDuration: 700, startIndex: 0, buttonOnClass: "selected", buttonOffClass: "off", rotateAction: "none", rotateActionDuration: 100, autoplay: true
}, options); this.slides = $(container).getElements(this.options.slidesSelector); this.buttons = $(container).getElements(this.options.buttonsSelector); this.createFx(); this.showSlide(this.options.startIndex); if(this.options.autoplay) this.autoplay(); if(this.options.rotateAction != 'none') this.setupAction(this.options.rotateAction); return this;} else return false;}, setupAction: function(action) { this.buttons.each(function(el, idx){ $(el).addEvent(action, function() { this.slideFx.setOptions(this.slideFx.options, {duration: this.options.rotateActionDuration}); if(this.currentSlide != idx) this.showSlide(idx); this.stop();}.bind(this));}, this);}, createFx: function(){ this.slideFx = new Fx.Elements(this.slides, {duration: this.options.transitionDuration}); this.slides.each(function(slide){ slide.setStyle('opacity',0);});}, showSlide: function(slideIndex){ var action = {}; this.slides.each(function(slide, index){ if(index == slideIndex && index != this.currentSlide){ $(this.buttons[index]).removeClass(this.options.buttonOffClass).addClass(this.options.buttonOnClass); action[index.toString()] = { 'opacity': [1]
};} else { $(this.buttons[index]).removeClass(this.options.buttonOnClass).addClass(this.options.buttonOffClass); action[index.toString()] = { 'opacity':[0]
};}
}, this); this.fireEvent('onShowSlide', slideIndex); this.currentSlide = slideIndex; this.slideFx.start(action);}, autoplay: function(){ this.createFx(); this.slideshowInt = this.rotate.periodical(this.options.slideInterval, this); this.fireEvent('onAutoPlay');}, stop: function(){ clearInterval(this.slideshowInt); this.fireEvent('onStop');}, rotate: function(){ current = this.currentSlide; next = (current+1 >= this.slides.length) ? 0 : current+1; this.showSlide(next); this.fireEvent('onRotate');}, show: function() { $(this.options.carouselContainer).setStyle('visibility','visible'); if(!$(this.options.carouselContainer).visible())$(this.options.carouselContainer).show();}, hide: function(){ $(this.options.carouselContainer).setStyle('visibility','hidden');}
}); CNETcarousel.implement(new Options); CNETcarousel.implement(new Events); var CNETcarouselWithButtons = CNETcarousel.extend({ initialize:function(el, options){ this.parent(el, $merge({ bubbleButtonBGImgSelector: '.bbg', buttonOnGifSrc: 'http://i.i.com.com/cnwk.1d/i/fd/c/green_button.gif', buttonOffGifSrc: 'http://i.i.com.com/cnwk.1d/i/fd/c/gray_button.gif'
}, options));}, showSlide: function(slideIndex){ this.buttons.each(function(button, index){ $(button).getElement(this.options.bubbleButtonBGImgSelector).src = (index == slideIndex)?this.options.buttonOnGifSrc:this.options.buttonOffGifSrc;}, this); this.parent(slideIndex);}
}); var carousel = null; window.onDomReady(function(){ if($('Carousel')) { carousel = new CNETcarouselWithButtons($('Carousel'),{buttonsSelector:'.bubble', rotateAction:'mouseover'});}
}); MultipleOpenAccordion = Fx.Elements.extend({ initialize: function(togglers, elements, options){ this.parent(elements, options); this.setOptions(this.options, $merge({ openAll: true, allowMultipleOpen: true, firstElementsOpen: [0], start: 'open-first', fixedHeight: false, fixedWidth: false, alwaysHide: true, wait: false, onActive: Class.empty, onBackground: Class.empty, height: true, opacity: true, width: false
}, options || {})); this.previousClick = 'nan'; this.elementsVisible = []; togglers.each(function(tog, i){ $(tog).addEvent('click', function(){this.toggleSection(i)}.bind(this));}, this); this.togglers = togglers; this.h = {}; this.w = {}; this.o = {}; this.now = []; this.elements.each(function(el, i){ this.now[i] = {}; if(this.options.openAll && this.options.allowMultipleOpen) $(el).setStyles({'overflow': 'hidden'}); else $(el).setStyles({'height': 0, 'overflow': 'hidden'});}, this); if(!this.options.openAll || !this.options.allowMultipleOpen) { switch(this.options.start){ case 'first-open': this.showSection(this.options.firstElementsOpen[0]); break; case 'open-first': this.toggleSection(this.options.firstElementsOpen[0]); break;}
}
if (this.options.openAll && this.options.allowMultipleOpen) { this.showAll();} else if (this.options.allowMultipleOpen) { this.openSections(this.options.firstElementsOpen);}
}, hideThis: function(i){ this.elementsVisible[i] = false; if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, 0]}; if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, 0]}; if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 1, 0]};}, showThis: function(i){ this.elementsVisible[i] = true; if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, this.options.fixedHeight || this.elements[i].scrollHeight]}; if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, this.options.fixedWidth || this.elements[i].scrollWidth]}; if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 0, 1]};}, toggleSection: function(iToToggle){ if(iToToggle != this.previousClick || this.options.alwaysHide || this.options.allowMultipleOpen) { this.previousClick = iToToggle; var objObjs = {}; var err = false; var madeInactive = false; this.elements.each(function(el, i){ var update = false; this.now[i] = this.now[i] || {}; if(i==iToToggle){ if (this.elementsVisible[i] && (this.options.allowMultipleOpen || this.options.alwaysHide)){ if(!(this.options.wait && this.timer)) { update = true; this.hideThis(i);} else { this.previousClick = 'nan'; err = true;}
} else if(!this.elementsVisible[i]){ if(!(this.options.wait && this.timer)) { update = true; this.showThis(i);} else { this.previousClick = 'nan'; err = true;}
}
} else if(this.elementsVisible[i] && !this.options.allowMultipleOpen) { if(!(this.options.wait && this.timer)) { update = true; this.hideThis(i);} else { this.previousClick = 'nan'; err = true;}
}
if(update) objObjs[i] = Object.extend(this.h, Object.extend(this.o, this.w));}, this); if (err) return; if (!madeInactive) this.options.onActive.call(this, this.togglers[iToToggle], iToToggle); this.togglers.each(function(tog, i){ if (!this.elementsVisible[i]) this.options.onBackground.call(this, tog, i);}, this); return this.custom(objObjs);}
}, showSection: function(i, useFx){ if($pick(useFx, false)) { if (!this.elementsVisible[i]) this.toggleSection(i);} else { this.setSectionStyle(i,$(this.elements[i]).scrollWidth, $(this.elements[i]).scrollHeight, 1); this.elementsVisible[i] = true; return true;}
}, hideSection: function(i, useFx){ if($pick(useFx, false)) { if (this.elementsVisible[i]) this.toggleSection(i);} else { this.setSectionStyle(i,0,0,0); this.elementsVisible[i] = false; return true;}
}, setSectionStyle: function(i,w,h,o){ if (this.options.opacity) $(this.elements[i]).setOpacity(o); if (this.options.height) $(this.elements[i]).setStyle('height',h+'px'); if (this.options.width) $(this.elements[i]).setStyle('width',w+'px');}, showAll: function(){ if(this.options.allowMultipleOpen){ this.elements.each(function(el,idx){ this.showSection(idx, false);}, this);}
}, hideAll: function(useFx){ if(this.options.allowMultipleOpen){ this.elements.each(function(el,idx){ this.hideSection(idx, false);}, this);}
}, openSections: function(sections) { if(this.options.allowMultipleOpen){ this.elements.each(function(el,idx){ if(sections.test(idx)) this.showSection(idx, false); else this.hideSection(idx, false);}, this);}
}
}); MultipleOpenAccordion.implement(new Options); function imgMouseOverEvents(outString, overString, selector) { $$(selector).each(function(image) { image = $(image); if ($type(image.src)) { if (image.src.indexOf(outString) > 0) { image.addEvent('mouseover',function(){ image.src = image.src.replace(outString, overString);}).addEvent('mouseout', function(){ image.src = image.src.replace(overString, outString);});}
}
});}; window.onDomReady(function(){imgMouseOverEvents('_off', '_over', 'img.autoMouseOverOff, input.autoMouseOver');}); window.onDomReady(function(){imgMouseOverEvents('_off', '_on', 'img.autoMouseOver');}); function tabMouseOvers(cssOn, cssOff, selector, subselector, applyToBoth){ $$(selector).each(function(el){ el.applyToBoth = $pick(applyToBoth, false); if(applyToBoth && subselector) { el.getElementsBySelector(subselector).each(function(el){ el.addClass(cssOff).removeClass(cssOn);});}
el.addClass(cssOff).removeClass(cssOn); el.addEvent('mouseover', function(){ this.addClass(cssOn).removeClass(cssOff); if(applyToBoth && subselector) { this.getElementsBySelector(subselector).each(function(subel){ subel.addClass(cssOn).removeClass(cssOff);});}
}); el.addEvent('mouseout', function(){ this.addClass(cssOff).removeClass(cssOn); if(applyToBoth && subselector) { $A(this.getElementsBySelector(subselector)).each(function(subel){ subel.addClass(cssOff).removeClass(cssOn);});}
});});}; var TabSwapper = new Class({ initialize: function(options){ this.setOptions({ initPanel: 0, smooth: false, cookieName: null, cookieDays: 999
}, options || {}); this.sectionOpacities = []; if(! $type(this.options.clickSelector)) this.options.clickSelector = this.options.tabSelector; this.setup(); if(this.options.cookieName && parseInt(this.recall())) this.swap(parseInt(this.recall())); else this.swap(this.options.initPanel);}, setup: function(){ var swapper = this; var opt = this.options; $$(opt.clickSelector).each(function(lnk, idx){ lnk.addEvent('click', function(){swapper.swap(idx)});}); if($type(opt.mouseoverClass) && $type(opt.mouseoutClass))
tabMouseOvers(opt.mouseoverClass, opt.mouseoutClass, opt.tabSelector); this.tabs = $$(opt.tabSelector); this.sections = $$(opt.sectionSelector);}, swap: function(swapIdx){ var opt = this.options; var swapper = this; this.tabs.each(function(tab, idx){ if(swapIdx == idx) tab.addClass(opt.selectedClass).removeClass(opt.deselectedClass); else tab.addClass(opt.deselectedClass).removeClass(opt.selectedClass);}); this.sections.each(function(sect, idx){ if(swapIdx == idx) swapper.showSection(idx); else swapper.hideSection(idx);}); if(opt.cookieName) this.save(swapIdx);}, save: function(index){ Cookie.set(this.options.cookieName, index, {duration:this.options.cookieDays});}, recall: function(){ return Cookie.get(this.options.cookieName);}, hideSection: function(idx) { this.sections[idx].hide();}, showSection: function(idx) { var sect = this.sections[idx]; var opacityFx = this.sectionOpacities[idx]; if(!sect.visible()) { if(this.options.smooth) { if (!opacityFx) opacityFx = this.sections[idx].effect('opacity', {duration: 500}); opacityFx.set(0);}
sect.show(); if(this.options.smooth) opacityFx.custom(0,1);}
}
}); TabSwapper.implement(new Options); var tabSwapper = TabSwapper; var SimpleSlideShow = new Class({ options: { startIndex: 0, slides: [], currentSlideClass: 'currentSlide', currentIndexContainer: false, maxContainer: false, nextLink: false, prevLink: false, wrap: true, disabledLinkClass: 'disabled', onNext: Class.empty, onPrev: Class.empty, onSlideClick: Class.empty, crossFadeOptions: {}
}, initialize: function(options){ this.setOptions(options); this.slides = this.options.slides; this.makeSlides(); this.setCounters(); this.setUpNav();}, setCounters: function(){ if($(this.options.currentIndexContainer))$(this.options.currentIndexContainer).setHTML(this.now+1); if($(this.options.maxContainer))$(this.options.maxContainer).setHTML(this.slides.length);}, makeSlides: function(){ this.now = $pick(this.now, this.options.startIndex); this.slides.each(function(slide, index){ if(index != this.now) slide.setStyle('display', 'none'); else slide.setStyle('display', 'block'); this.makeSlide(slide);}, this);}, makeSlide: function(slide){ slide.addEvent('click', function(){ this.fireEvent('onSlideClick');}.bind(this));}, setUpNav: function(){ if($(this.options.nextLink)) $(this.options.nextLink).addEvent('click', function(){ this.cycleForward();}.bind(this)); if($(this.options.prevLink)) $(this.options.prevLink).addEvent('click', function(){ this.cycleBack();}.bind(this));}, cycleForward: function(){ if($type(this.now) && this.now < this.slides.length-1) this.showSlide(this.now+1); else if($type(this.now) && this.options.wrap) this.showSlide(0); else this.showSlide(this.options.startIndex); this.fireEvent('onNext'); if(this.now == this.slides.length && !this.options.wrap && $(this.options.nextLink))
$(this.options.nextLink).addClass(this.options.disabledLinkClass); else if ($(this.options.nextLink)) $(this.options.nextLink).removeClass(this.options.disabledLinkClass);}, cycleBack: function(){ if(this.now > 0) this.showSlide(this.now-1); else if(this.options.wrap) this.showSlide(this.slides.length-1); this.fireEvent('onPrev'); if(this.now == 0 && !this.options.wrap && $(this.options.prevSlide))
$(this.options.prevSlide).addClass(this.options.disabledLinkClass); else if ($(this.options.prevSlide))
$(this.options.prevSlide).removeClass(this.options.disabledLinkClass);}, showSlide: function(iToShow){ var now = this.now; if(this.slides[iToShow]) { if($type(this.now) && this.now != iToShow){ this.slides[this.now].effect('opacity', this.options.crossFadeOptions).start(0).chain(function(){ this.slides[now].hide(); this.slides[iToShow].addClass(this.options.currentSlideClass).setStyles({ 'display':'block', 'opacity':0
}).effect('opacity', this.options.crossFadeOptions).start(1);}.bind(this));} else this.slides[iToShow].setStyles({ 'display':'block', 'opacity':0
}).effect('opacity', this.options.crossFadeOptions).start(1); this.now = iToShow; this.setCounters();}
}, slideClick: function(){ this.fireEvent('onSlideClick', [this.slides[this.now], this.now]);}
}); SimpleSlideShow.implement(new Events); SimpleSlideShow.implement(new Options); var SimpleImageSlideShow = SimpleSlideShow.extend({ options: { imgUrls: [], imgClass: 'screenshot', container: false
}, initialize: function(options){ this.parent(options); this.options.imgUrls.each(function(url){ this.addImg(url);}, this); this.showSlide(this.options.startIndex);}, addImg: function(url){ if($(this.options.container)) { var img = new Element('img').setProperties({ 'src': url, 'id': this.options.imgClass+this.slides.length
}).addClass(this.options.imgClass).setStyle( 'display', 'none').injectInside($(this.options.container)).addEvent( 'click', this.slideClick.bind(this)); this.slides.push(img); this.makeSlide(img); this.setCounters();}
}
}); function imgMouseOverEvents(outString, overString, selector) { $$(selector).each(function(image) { image = $(image); if ($type(image.src)) { if (image.src.indexOf(outString) > 0) { image.addEvent('mouseover',function(){ image.src = image.src.replace(outString, overString);}).addEvent('mouseout', function(){ image.src = image.src.replace(overString, outString);});}
}
});}; window.onDomReady(function(){imgMouseOverEvents('_off', '_over', 'img.autoMouseOverOff, input.autoMouseOver');}); window.onDomReady(function(){imgMouseOverEvents('_off', '_on', 'img.autoMouseOver');}); function tabMouseOvers(cssOn, cssOff, selector, subselector, applyToBoth){ $$(selector).each(function(el){ el.applyToBoth = $pick(applyToBoth, false); if(applyToBoth && subselector) { el.getElementsBySelector(subselector).each(function(el){ el.addClass(cssOff).removeClass(cssOn);});}
el.addClass(cssOff).removeClass(cssOn); el.addEvent('mouseover', function(){ this.addClass(cssOn).removeClass(cssOff); if(applyToBoth && subselector) { this.getElementsBySelector(subselector).each(function(subel){ subel.addClass(cssOn).removeClass(cssOff);});}
}); el.addEvent('mouseout', function(){ this.addClass(cssOff).removeClass(cssOn); if(applyToBoth && subselector) { $A(this.getElementsBySelector(subselector)).each(function(subel){ subel.addClass(cssOff).removeClass(cssOn);});}
});});}; var TabSwapper = new Class({ initialize: function(options){ this.setOptions({ initPanel: 0, smooth: false, cookieName: null, cookieDays: 999
}, options || {}); this.sectionOpacities = []; if(! $type(this.options.clickSelector)) this.options.clickSelector = this.options.tabSelector; this.setup(); if(this.options.cookieName && parseInt(this.recall())) this.swap(parseInt(this.recall())); else this.swap(this.options.initPanel);}, setup: function(){ var swapper = this; var opt = this.options; $$(opt.clickSelector).each(function(lnk, idx){ lnk.addEvent('click', function(){swapper.swap(idx)});}); if($type(opt.mouseoverClass) && $type(opt.mouseoutClass))
tabMouseOvers(opt.mouseoverClass, opt.mouseoutClass, opt.tabSelector); this.tabs = $$(opt.tabSelector); this.sections = $$(opt.sectionSelector);}, swap: function(swapIdx){ var opt = this.options; var swapper = this; this.tabs.each(function(tab, idx){ if(swapIdx == idx) tab.addClass(opt.selectedClass).removeClass(opt.deselectedClass); else tab.addClass(opt.deselectedClass).removeClass(opt.selectedClass);}); this.sections.each(function(sect, idx){ if(swapIdx == idx) swapper.showSection(idx); else swapper.hideSection(idx);}); if(opt.cookieName) this.save(swapIdx);}, save: function(index){ Cookie.set(this.options.cookieName, index, {duration:this.options.cookieDays});}, recall: function(){ return Cookie.get(this.options.cookieName);}, hideSection: function(idx) { this.sections[idx].hide();}, showSection: function(idx) { var sect = this.sections[idx]; var opacityFx = this.sectionOpacities[idx]; if(!sect.visible()) { if(this.options.smooth) { if (!opacityFx) opacityFx = this.sections[idx].effect('opacity', {duration: 500}); opacityFx.set(0);}
sect.show(); if(this.options.smooth) opacityFx.custom(0,1);}
}
}); TabSwapper.implement(new Options); var tabSwapper = TabSwapper; JsonP = new Class({ options: { onComplete: Class.empty, callBackKey: "callback", queryString: "", data: {}
}, initialize: function(url, options){ this.setOptions(options); this.url = this.makeUrl(url); this.fired = false;}, request: function(){ dbug.log('retrieving by json script method: %s', this.url); this.script = new Asset.javascript(this.url); this.fired = true;}, makeUrl: function(url){ var index = JsonP.requestors.push(this) - 1; var separator = (url.test('\\?'))?'&':'?'; var jurl = url + separator + this.options.callBackKey + "=JsonP.requestors[" + index+"].handleResults"; if(this.queryString) jurl += "&"+this.queryString; jurl += "&"+Object.toQueryString(this.options.data); return jurl;}, handleResults: function(data){ this.fireEvent('onComplete', data); this.script.remove();}
}); JsonP.requestors = []; JsonP.implement(new Options); JsonP.implement(new Events);