
var custom_handlers_init=false;var original_function_u=null;var original_function_c=null;var original_function_m=null;var original_function_o=null;var active_select_options=null;var cancel_options_hide=false;var custom_scrolls=new Array();var custom_selects=new Array();var custom_radios=new Array();var custom_radios_convert=new Array();function CustomScroll(element,file){if(typeof(element)!="object"){element=document.getElementById(element);}
if(element.id==null){return null;}
this.id=element.id;this.full_content=element;this.dimensions=[0,0,0];this.constructed=false;this.elem_counter=1;this.scroll_timer=null;this.ratio=0;this.button_height=0;this.scroll_cursor_pos=[0,0];this.act_scroll_pos=0;this.dragging=false;this.dragging_point=0;this.texture="/_img/customize/scroll.png";if(typeof(file)!="undefined"){this.texture=file;}
this.construct=function(){setCustomizeHandlers();this.full_content.style.overflow="hidden";this.dimensions=this.getScrollDimensions();this.createElements();this.full_content.onmousewheel=function(e){var obj=custom_scrolls[this.id];if(!e){e=window.event;}
obj.wheelScroll(e);return false;};if(window.addEventListener){this.full_content.addEventListener('DOMMouseScroll',function(e){if(!e){e=window.event;}
var obj=custom_scrolls[this.id];obj.wheelScroll(e);if(e.preventDefault){e.preventDefault();}
e.returnValue=false;return false;},false);}
this.resize();custom_scrolls[this.id]=this;this.constructed=true;}
this.createElements=function(){var scroll=this.createElement('DIV',true);var bar=this.createElement('DIV',false);var m_scroll=this.createElement('DIV',false);var t_btn=this.createElement('DIV',false);var m_btn=this.createElement('DIV',false);var b_btn=this.createElement('DIV',false);var t_part=this.createElement('DIV',false);var b_part=this.createElement('DIV',false);scroll.className="custom_scroll_content";bar.className="custom_scroll_v";m_scroll.className="m_layer";t_btn.className="t_btn";m_btn.className="m_btn";b_btn.className="b_btn";t_part.className="t_part";b_part.className="b_part";t_btn.style.background="url('"+this.texture+"') no-repeat";b_btn.style.background="url('"+this.texture+"') 0 -16px no-repeat";m_btn.style.background="url('"+this.texture+"') -16px 0 repeat-y";bar.style.background="url('"+this.texture+"') -32px 0 repeat-y";t_part.style.background="url('"+this.texture+"') 0 -32px no-repeat";b_part.style.background="url('"+this.texture+"') 0 -37px no-repeat";m_btn.onmousedown=function(e){var id=this.id.split("_");id.pop();var obj=custom_scrolls[id.join("_")];obj.dragScroll(e);return false;};b_btn.onmousedown=function(){var id=this.id.split("_");id.pop();var obj=custom_scrolls[id.join("_")];obj.scrollDown();return false;};t_btn.onmousedown=function(){var id=this.id.split("_");id.pop();var obj=custom_scrolls[id.join("_")];obj.scrollUp();return false;};if(typeof(t_part.innerHTML)!="undefined"){t_part.innerHTML=" ";}
if(typeof(b_part.innerHTML)!="undefined"){b_part.innerHTML=" ";}
if(typeof(t_btn.innerHTML)!="undefined"){t_btn.innerHTML=" ";}
if(typeof(b_btn.innerHTML)!="undefined"){b_btn.innerHTML=" ";}
while(this.full_content.hasChildNodes()){scroll.appendChild(this.full_content.firstChild.cloneNode(true));this.full_content.removeChild(this.full_content.firstChild);}
m_btn.appendChild(t_part);m_btn.appendChild(b_part);m_scroll.appendChild(m_btn);bar.appendChild(t_btn);bar.appendChild(m_scroll);bar.appendChild(b_btn);this.full_content.appendChild(scroll);this.full_content.appendChild(bar);this.scroll_content=scroll;this.track=m_scroll;this.scroll_button=m_btn;this.scroll_bar=bar;this.scroll_content.style.width=(this.dimensions[0]-21)+"px";}
this.reset=function(){if(this.constructed){this.scroll_content.scrollTop=0;this.scroll_button.style.margin="0 0 0 0";this.act_scroll_pos=0;this.resize();}}
this.resize=function(){var height=this.dimensions[1];var width=this.dimensions[0];var maxScroll=(this.scroll_content.scrollHeight-height);var c_height="100%";if(height==67){c_height="67px";}
if(maxScroll>1){this.button_height=(height-32)/(this.scroll_content.scrollHeight/height);if(this.button_height<10){this.button_height=10;}
var maxMargin=(this.dimensions[1]-32)-this.button_height;this.ratio=maxScroll/maxMargin;this.scroll_content.style.width=(width-21)+"px";this.scroll_content.style.height=c_height;this.scroll_bar.style.height=height+"px";this.scroll_bar.style.margin="-"+height+"px 0 0 "+(width-16)+"px";this.scroll_bar.style.display="block";this.track.style.height=(height-32)+"px";this.scroll_button.style.height=(this.button_height)+"px"
if(this.scroll_content.scrollTop>0){this.fixPosition(this.scroll_content.scrollTop);}}else{this.scroll_content.style.width=(width-21)+"px";this.scroll_content.style.height=c_height;this.scroll_bar.style.height="1px";this.scroll_bar.style.margin="0";this.scroll_bar.style.display="none";}}
this.fixPosition=function(scroll){if(this.scroll_content.scrollTop>0){var pos=this.scroll_content.scrollTop/this.ratio;this.scrollTo(pos);}}
this.createElement=function(nodename,select){var elem=document.createElement(nodename);elem.id=this.id+"_"+this.elem_counter;elem.style.display="block";if(!select){elem.onselectstart=function(){return false;}
elem.onmousedown=function(){return false;}}
this.elem_counter++;return elem;}
this.scrollUp=function(){this.scroll(-1);this.scroll_timer=setInterval("custom_scrolls['"+this.id+"'].scroll(-1);",100);}
this.scrollDown=function(){this.scroll(1);this.scroll_timer=setInterval("custom_scrolls['"+this.id+"'].scroll(1);",100);}
this.stopScroll=function(){if(this.scroll_timer!=null){clearInterval(this.scroll_timer);}
this.scroll_timer=null;this.dragging=false;}
this.scroll=function(dist){var maxMargin=(this.dimensions[1]-32)-this.button_height;var val=this.act_scroll_pos+dist;if(val<0){val=0;}
if(val>maxMargin){val=maxMargin;}
this.scrollTo(val);}
this.scrollTo=function(val){var height=this.dimensions[1];var width=this.dimensions[0];var maxMargin=(height-32)-this.button_height;if(val<0){val=0;}
if(val>maxMargin){val=maxMargin;}
this.act_scroll_pos=val;this.scroll_content.scrollTop=this.act_scroll_pos*this.ratio;this.scroll_button.style.margin=val+"px 0 0 0";}
this.scrollBy=function(val){val=this.act_scroll_pos+val;this.scrollTo(val);}
this.dragScroll=function(e){if(e==null){e=window.event};this.scroll_cursor_pos=[e.clientX,e.clientY];this.dragging_point=this.act_scroll_pos;this.dragging=true;}
this.scrollDragMove=function(e){if(this.dragging){if(e==null){e=window.event};var pos=[e.clientX,e.clientY];var dist=this.dragging_point+(pos[1]-this.scroll_cursor_pos[1]);this.scrollTo(dist);}}
this.wheelScroll=function(e){var delta=0;if(e.wheelDelta){delta=e.wheelDelta/120;}else if(e.detail){delta=-e.detail/3;}
this.scrollBy((-delta)*(this.ratio*5));}
this.getScrollDimensions=function(){var width=0;var height=0;width=getRenderedWidth(this.full_content);height=getRenderedHeight(this.full_content);if(width<30){width=30;}
if(height<67){height=67;}
return[width,height];}
this.construct();}
function setCustomizeHandlers(){if(!custom_handlers_init){original_function_u=document.onmouseup;original_function_c=document.onclick;original_function_m=document.onmousemove;original_function_o=window.onload;document.onmouseup=cancelActionU;document.onclick=cancelActionC;document.onmousemove=scrollDragMove;window.onload=onloadReset;}
custom_handlers_init=true;}
function onloadReset(e){for(var key in custom_scrolls){if(typeof(custom_scrolls[key].fixPosition)!="undefined"){custom_scrolls[key].fixPosition();}}
if(typeof(original_function_o)=="function"){return original_function_o(e);}else{}}
function scrollDragMove(e){for(var key in custom_scrolls){if(typeof(custom_scrolls[key].scrollDragMove)!="undefined"){custom_scrolls[key].scrollDragMove(e);}}
if(typeof(original_function_m)=="function"){return original_function_m(e);}else{}}
function cancelActionU(e){for(var key in custom_scrolls){if(typeof(custom_scrolls[key].stopScroll)!="undefined"){custom_scrolls[key].stopScroll();}}
if(typeof(original_function_u)=="function"){return original_function_u(e);}else{}}
function cancelActionC(e){for(var key in custom_scrolls){if(typeof(custom_scrolls[key].stopScroll)!="undefined"){custom_scrolls[key].stopScroll();}}
if(active_select_options!=null&&!cancel_options_hide){active_select_options.style.display="none";active_select_options=null;}
cancel_options_hide=false;if(typeof(original_function_c)=="function"){return original_function_c(e);}else{}}
function CustomSelect(elem){if(typeof(elem)!="object"){this.element=document.getElementById(elem);}else{this.element=elem;}
this.id=null;if(this.element.id==null){return null;}else{this.id=this.element.id;}
this.construct=function(){this.width=this.element.scrollWidth;this.height=getRenderedHeight(this.element);if(this.width==0){var clone=this.element.cloneNode(true);clone.style.position="absolute";clone.style.top="-500px";clone.style.left="-500px";var body=document.getElementsByTagName('BODY')[0];body.appendChild(clone);this.width=clone.scrollWidth;this.height=getRenderedHeight(clone);body.removeChild(clone);}
setCustomizeHandlers();this.container=document.createElement("DIV");this.options=document.createElement("DIV");this.label=document.createElement("A");var value="";for(var i=0;i<this.element.options.length;i++){if(this.element.options[i].selected){value=this.element.options[i].text;}
var newopt=document.createElement("A");newopt.appendChild(document.createTextNode(this.element.options[i].text));newopt.href="javascript:void(0);";newopt.name="i"+i;newopt.rel=this.id;newopt.onclick=function(){var i=this.name.substring(1);custom_selects[this.rel].selectOption(i);return false;};this.options.appendChild(newopt);}
var txt=document.createElement("SPAN");txt.appendChild(document.createTextNode(value));this.label.appendChild(txt);this.label.rel=this.id;this.label.href="javascript:void(0);";this.label.onmouseup=function(){custom_selects[this.rel].openOptions();cancel_options_hide=true;return false;};this.container.className="custom_select";this.container.appendChild(this.options);this.container.appendChild(this.label);this.element.parentNode.appendChild(this.container);this.options.style.width=(this.width-2)+"px";this.options.className="select_options";if(this.options.scrollWidth>this.width){this.width=this.options.scrollWidth;}
var Hconst=6;if(navigator.appName=='Microsoft Internet Explorer'){var ua=navigator.userAgent;var re=new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");if(re.exec(ua)!=null){rv=parseFloat(RegExp.$1);}
if(rv<7){Hconst=6;}else if(rv<8){Hconst=29;}else{Hconst=8;}}else if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){Hconst=9;}
this.width+=Hconst;this.container.style.width=(this.width-2)+"px";this.container.style.minHeight=(this.height-2)+"px";this.label.style.width=(this.width-2)+"px";this.label.style.minHeight=(this.height-2)+"px";if(this.element.options.length>8){this.options.style.height=(8*(this.height-2))+"px";this.options.className+=" options_scroll";}else{this.options.className+=" options_noscroll";}
this.options.style.width=(this.width-2)+"px";this.options.style.display="none";this.label.className="select_label";this.element.style.display="none";custom_selects[this.id]=this;}
this.selectOption=function(i){this.element.selectedIndex=i;this.closeOptions();this.label.firstChild.firstChild.data=this.element.options[i].text;if(this.element.onchange!=null){this.element.onchange();}}
this.openOptions=function(){var Hconst=0;if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){Hconst=-1;}else if(navigator.appName=='Microsoft Internet Explorer'){Hconst=1;}
active_select_options=this.options;this.options.style.marginTop=(this.label.scrollHeight+Hconst)+"px";this.options.style.display="";if(this.element.onclick!=null){this.element.onclick();}}
this.closeOptions=function(){this.options.style.display="none";this.options.scrollTop=0;active_select_options=null;}
this.construct();}
function CustomRadio(name,form){this.form_i=null;this.elements=new Array();this.new_elements=new Array();if(typeof(form)=="undefined"||form==null){for(var i=0;i<document.forms.length;i++){var form=document.forms[i];for(var y=0;y<form.elements.length;y++){var element=form.elements[y];if(element.type=="radio"&&element.name==name){this.form_i=i;this.elements.push(element);if(typeof(element.id)!="undefined"&&element.id!=null){custom_radios_convert[element.id]=[i,y];}}}
if(this.form_i!=null){break;}}}else{if(typeof(form)!="object"){form=document.getElementById(form);}
var tmp=form.id;form.id="test_form_id_tmp";for(var i=0;i<document.forms.length;i++){var form=document.forms[i];if(form.id=="test_form_id_tmp"){this.form_i=i;for(var y=0;y<form.elements.length;y++){var element=form.elements[y];if(element.type=="radio"&&element.name==name){this.elements.push(element);if(typeof(element.id)!="undefined"&&element.id!=null){custom_radios_convert[element.id]=[i,y];}}}
break;}}
form.id=tmp;}
if(this.form_i==null||this.elements.length==0){return null;}else if(typeof(custom_radios[this.form_i])!="undefined"){return custom_radios[this.form_i];}
this.construct=function(){var labels=document.getElementsByTagName("LABEL");for(var i=0;i<labels.length;i++){var label=labels[i];label.onclick=function(){var id=this.htmlFor;if(typeof(custom_radios_convert[id])!="undefined"){var keys=custom_radios_convert[id];custom_radios[keys[0]].check(keys[1]);return false;}};}
for(var i=0;i<this.elements.length;i++){var element=this.elements[i];var replacer=document.createElement("A");element.style.display="none";replacer.rel="f"+this.form_i+"_e"+i;replacer.className+="custom_radio";replacer.href="javascript:void(0);";replacer.appendChild(document.createTextNode(' '));replacer.onclick=function(){var parts=this.rel.split('_');var form=parts[0].substring(1);var i=parts[1].substring(1);custom_radios[form].check(i);return false;};if(element.checked){replacer.className+=" custom_radio_checked";}
element.parentNode.insertBefore(replacer,element);this.new_elements.push(replacer);}
custom_radios[this.form_i]=this;}
this.check=function(num){for(var i=0;i<this.elements.length;i++){var element=this.elements[i];var new_element=this.new_elements[i];if(i==num){element.checked=true;new_element.className="custom_radio custom_radio_checked";}else{element.checked=false;new_element.className="custom_radio";}}
if(typeof(this.elements[num])!="undefined"&&this.elements[num].onclick!=null){this.elements[num].onclick();}}
this.construct();}
function getRenderedWidth(elem){var width=getStyle(elem,"width");var padding=parseInt(getStyle(elem,"padding-right").replace("px",""))+parseInt(getStyle(elem,"padding-left").replace("px",""));if(width!=null&&width!="auto"){if(width.indexOf("%")>=0){if(elem.parentNode){var i=parseInt(width.replace("%",""))/100;width=i*getRenderedWidth(elem.parentNode)-padding;}else{width=elem.scrollWidth;}}else{width=parseInt(width.replace("px",""))-padding;}}else if(elem.parentNode){width=getRenderedWidth(elem.parentNode)-padding;}else{width=elem.scrollWidth;}
return width;}
function getRenderedHeight(elem){var height=getStyle(elem,"height");var padding=parseInt(getStyle(elem,"padding-top").replace("px",""))+parseInt(getStyle(elem,"padding-bottom").replace("px",""));if(height!=null&&height!="auto"){if(height.indexOf("%")>=0){if(elem.parentNode){var i=parseInt(height.replace("%",""))/100;height=i*getRenderedHeight(elem.parentNode)-padding;}else{height=elem.scrollHeight;}}else{height=parseInt(height.replace("px",""))-padding;}}else{height=elem.scrollHeight;}
return height;}
function getStyle(oElm,strCssRule){var strValue=null;if(typeof(document.defaultView)!="undefined"&&typeof(document.defaultView.getComputedStyle)!="undefined"){var style=document.defaultView.getComputedStyle(oElm,null);if(!window.opera&&typeof(style.getPropertyCSSValue)!="undefined"){strValue=style.getPropertyCSSValue(strCssRule).cssText;}else{strValue=style.getPropertyValue(strCssRule);}}else if(oElm.currentStyle){strCssRule=strCssRule.replace(/\-(\w)/g,function(strMatch,p1){return p1.toUpperCase();});strValue=oElm.currentStyle[strCssRule];}
return strValue;}