﻿﻿﻿/*03-08-2011 21:00 CT */

/*framework.js
 @Autor Julio Tinajero
 � 2011 Hewlett-Packard Development Company, L.P

 Framework.js will be the placeholder for all the classes  and functions that will wire up from utilities, the GUI elements objects from HP.com UI framework, also contains global functions that are used across all hp. */
 


var supportSearch;

/** CLEARING AND RESTORING DATA FROM FIND YOUR PRODUCT SEARCHBOX* */
function clearSearch(el) {
    window.supportSearch = el.value;
    el.value = '';

}

function restoreSearch(el) {
    if (el.value == '')
        el.value = supportSearch;
}

/**
 * Mootools-more Tips class
 */
(function(){var a=function(c,b){return(c)?($type(c)=="function"?c(b):b.get(c)):"";
};this.Tips=new Class({Implements:[Events,Options],options:{onShow:function(){this.tip.setStyle("display","block");},onHide:function(){this.tip.setStyle("display","none");
},title:"title",text:function(b){return b.get("rel")||b.get("href");},showDelay:100,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:false},initialize:function(){var b=Array.link(arguments,{options:Object.type,elements:$defined});
this.setOptions(b.options);if(b.elements){this.attach(b.elements);}this.container=new Element("div",{"class":"tip"});},toElement:function(){if(this.tip){return this.tip;
}return this.tip=new Element("div",{"class":this.options.className,styles:{position:"absolute",top:0,left:0}}).adopt(new Element("div",{"class":"tip-top"}),this.container,new Element("div",{"class":"tip-bottom"}));
},attach:function(b){$$(b).each(function(d){var f=a(this.options.title,d),e=a(this.options.text,d);d.erase("title").store("tip:native",f).retrieve("tip:title",f);
d.retrieve("tip:text",e);this.fireEvent("attach",[d]);var c=["enter","leave"];if(!this.options.fixed){c.push("move");}c.each(function(h){var g=d.retrieve("tip:"+h);
if(!g){g=this["element"+h.capitalize()].bindWithEvent(this,d);}d.store("tip:"+h,g).addEvent("mouse"+h,g);},this);},this);return this;},detach:function(b){$$(b).each(function(d){["enter","leave","move"].each(function(e){d.removeEvent("mouse"+e,d.retrieve("tip:"+e)).eliminate("tip:"+e);
});this.fireEvent("detach",[d]);if(this.options.title=="title"){var c=d.retrieve("tip:native");if(c){d.set("title",c);}}},this);return this;},elementEnter:function(c,b){this.container.empty();
["title","text"].each(function(e){var d=b.retrieve("tip:"+e);if(d){this.fill(new Element("div",{"class":"tip-"+e}).inject(this.container),d);}},this);$clear(this.timer);
this.timer=(function(){this.show(b);this.position((this.options.fixed)?{page:b.getPosition()}:c);}).delay(this.options.showDelay,this);},elementLeave:function(c,b){$clear(this.timer);
this.timer=this.hide.delay(this.options.hideDelay,this,b);this.fireForParent(c,b);},fireForParent:function(c,b){b=b.getParent();if(!b||b==document.body){return;
}if(b.retrieve("tip:enter")){b.fireEvent("mouseenter",c);}else{this.fireForParent(c,b);}},elementMove:function(c,b){this.position(c);},position:function(e){if(!this.tip){document.id(this);
}var c=window.getSize(),b=window.getScroll(),f={x:this.tip.offsetWidth,y:this.tip.offsetHeight},d={x:"left",y:"top"},g={};for(var h in d){g[d[h]]=e.page[h]+this.options.offset[h];
if((g[d[h]]+f[h]-b[h])>c[h]-this.options.windowPadding[h]){g[d[h]]=e.page[h]-this.options.offset[h]-f[h];}}this.tip.setStyles(g);},fill:function(b,c){if(typeof c=="string"){b.set("html",c);
}else{b.adopt(c);}},show:function(b){if(!this.tip){document.id(this);}if(!this.tip.getParent()){this.tip.inject(document.body);}this.fireEvent("show",[this.tip,b]);
},hide:function(b){if(!this.tip){document.id(this);}this.fireEvent("hide",[this.tip,b]);}});})();

/*
 * @Name ArrowTips @Author Maksim Berezovsky @Params -TBD
 */
var ArrowTips = new Class({

    Extends: Tips,

    elementEnter: function(event, element) {
        this.container.empty();

        ['title', 'text'].each(function(value) {
            var content = element.retrieve('tip:' + value);
            if (content) this.fill(new Element('div', {'class': 'tip-' + value}).inject(this.container), content);
        }, this);

        $clear(this.timer);
        this.timer = (function() {
            this.show(element);
            this.options.fixed ? this.positionToElement(event, element) : this.position(event);
        }).delay(this.options.showDelay, this);
    },

    positionToElement: function(event, element) {
        if (!this.tip) document.id(this);

        var dimensions = element.getCoordinates(),
                wSize = window.getSize(),
                wScroll = window.getScroll(),
                tOffset = this.options.offset,
                tSize = this.tip.getSize(),
                styles = {'z-index':2 };

        styles.left = dimensions.left + tOffset.x;
        if (styles.left + tSize.x - wScroll.x > wSize.x) {
            styles.left = dimensions.right - tSize.x;
            this.tip.addClass('tip-pos-right');
        } else {
            this.tip.removeClass('tip-pos-right');
        }

        styles.top = dimensions.top - tSize.y - tOffset.y;
        if (dimensions.top - tSize.y < wScroll.y) {
            styles.top = dimensions.bottom + tOffset.y;
            this.tip.addClass('tip-pos-bottom');
        } else {
            this.tip.removeClass('tip-pos-bottom');
        }

        this.tip.setStyles(styles);
    }

});

/*
 * @Name FlashBanner @Author Julio Tinajero 
 * @Description  Flash Banner detector, if flash is enabled creates a SWF object and embeds it to the page (based on href of anchor element in flash banner container, which afterwards is destroyed), if flash is not installed or disabled will display default html banner based on flash-banner-molecule structure.
 */

var FlashBanner= new Class({
		Implements:Options,
		options:{
		bannerClass:'.js_multi_banner',
		containerClass:'.js_flash_banner',
		singleVersionClass:'.js_banner',
		tabbedHTMLVersionClass:'.js_tab_banner',
		tabTriggerClass:'.js_bnnr_tab_trigger',
		tabTargetClass:'.js_banner_tab',
		rotateBanner:false,
		swfURL:'.js_swf_obj',
		debugMode:false,
		useFx: false,
		rotate:false,
		rotatePeriod:3000,
		bannerType:'img_banner'//Possible types are img_banner(default),tab_banner and degree_banner
		},
		initialize:function(options){
		this.setOptions(options || {});
		
		if(Browser.Plugins.Flash && Browser.Plugins.Flash.version>=9 && !this.options.debugMode){
		this.embedFlash();
		}
		
		else{
		switch(this.options.bannerType){
		case 'tab_banner':
		this.useTabbedHTMLVersion();
		break;		
		case 'img_banner':
		this.useHTMLVersion();
		break;
		case 'degree_banner':
		break;
		default:
		this.useHTMLVersion();
		break;
		
		}
		
		}
		
		},
		embedFlash:function(){
	    var flashObjContainer= $$(this.options.bannerClass)[0].getElements(this.options.containerClass)[0];
		var flashObj= new Swiff(flashObjContainer.getElements('.js_swf_obj')[0].getProperty('href'),{
		width:1000, height:306, id:'sw-landing-1000x306', container:flashObjContainer, params: {wmode:'opaque',bgcolor:'#000000',scale:'showall',menu:'false'},vars: {}, properties:{}});
		flashObjContainer.removeClass('hidden');
		
		
	    //Eventually after the flash content is pulled from the HTML, destroy HTML banner container
		
		
		},
		useHTMLVersion:function(){
		 var flashObjContainer= $$(this.options.bannerClass)[0].getElements(this.options.containerClass)[0];	
		$$(this.options.singleVersionClass)[0].removeClass('hidden');
		flashObjContainer.destroy();
		
		},
		useTabbedHTMLVersion:function(){
		var tabbedHTMLContainer= $$(this.options.tabbedHTMLVersionClass)[0].removeClass('hidden');
		var tabControl = new CHKTabControl($(document.body),{
		loop: true,
		rotationDelay: this.options.rotatePeriod,
		rotationDirection: 'forward', // forward, backward
		rotationTimer: 1000
		});
        var currentTab = 1;
        var triggerEls = $$(this.options.tabTriggerClass);
        var targetEls = $$(this.options.tabTargetClass);
		triggerEls.each(function(triggerEl, index) {
            tabControl.addTab(new CHKCustomPopUp(triggerEl, targetEls[index], {
                showEvent : 'click',
                hideEvent : null,
                showTriggerClass : 'sld_sel',
                hideTriggerClass : '',
                preventDefault : false,
				useFx:this.options.useFx,
				fxOpenStylePre: {opacity:0,display:'none'},
				fxOpenStyle: {opacity:1, display:'block',visibility:'visible'},
				fxCloseStyle:{opacity:0,visibility:'hidden', display:'none'},
				fxCloseStylePost: {opacity:0, display:'none'},
				fxWait: false,
				fxDuration: 2000,
				fxTransition: Fx.Transitions.Back.easeOut,
                overrides: {
                    keypressHandler: function(event) {
                        if (event && event.key && event.key == 'enter') {
                            if (this.options.stopPropagation) event.stopPropagation();
                            if (this.options.preventDefault) event.preventDefault();
                            $clear(this.timer);
                            if (this.isOpen === false) {
                                this.show();
                            }
                        }
                    }
                }
			
            }));

            if (triggerEl.hasClass('js_current')) {
                currentTab = index;
			
            }
			
			triggerEl.addEvent('click',function(){
			tabControl.rotateStop();
			(function(){tabControl.rotateStart();}).delay(10000);
			});
        }.bind(this));
		tabControl.hideAllTabs();
		if(this.options.rotate){
		tabControl.rotateStart();
		}
       core.addView(tabControl);
		
        tabControl.showTab(currentTab, false);
		
		
		}
		});
/*
 * @Name NavTogglerListAccordion @Author Julio Tinajero @Params String:
 * togglerSelectorPath - CSS Selector path, String: toggleEvent - click event or
 * mouseenter, String: toggledClass - Expander Class that will be toggled
 * @Description Expandable accordion for nav list element structure in right or
 * left navigation (RTL), it toggles the passed class to the parent of the
 * passed toggler Selector path
 */
var NavTogglerListAccordion = new Class({
    initialize : function(togglerSelectorPath, toggleEvent, toggledClass) {
        $$(togglerSelectorPath).each(function(el) {
            el.addEvent(toggleEvent, function() {
                el.getParent().toggleClass(toggledClass);
            });
        });
    }
});

/*
 * @Name ExpandableContentArea @Author Julio Tinajero @Params Element: triggerEl -
 * Expandable element parent, Element: targetEl - Expanded Element, usually with
 * class .js_expander @Description Expandable container used in Support Topics
 * page, it expands the js_expander inner container and switches the entire area
 * to a gray color
 */

var ExpandableContentArea = new Class(
{

    initialize : function(triggerEl, targetEl) {
        if (triggerEl && targetEl) {
            this.fixOverflow(triggerEl, targetEl);
            this.addTriggerEvents(triggerEl, targetEl);
        }
    },

    fixOverflow : function(trigger, target) {
        var textBlockEl = trigger.getElement('.js_text_block');

        if (textBlockEl) {
            var expandedTitle = trigger
                    .getElement('.js_expanded_title');
            expandedTitle.addClass('limit_f140_2ln');
            if (expandedTitle.getHeight() <= expandedTitle
                    .getScrollHeight()) {
                expandedTitle.removeClass('limit_f140_2ln');
            }

           // trigger.addClass('hand');
            target.addClass('limits');
        } else {
            target.removeClass('limits');
        }
    },

    addTriggerEvents : function(container) {
        var expanderEl = container.getElement('.js_expander'), textBlockEl = container
                .getElement('.js_text_block');

        if (textBlockEl) {
            var fxTimer = null, whiteSkinned = !!container
                    .getParents('.white').length, expandTween = new Fx.Tween(
                    expanderEl, {
                duration : 500,
                link : 'cancel'
            }), highlightMorph = new Fx.Morph(container, {
                duration : 500,
                link : 'cancel'
            });

            var expandToColor = whiteSkinned ? '#eee' : '#202020', collapseToColor = whiteSkinned ? '#fff'
                    : '#131313';

            var expand = function() {
                $clear(fxTimer);
                fxTimer = (function() {
                    expandTween.start('height', expanderEl
                            .getScrollHeight());
                    highlightMorph.start({
                        backgroundColor : expandToColor
                    });
                }).delay(300);
            };

            var collapse = function() {
                $clear(fxTimer);
                fxTimer = (function() {
                    expandTween.start('height', '0px');
                    highlightMorph.start({
                        backgroundColor : collapseToColor
                    });
                }).delay(100);
            };

            //container.addClass('hand');
            expanderEl.addClass('limits');
            collapse();

            container.addEvents({
                mouseenter : expand,
                mouseleave : collapse
            });

            container.getElements('a').addEvents({
                focus : expand,
                blur : collapse
            });
        } else {
            expanderEl.removeClass('limits');
        }

        container.addEvent('click', function() {
           // document.location = container.getElement('a').href;
        });
    }

});

/**
 * @Name SimpleColPopupHover @Author Julio Tinajero @Params Element: triggerEl -
 * Trigger Element that will open a popup on hover or focus event, Element:
 * targetEl - Overlayed element @Description Popup functionality for 3 column
 * popup layout
 */
var SimpleColPopUpHover = new Class({

    Extends : CHKCustomPopUp,

    options : {
        showEvent : [ 'mouseenter', 'focus' ],
        hideEvent : [ 'mouseleave', 'blur' ],
        useFx : true,
        fxOpenStyle : {
            opacity : 1,
            display : 'block'
        },
        fxOpenStylePre : {
            opacity : 0,
            display : 'none'
        },
        fxCloseStyle : {
            opacity : 0
        },
        fxCloseStylePost : {
            opacity : 1,
            display : 'none'
        },
        fxDuration : 300,
        fxTransition : Fx.Transitions.Sine.easeInOut,
        enableKeypress : true
    },

    initialize : function(triggerEl, targetEl, options) {
        triggerEl = $(triggerEl);
        targetEl = $(targetEl);

        if (!triggerEl || !targetEl) {
            return;
        }

        this.setOptions(options);
        this.parent(triggerEl, targetEl, this.options);

        core.addPagePopup(this);
        this.addKeyboardEvents();
    },

    addKeyboardEvents : function() {
        this.triggerEl.getElements('a').addEvent('click', function() {
            this.show();
        }.bind(this));
    }

});

/*
 * @Name SimpleColPopupClick @Author Julio Tinajero @Params Element: triggerEl -
 * Trigger Element that will open a popup on hover or focus event, Element:
 * targetEl - Overlayed element, Array: showEvts- Array containing show events,
 * Array: hideEls- Array containing hide events @Description Popup functionality
 * for 3 column popup layout
 */
var SimpleColPopUpClick = new Class({

    Extends : CHKCustomPopUp,

    options : {
        showEvent : 'click',
        hideEvent : '',
        useFx : true,
        fxOpenStyle : {
            opacity : 1,
            display : 'block'
        },
        fxOpenStylePre : {
            opacity : 0,
            display : 'none'
        },
        fxCloseStyle : {
            opacity : 0
        },
        fxCloseStylePost : {
            opacity : 1,
            display : 'none'
        },
        fxDuration : 300,
        fxTransition : Fx.Transitions.Sine.easeInOut,
        enableKeypress : true
    },

    initialize : function(triggerEl, targetEl, hideEls, options) {
        triggerEl = $(triggerEl);
        targetEl = $(targetEl);

        if (!triggerEl || !targetEl) {
            return;
        }

        this.setOptions(options);
        this.parent(triggerEl, targetEl, this.options);
        core.addPagePopup(this);

        $splat(hideEls).each(function(element) {
            this.addHideElement(element);
        }, this);
    }
});

/*
 * @Name TabbedNavigation @Author Julio Tinajero @Params String ClassPath:
 * tabTriggerClass - Class in tab menu, String Classpath: tabTargetClass - class
 * in tab target container @Description Tabbed Navigation Menu, takes one tab
 * class as parameter and wires it up to its counterpart in tabTargetClass
 * (found in the DOM)
 */
var TabbedNavigation = new Class({

    initialize : function(tabTriggerClass, tabTargetClass) {
        if (!tabTriggerClass || !tabTargetClass) {
            return;
        }
        this.onPageLoad(tabTriggerClass, tabTargetClass);
        // wire up the View controls
        var tabControl = new CHKTabControl($(document.body));
        var currentTab = 1;
        var triggerEls = $$(tabTriggerClass);
        var targetEls = $$(tabTargetClass);
		
		var showTabHandler = function (index) {
			updateScreenReading(this.tabs[index].triggerEl, '.js_selectedTab');
		}.bind(tabControl);
		
		var hideTabHandler = function (index) {
			updateScreenReading(this.tabs[index].triggerEl, '.js_unselectedTab');
		}.bind(tabControl);
		
		tabControl.addEvents({
			onShowTab : showTabHandler,
			onHideTab : hideTabHandler
		});

        triggerEls.each(function(triggerEl, index) {
            tabControl.addTab(new CHKCustomPopUp(triggerEl, (triggerEl.getProperty('rel')!="")?$(triggerEl.getProperty('rel')):targetEls[index], {
                showEvent : 'click',
                hideEvent : null,
                showTriggerClass : 'current',
                hideTriggerClass : '',
                preventDefault : false,
                overrides: {
                    keypressHandler: function(event) {
                        if (event && event.key && event.key == 'enter') {
                            if (this.options.stopPropagation) event.stopPropagation();
                            if (this.options.preventDefault) event.preventDefault();
                            $clear(this.timer);
                            if (this.isOpen === false) {
                                this.show();
                            }
                        }
                    }
                }
            }));

            if (triggerEl.hasClass('current')) {
                currentTab = index;
            }

            triggerEl.addEvent('click',function(){
               this.setScreenReaderText(triggerEls,index);
            }.bind(this));

			
			hideTabHandler(index);
			
        }.bind(this));
        core.addView(tabControl);
        tabControl.showTab(currentTab, false);

    },
     //NOTE: modified screenReading content
    setScreenReaderText: function(triggerEls, cur_tab) {
        triggerEls.each(function(triggerEl, i) {
            if (cur_tab == i)
                triggerEl.getElements('.screenReading')[0].set("text", "Tab - Selected");
            else
                triggerEl.getElements('.screenReading')[0].set("text", "Tab");
        });
    },

    onPageLoad : function(tabTriggerClass, tabTargetClass) {
        var triggers = $$(tabTriggerClass);
        var target = $$(tabTargetClass);
        var location = window.location.href.split("#tab");
        var pattern = /[0-9]+/gi;
        var currentTab = pattern.exec(location[1]);

        if (currentTab <= target.length && currentTab > 0) {
            triggers.removeClass('current');
            triggers[currentTab - 1].addClass('current');
            this.setScreenReaderText(triggers,currentTab-1);
        }

    }
});

var UnderLayedPopup = new Class({

    Extends : CHKCustomPopUp,

    options : {
        syncFlash: false,
        popupOptions : {
            tabIndex : 10,
            showEvent : 'click',
            hideEvent : null,
            useFx : true,
            fxOpenStyle : {
                opacity : 1
            },
            fxOpenStylePre : {
                opacity : 0,
                display : 'block',
                visibility : 'visible'
            },
            fxCloseStyle : {
                opacity : 0
            },
            fxCloseStylePost : {
                opacity : 0,
                display : 'none',
                visibility : 'hidden'
            },
            fxDuration : 100,
            fxTransition : Fx.Transitions.Sine.easeInOut,
            enableKeypress : false
        },
        closeElsClass : '.js_pop_close'
    },

    initialize : function(triggerEl, targetEl, options) {
        triggerEl = $(triggerEl);
        targetEl = $(targetEl);

        if (!triggerEl || !targetEl) {
            return;
        }

        this.setOptions(options || {});
        this.parent(triggerEl, targetEl, this.options.popupOptions);

        this.initDarkenLayer();
        this.initCloseButtons();

        this.bindEvents();
        this.checkFlash();
        this.hide(true);
        this.targetEl.inject($(document.body));
    },

    /**
     * @method initDarkenLayer
     * @description initialize darken layer as a static variable, coz no need to
     *              create the same for each popup
     */
    initDarkenLayer : function() {
        this.darkenEl = new Element('div', {
            'class' : 'pop_drk',
            'opacity' : ' 0.8'
        });
    },

    /**
     * @method initCloseButtons
     * @description initialize close button(s) with events
     */
    initCloseButtons : function() {
        var closeEls = this.targetEl.getElements(this.options.closeElsClass);
        closeEls.setProperty('tabindex', this.options.tabIndex + 1);
        closeEls.addEvent('click', function(event) {
            event.stop();
            this.hide();
        }.bind(this));
    },

    /**
     * @method bindEvents
     * @description setup show/hide events to control darken layer, its height
     *              and also opens proper accordion element
     */
    bindEvents : function() {
        this.addEvent('onshow', this.onPopupShow.bind(this));
        this.addEvent('onhide', this.onPopupHide.bind(this));
    },

    /**
     * @method checkFlash
     * @description if flash sync fix needed (flash keeps playing in ie when element is hidden)
     * it stores flash object as a string that will be used to insert flash object when popup is opened
     */
    checkFlash: function() {
        if (this.options.syncFlash) {
            var flashEl = this.targetEl.getElement('object');
            if (flashEl) {
                this.flashWrapEl = (new Element('div')).addClass('fsh-syn').wraps(flashEl);
                this.flashContentEl = this.flashWrapEl.get('html');
            }
        }
    },

    /**
     * @method syncFlash
     * @param display {Boolean} - if true - will inject flash string, otherwise - remove it from flash wrapper
     * @description if flash sync fix needed (flash keeps playing in ie when element is hidden)
     * it stores flash object as a string that will be used to insert flash object when popup is opened
     */
    syncFlash: function(display) {
        if (this.options.syncFlash && this.flashWrapEl) {
            this.flashWrapEl.set('html', display ? this.flashContentEl : '');
        }
    },

    /**
     * @method onPopupHide
     * @description popup hide event handler
     */
    onPopupHide: function() {
        this.darkenEl.dispose();
        this.syncFlash(false);
    },

    /**
     * @method onPopupShow
     * @description popup showing event handler
     */
    onPopupShow : function() {
        var bodyEl = $(document.body);
        this.targetEl.setStyles({
            top : bodyEl.getScrollTop(),
            marginLeft : -this.targetEl.getWidth() / 2
        });

        this.darkenEl.setStyle('height', bodyEl.getScrollHeight());
        this.darkenEl.inject(bodyEl);
        this.syncFlash(true);
    }

});


/**
 * @class SurveyWidget
 * @description initialize survey widget
 */
var SurveyWidget = new Class({

    Extends : UnderLayedPopup,

    options : {
		//popupOptions : {
		popupOptions : {
            tabIndex : 1
		
		},
        parentEl : '.banner',
        closeElsClass : '.js_svy_close',
		opt:'.js_ko_opt'
    },

    /**
     * @constructor
     * @param {String|Element}
            *            triggerEl - id or element that will be a trigger to display
     *            the popup
     * @param {String|Element}
            *            targetEl - id or element that will be the popup
     * @param {Object}
            *            options - configuration options (see `options` and
     *            `CHKCustomPopUp.options`)
     */
    initialize : function( targetEl, options) {
        targetEl = $(targetEl);
		this.formEl = $$('.js_svy_form')[0];
		var svy_form=this.formEl;
		var isKorea=false;
		this.surveyLayerEl =$$('.js_svy_layer')[0];
		this.thanksLayerEl = $$('.js_thanks_layer')[0];
			
		if (!targetEl) {
            return;
        }

        this.setOptions(options || {});
        this.parent(targetEl, targetEl, this.options.popupOptions);
		this.initKoreanOpts();
		form_submit=true;
		this.hide(false);
   },
	
	  initCloseButtons : function() {
        var closeEls = this.targetEl.getElements(this.options.closeElsClass);
        closeEls.setProperty('tabindex', this.options.tabIndex );
        closeEls.addEvent('click', function(event) {
            event.stop();
            this.hide();
        }.bind(this));
    },

	validateForm:function(){
		var inputs=this.formEl.getElements('.js_svy_input');
		var svy_form=this.formEl;
		var survey=this.surveyLayerEl;
		var thanks=this.thanksLayerEl;
		var nameEl=inputs[0].get('value');
        var emailToEl = inputs[1].get('value');
     
		var checkConditions = svy_form.getElement('input[name=Accept]');
		var validationErrors=$$('.srv_wdg .hidden .js_svy_err_msg');
		var nameEmptyError = validationErrors[0].get('text');
		var emailEmptyError = validationErrors[1].get('text');
		var emailInvalidError = validationErrors[2].get('text');
		var acceptCondError = validationErrors[3].get('text');

		//var acceptConditions = !checkConditions.get('disabled');
			var checkCond=isKorea && checkConditions.checked;
			var form_errors = 0;
			
			if(checkCond || !isKorea){
							
				if(nameEl == "" || nameEl == null || nameEl.length == 0 || ((nameEl.search(blank_spaces))> -1 )){
					alert(nameEmptyError);
					form_submit=false;
					form_errors = 1;
				}
				
				if(emailToEl == "" || emailToEl == null || emailToEl.length == 0 || ((emailToEl.search(blank_spaces))> -1 )){
					alert(emailEmptyError);
					form_submit=false;
					form_errors = 1;
				}
				else if(!emailToEl.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)) {
						alert(emailInvalidError);
						form_submit=false;
						form_errors = 1;
					}
			
				if (form_errors == 0){
				form_submit=true;
				}
			}
			else if(isKorea && !checkConditions.checked){
					alert(acceptCondError);
					form_submit=false;
					form_errors = 1;
			}
			else if (form_errors == 0){
				
				form_submit=true;
			}
	},
	
		/**
	 *@method initKoreanOpts
	 *@description detect if it's Korean page to display extra items
	**/
	initKoreanOpts:function(){
	var korOpts=this.targetEl.getElements(this.options.opt);
	var indexi=-1;
	 document.getElements('meta').each(function(meta, index){
	  if(meta.content=="kr"){
			indexi=index;	
		}
		if(indexi !=-1){
		isKorea=true;
			korOpts.setStyle('display', 'block');
		}
		else{
		korOpts.setStyle('display', 'none');
			isKorea=false;
		}
	  	
	 });

	},
	
     bindEvents : function() {
	
	this.surveyLayerEl.addEvent('onshow', this.thanksLayerEl.hide()); 
   
        this.targetEl.addEvent('keydown', function(event) {
            if (event.key == 'esc') {
                this.hide();
            }
        }.bind(this));

        this.addEvent('onshow', this.onPopupShow.bind(this));

      this.addEvent('onhide', function() {
           /** (function() {
                this.triggerEl.focus();
            }).delay(100, this);**/

            this.darkenEl.dispose();
        }.bind(this));
		
		 $$('.js_submit').addEvent('click', function(event) {
      
			this.validateForm();
            if(form_submit==false){
				event && event.stop();
			}
			else{
				this.surveyLayerEl.hide();
				this.thanksLayerEl.show();
				var uno=$$('.js_thanks_layer .js_svy_close')[0];	
				
			try{if ($defined($$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('fullName')].get('value'))){var fullName = $$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('fullName')].get('value') ;}else{ var fullName = ' ';}} catch(err) {}
			try{if ($defined($$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('email')].get('value'))){var email = $$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('email')].get('value');}else{ var email = ' ';}} catch(err) {}
			try{if ($defined($$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('caseId')].get('value'))){var caseId = $$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('caseId')].get('value') ;}else{var caseId = ' ';}} catch(err) {}
			try{if ($defined($$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('site')].get('value'))){var site = $$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('site')].get('value');}else{ var site= ' ';}} catch(err) {}
			try{if ($defined($$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('currentPage')].get('value'))){var currentPage = $$('.js_svy_input')[$$('.js_svy_input').get('name').indexOf('currentPage')].get('value');}else{var currentPage = ' ';}} catch(err) {}
				 
				 
				 var pathName = window.location.pathname.split('/');
				 var handler_url = 'http://'+window.location.hostname+'/'+pathName[1]+'/'+pathName[2]+'/system/include/suppport-topics-submit-survey-handler.jsp';
																								
			var req = new Request.HTML({
            method: 'post',
            url: handler_url,
			data:'caseId='+caseId+'&'+
			'site='+site+'&'+
			'currentPage='+currentPage+'&'+
			'fullName=' + fullName+'&'+
			'email='+email,
			update:'harris_thank_you',
			onFailure: function() { 
			$('js_survey_target').hide();
            },

            onException: function() {
			$('js_survey_target').hide();
				
            },
			onRequest:function(){
			$('js_survey_target').hide();
			  
			},

            onSuccess: function() {	
			$('js_survey_target').show();
            },
			
			onComplete: function() {	
				$$('.js_svy_close')[1].cloneEvents($$('.js_svy_close')[2]);
					
				
            }
        });
		req.send();	
				//this.formEl.submit();
				(function() {
						//$$('.js_thanks_layer .js_svy_close')[0].focus();
					}).delay(100);
			}
        }.bind(this));
		
		if(typeof this.surveyLayerEl.getElement('input[name=Accept]')!='undefined' && this.surveyLayerEl.getElement('input[name=Accept]')!=null){
			this.surveyLayerEl.getElement('input[name=Accept]').addEvent('keydown', function(e){
				if(e.key=="enter"){
					this.checked = !this.checked;
				}
			});
		}
		
		
    },

    onPopupShow : function() {
        var bodyEl = $(document.body);
        var parentEl = document.getElement(this.options.parentEl);
        var bannerElCoordinates = parentEl.getCoordinates();
        var targetElCoordinates = this.targetEl.getCoordinates();

        // Center target left in the banner area
        this.targetEl.setStyle('top', bannerElCoordinates.top + 25);
        this.targetEl.setStyle('left', bannerElCoordinates.left
                + (bannerElCoordinates.width - targetElCoordinates.width) / 2);

        this.darkenEl.setStyle('height', bodyEl.getScrollSize().y);
        this.darkenEl.inject(bodyEl);

    }

});

/**
 * @class CountryLanguageWidget
 * @description initialize country language selector functionality
 */
var CountryLanguageWidget = new Class({

    Extends : UnderLayedPopup,

    options : {
        rotateOptions : {
            targetEl : '.js_lng_text',
            rotateEl : '.js_lng_text span',
            flagEl : '.js_lng_flag',
            period : 2000,
            flagClassRe : /flg_\w{2,3}/,
            randomOrder : false,
            overlapTxt:true
        },
        parentEl : '.banner',
        closeElsClass : '.js_lng_close'
    },

    /**
     * @constructor
     * @param {String|Element}
            *            triggerEl - id or element that will be a trigger to display
     *            the popup
     * @param {String|Element}
            *            targetEl - id or element that will be the popup
     * @param {Object}
            *            options - configuration options (see `options` and
     *            `CHKCustomPopUp.options`)
     */
    initialize : function(triggerEl, targetEl, options) {
        triggerEl = $(triggerEl);
        targetEl = $(targetEl);

        if (!triggerEl || !targetEl) {
            return;
        }

        this.setOptions(options || {});
        this.parent(triggerEl, targetEl, this.options.popupOptions);
        this.options.tabIndex = this.triggerEl.getProperty('tabIndex');
        this.initAccordion();
        this.initTabIndexes();
        if (this.options.rotateOptions.overlapTxt && this.options.rotateOptions.rotateEl) {
            this.triggerEl.getElements(this.options.rotateOptions.rotateEl).each(function(el, index) {
                if (index > 0) {
                    el.set('opacity', 0);
                }
                el.addClass('abs');
                el.addClass('lng_swh');
            });
        }


        if (this.options.rotateOptions) {
            this.initRotation();
        }
    },

    /**
     * @method initAccordion
     * @description initialize accordion control for regions selection
     */
    initAccordion : function() {
        var duration = 200;

       /*
        language-selector opened class implimentation
       */
        var dt_elements = this.targetEl.getElements('dt');
        var dd_elements = this.targetEl.getElements('dd');
        var opened_position = -1;
        for(var i=0; i<dt_elements.length; i++){
            if(dt_elements[i].get('class').match(/opened/i) ||
               dd_elements[i].get('class').match(/opened/i)){
                    opened_position = i;
                    break;
                }
        }


        this.accordion = new Accordion(this.targetEl, dt_elements, dd_elements, {
            opacity : false,
            display : opened_position,
            duration : duration,
            alwaysHide : true,
            onActive : function(toggler, element) {
                toggler.addClass('opened');
                element.addClass('opened');
                element.setStyle('display', 'block');
            },
            onBackground : function(toggler, element) {
                toggler.removeClass('opened');
                element.removeClass('opened');
                element.setStyle.delay(duration, element, [ 'display', 'none' ]);
            }
        });
    },

    /**
     * @method initTabIndexes
     * @description setup tab-indexes for country links and focus event that
     *              opens parent accordion element if link is focused
     */
    initTabIndexes : function() {
        this.accordion.togglers.each(function(toggler, index) {
            var element = this.accordion.elements[index];
            var links = element.getElements('a');

            links.setProperty('tabindex', this.options.tabIndex);
            //toggler.setProperty('tabindex', this.options.tabIndex);
            toggler.addEvent('keydown', function(event) {
                if (event.key == 'enter') {
                    this.accordion.display(index);
                }

                if (event.key == 'tab') {
                    if (index == 0 && event.shift)this.hide();
                    if (index == this.accordion.togglers.length - 1 && !event.shift) this.hide();
                }
            }.bind(this));
        }, this);
    },

    /**
     * @method initRotation
     * @description initialize label rotation functionality
     */
    initRotation : function() {
        var rotateOptions = this.options.rotateOptions;
        var languageLinks = this.triggerEl.getElements(rotateOptions.rotateEl);
        var overlapFlag = this.options.rotateOptions.overlapTxt;

        var current = overlapFlag ? 0 : 1, element;
        if (languageLinks.length > 1) (function() {
            if (rotateOptions.randomOrder) {
                element = languageLinks.getRandom();
            } else {
                element = languageLinks[current];
                if (current >= languageLinks.length)
                    current = 0;
            }
            if (overlapFlag) {
                this.overlapTriggerText(languageLinks, current);
            }
            else {
                this.applyTriggerText(element.get('html'), element.get('rel'));
            }
            current++;
        }).periodical(rotateOptions.period, this);
    },

    applyTriggerText: function(innerHtml, flagName) {
        var rotateOptions = this.options.rotateOptions;
        var textEl = this.triggerEl.getElement(rotateOptions.targetEl);
        var flagEl = this.triggerEl.getElement(rotateOptions.flagEl);
        var flagMatch = flagName.match(rotateOptions.flagClassRe);

        if (flagEl && flagMatch) {
            this.fadeElIn(flagEl, function() {
                flagEl.className = flagEl.className.replace(rotateOptions.flagClassRe, flagMatch[0]);
            });
        }

        this.fadeElIn(textEl, function() {
            textEl.set('html', innerHtml);
        });
    },
    overlapTriggerText:function(elements, index) {
        elements[index].fade('out');
        elements[index = index < elements.length - 1 ? index + 1 : 0].fade('in');


    },

    fadeElIn: function(element, fn) {
        var tween = element.get('tween', { property: 'opacity', duration: 200 });
        tween.start(0).chain(function() {
            fn(element);
            tween.start(1);
        });
    },
    fadeElOut: function(element, fn) {
        var tween = element.get('tween', { property: 'opacity', duration: 200 });
        tween.start(1).chain(function() {
            fn(element);
            tween.start(0);
        });
    },

    /**
     * @method bindEvents
     * @description setup show/hide events to control darken layer, its height
     *              and also opens proper accordion element
     */
    bindEvents : function() {
        this.targetEl.addEvent('keydown', function(event) {
            if (event.key == 'esc') {
                this.hide();
            }
        }.bind(this));

        this.addEvent('onshow', this.onPopupShow.bind(this));

        this.addEvent('onhide', function() {
            (function() {
                this.triggerEl.focus();
            }).delay(100, this);

            this.darkenEl.dispose();
        }.bind(this));
    },

    onPopupShow : function() {
        var bodyEl = $(document.body);
        var parentEl = document.getElement(this.options.parentEl);
        var bannerElCoordinates = parentEl.getCoordinates();
        var targetElCoordinates = this.targetEl.getCoordinates();

        // Center target left in the banner area
        this.targetEl.setStyle('top', bannerElCoordinates.top + 25);
        this.targetEl.setStyle('left', bannerElCoordinates.left
                + (bannerElCoordinates.width - targetElCoordinates.width) / 2);

        this.darkenEl.setStyle('height', bodyEl.getScrollSize().y);
        this.darkenEl.inject(bodyEl);

        var index = this.accordion.previous > -1 ? this.accordion.previous : 0;
        if (!this.accordion.elements[index].getHeight())
            this.accordion.display(index);
		this.accordion.togglers[0].getElement('a').focus();
    }

});

var ProgressiveDisclosurePopup = new Class({

    Extends: CHKCustomPopUp,

    children: [],

    initialize: function (trigger, target, options) {
        this.parent(trigger, target, options);

        var ss = target.getComputedSize();
        this.options.fxOpenStyle["padding-top"] = [0, ss['padding-top']];
        this.options.fxOpenStyle["padding-bottom"] = [0, ss['padding-bottom']];

        this.addEvents({
            onshow : this._showScreenReaderHandler.bind(this),
            onhide : this._hideScreenReaderHandler.bind(this)
        });

        if (trigger) {
	        if (trigger.hasClass("js-state-open")) {
	            this.show();
	        }
	        if (trigger.hasClass("js-state-closed")) {
				target.setStyles({'padding-top':'0','padding-bottom':'0'});
	            this.hide();
	        }
        }
    },

    _showScreenReaderHandler: function () {
        updateScreenReading(this.triggerEl, '.js_expandContent');
    },

    _hideScreenReaderHandler: function () {
        updateScreenReading(this.triggerEl, '.js_collapseContent');
    },

    _popupHeight: function () {
        this.targetEl.setStyles({display:"block"}); //NOTE: need for screen reader
        var ss = this.targetEl.getComputedSize();
        var res = this.targetEl.getScrollHeight() - ss['padding-top'] - ss['padding-bottom'];
        return res <= 0 ? 0 : res;
    },

    _correctHeight: function () {
        var height = this._popupHeight();

        this.options.fxOpenStyle.height = [0, height];
        this.options.fxCloseStyle.height = [height, 0];
    },

    expandAll: function (stopEventFiring) {
        var childrenHeight = 0;
        this.children.each(function (pp) {
            childrenHeight += pp.expandAll(stopEventFiring);
        });

        var height = childrenHeight + this._popupHeight();
        this.options.fxOpenStyle.height = [0, height];
        this.show(stopEventFiring);
        this._showScreenReaderHandler();

        return height;
    },

    collapseAll: function (stopEventFiring) {
        this.options.fxCloseStyle.height = [this._popupHeight(), 0];
        this.hide(stopEventFiring);
        this._hideScreenReaderHandler();

        this.children.each(function (pp) {
            pp.collapseAll(stopEventFiring);
        });
    }

});

/**
 * @class ProgressiveDisclosure
 * @description Nested list items items disclosure functionality
 */
var ProgressiveDisclosure = new Class({

    Implements : Options,

    options : {
        // For compatibility with previous implementation
        expandedClass : 'icn_pls_drk',
        collapsedClass : 'icn_mns_drk',

        /**
         * This parameter is workaroud for jumping in FireFox (3.16).
         * During changing the  height parameter of Items (during onening/closing) FireFox try to resize
         * the whole page and this operation takes a time. So we see ragged (not smooth) transition because
         * of after each changing of height we should wait while FF recalculates new height.
         *
         * Workaround:
         * 1) before our transition we fix 'heightContainer' size
         * 2) after transition we stop fixing size and you see window resizing
         * for details look usage of this parameter
         *
         * Please remove it and all connected code when hp stop supporting FireFox 3.x (in FireFox 4.0 bug wasn't reproduced)
         * */
        heightContainer: null,

        triggerElSelector : '.js_prg_dsc_trg',
        targetElSelector : '.js_prg_dsc_cnt',
        nestedElSelector : '.js_prg_dsc',
        expandAllElsDisabledClass: 'disabled',
        collapseAllElsDisabledClass: 'disabled',
        popupOptions : {
            showEvent : 'click',
            hideEvent : '',
            showTriggerClass : 'opened',
            hideTriggerClass : '',
            showTargetClass : 'opened',
            hideTargetClass : '',
            useFx : true,
            enableTriggerToggle : true,
            enableKeypress : false,

            /* Open */
            fxOpenStylePre : {
                height : 0,
                'padding-top':0,
                'padding-bottom':0,
                overflow : 'hidden',
                display:'block'
            },
            fxOpenStyle : {
                height : null
            },
            fxOpenStylePost : {
                height : 'auto',
                'padding-top':null,
                'padding-bottom':null
            },

            /* Close */
            fxCloseStylePre : {
                overflow : 'hidden'
            },
            fxCloseStyle : {
                height : 0,
                'padding-top':0,
                'padding-bottom':0
            },
            fxCloseStylePost : {
                display:'none'         //NOTE: need for screen readers
            },
            fxTransition : Fx.Transitions.Sine.easeInOut
        }
    },

    /**
     * @constructor
     * @param {String|Element}
     *            rootEl - id or element to apply functionality
     * @param {Element|Elements}
     *            expandAllEls - element or elements collection that
     *            should expand all nested items
     * @param {Object}
     *            options - configuration options - {Object}
     *            popupOptions - options for CHKCustomPopUp
     */
    initialize : function(rootEl, options) {
        this.setOptions(options);

        this.children = [];
        this.options.expandAllEls = $$(this.options.expandAllEls);
        this.options.collapseAllEls = $$(this.options.collapseAllEls);

        var root = $(rootEl);
        this.attach(root, this.children);

        this.bindTogglers();

        if (this.options.heightContainer) {
            var col = $(this.options.heightContainer);
            this.children.each(function (popup) {
                popup.addEvents({
                    "onTransitionStart": function (e) {
                        var size = col.getComputedSize();
                        if (!popup.isOpen) {
                            col.setStyle("height", size.height)
                        }
                    },

                    "onTransitionComplete": function (e) {
                        if (!popup.isOpen) {
                            col.setStyle("height", "auto");
                        }
                    }
                });
            });

            col.setStyle("height", "auto");
        }
    },

     /**
     * @method attach
     * @param {Element}
     *            element - list element to attach expanding
     *            functionality
     * @description general method that applies functionality to the
     *              list (either it's root or nested list), it also
     *              collects all tabs to be able to control
     *              expand/collapse state. Method is called recursively
     *              to initialize nested lists
     */
    attach : function(element, children) {
        var popupTargetEls = element.getChildren(this.options.targetElSelector);

        popupTargetEls.each(function(targetEl) {
        	var el = targetEl.getPrevious('dt');
        	var triggerEl;
        	if (el) {
        		triggerEl = el.getElement(this.options.triggerElSelector);
        	}

        	var popup = {};
        	if (triggerEl && this.options.popupOptions.showEvent) {
        		triggerEl.addEvent(this.options.popupOptions.showEvent, function () {popup._correctHeight()});
            }
            popup = new ProgressiveDisclosurePopup(triggerEl, targetEl, this.options.popupOptions);

            popup.addEvents({
                onhide: this.checkExpandAllEl.bind(this),
                onshow: this.checkExpandAllEl.bind(this)
            });

            children.push(popup);

            var nestedLevelEl = targetEl.getFirst(this.options.nestedElSelector);
            if (nestedLevelEl) {
                this.attach(nestedLevelEl, popup.children);
            }
        }, this);
    },

    bindTogglers : function() {
        var options = this.options;

        if (options.expandAllEls.length && options.collapseAllEls.length) {
            options.expandAllEls.addEvent('click', function(event) {
                event.stop();
                this.toggleAll(true);
            }.bind(this));

            options.collapseAllEls.addEvent('click', function(event) {
                event.stop();
                this.toggleAll(false);
            }.bind(this));
        } else if (options.expandAllEls.length) {
            this.options.collapsedText = options.expandAllEls[0].get('rel');
            this.options.expandedText = options.expandAllEls[0].get('html');

            options.expandAllEls.addEvent('click', function(event) {
                event.stop();
                this.toggleAll(!this.isAllExpanded());
            }.bind(this));
        }

    },

    /**
     * @method toggleAll
     * @param {Boolean}
     *            show - if true will expand, otherwise - collapse all
     *            items
     * @param {Boolean}
     *            force - if true fire show/hide even if tab is already
     *            shown/hidden
     * @description Expand or collapse all items
     */
    toggleAll : function(show, force) {
        this.children.each(function(popup) {
            if (show) {
                if (!popup.isOpen || force) {
                    popup.expandAll(true);
                }
            } else {
                if (popup.isOpen || force) {
                    popup.collapseAll(true);
                }
            }
        });

        this.checkExpandAllEl();
    },

    /**
     * @method checkExpandAllEl
     * @description Change expandAll elements text and class depending
     *              on state
     */
    checkExpandAllEl : function() {
        var options = this.options;

        if (options.expandAllEls.length && options.collapseAllEls.length) {
            options.expandAllEls[this.isAllExpanded() ? 'addClass' : 'removeClass'](options.expandAllElsDisabledClass);
            options.collapseAllEls[this.isAllCollapsed() ? 'addClass' : 'removeClass'](options.collapseAllElsDisabledClass);
        } else if (options.expandAllEls.length) {
            if (this.isAllExpanded()) {
                options.expandAllEls.set('html', options.collapsedText);
                options.expandAllEls.addClass(options.collapsedClass);
                options.expandAllEls.removeClass(options.expandedClass);
            } else {
                options.expandAllEls.set('html', options.expandedText);
                options.expandAllEls.removeClass(options.collapsedClass);
                options.expandAllEls.addClass(options.expandedClass);
            }
        }
    },

    isAllExpanded: function() {
        return this.children.every(function(tab) {
            return tab.isOpen;
        });
    },

    isAllCollapsed: function() {
        return this.children.every(function(tab) {
            return !tab.isOpen;
        });
    }
});

/**
 * @class InputLabel
 * @description Used to add default label to the input that will disappear on
 *              input focus
 */
var InputLabel = new Class({

    Implements : Options,

    options : {
        labeledCssClass : 'inp_lbl',
        defValueAttribute : 'value'
    },

    /**
     * @constructor
     * @param {String|Elements}
            *            elements - css selector or elements collection to apply labels
     * @param {Object}
            *            options - configuration options - {String} labeledCssClass - a
     *            css class to be applied when element has default value -
     *            {String} defValueAttribute - an attribute name that holds
     *            default label value
     */
    initialize : function(elements, options) {
        this.setOptions(options);

        $$(elements).each(function(element) {
            this.attach(element);
        }, this);
    },

    /**
     * @method attach
     * @param {Element}
            *            element
     * @description Add blur/focus events to handle default input label
     */
    attach : function(element) {
        var label = element.getAttribute(this.options.defValueAttribute);
        var labeledClass = this.options.labeledCssClass;

        if (label && label.length) {
            var onFocus = function() {
                if (element.get('value') == label) {
                    element.set('value', '');
                }
                element.removeClass(labeledClass);
            };

            var onBlur = function() {
                var value = element.get('value');

                if (value == '' || value == label) {
                    element.set('value', label);
                    element.addClass(labeledClass);
                }
            };

            element.addEvent('focus', onFocus);
            element.addEvent('blur', onBlur);
            onBlur();
        }
    }
});

/**
 * @class ShareWidget
 * @description Adds functionality for sharing page with social networks or email
 */
var ShareWidget = new Class({

    Implements : [ Options, Events ],

    options : {
        shareUrl : document.location.href,
        shareTitle : document.title,
        popupOffset : {
            x : 0,
            y : 0
        }
    },

    /**
     * @constructor
     * @param {String|Element}
            *            trigger
     * @param {String|Element}
            *            wrapper - id or element that contains widget popups
     *            elements
     * @param {Object}
            *            options - configuration options - {String} shareUrl -
     *            url to share, by default - window.location - {String}
     *            shareTitle - title to share, by default - page's title
     */
    initialize : function(trigger, wrapper, options) {
        this.wrapperEl = $(wrapper);
        this.triggerEl = $(trigger);
        this.containerEl = this.wrapperEl.getElement('.js_shr_wdg_windows');
        this.mainPopupEl = this.containerEl.getElement('.js_shr_wdg_main');
        this.emailPopupEl = this.containerEl.getElement('.js_shr_wdg_email');
        this.containerEl.setStyle('display', 'block');

        this.setOptions(options || {});
        this.options.tabIndex = this.options.tabIndex || this.triggerEl.get('tabindex') || 10;

        //NOTE:Menus must appear directly after the link that activates them in the source code. Screen readers and other assistive technology will render content to the user in the order it appears in the HTML source code and not the order in which it appears visually on the screen.
        this.containerEl.inject(document.body);

        this.applyPositioning();
        this.buildMainPopup(this.triggerEl, this.mainPopupEl);
        this.bindSocialLinks();
        this.setTabIndexes();
    },

    /**
     * @method buildMainPopup
     * @param {Element}
            *            trigger - popup trigger
     * @param {Element}
            *            element - displayed popup content
     * @description build main popup functionality that displays links
     *              for social networks
     */
    buildMainPopup : function(trigger, element) {
        this.mainPopup = new CHKCustomPopUp(trigger, element, {
            showEvent : 'click',
            hideEvent : 'mouseleave',
            showDelay : null,
            hideDelay : 300,
            enableTriggerToggle: true,
            enableKeypress: false
        });

        this.mainPopup.addEvent('onshow', function() {
            this.applyPositioning();
            this.mainPopupEl.getElement('.js_shr_wdg_scl a').focus();
        }.bind(this));

        this.mainPopup.addEvent('onhide', function() {
            (function() {
                this.mainPopup.triggerEl.focus();
            }).delay(100, this);
        }.bind(this));

        // A kind of hack to allow mouseleave close event handling
        this.mainPopup.targetEl.addEvent('mouseenter', function() {
            $clear(this.mainPopup.timer);
        }.bind(this));

        this.mainPopup.targetEl.setStyle('position', 'absolute');
        this.mainPopup.hide(true);
    },

    /**
     * @method buildEmailPopup
     * @param {Element}
            *            trigger - popup trigger
     * @param {Element}
            *            element - displayed popup content
     * @description build email popup functionality that displays email
     *              sharing. Also attaching show/hide events logic
     */
    buildEmailPopup : function(trigger, element) {
        this.emailPopup = new CHKCustomPopUp(trigger, element, {
            showDelay : null,
            preventDefault : false,
            hideDelay : 300,
            showEvent : 'click',
            hideEvent : []
        });

        this.emailPopup.targetEl.setStyle('position', 'absolute');

        this.formEl = this.emailPopup.targetEl.getElement('.js_shr_wdg_form');
        if (!this.formEl) throw new Error('Share widget does not have `form.js_shr_wdg_form`');

        // Add default values to input fields, that disappear on focus
        new InputLabel(this.formEl.getElements('.inp_txt'));

        this.formEl.getElement('input[name=copy]').addEvent('click', this.onSendCopyClick.bind(this));

        this.emailPopup.addEvent('onshow', function() {
            this.applyPositioning();
            this.mainPopup.hide();
        }.bind(this));

        this.mainPopup.addEvent('onshow', function() {
            if (this.emailPopup.isOpen) {
                this.mainPopup.hide();
            }
        }.bind(this));

        this.emailPopup.targetEl.getElements('.js_shr_wdg_close').addEvent('click', function(event) {
            event.stop();
            this.emailPopup.hide();
            this.mainPopup.show();
            //this.mainPopup.hideDelay(1500);
        }.bind(this));

        this.emailPopup.targetEl.getElements('.js_cty_sel_tr')
                .addEvent('click', function() {
            this.formEl.fireEvent('submit');
        }.bind(this));
		
		 this.emailPopup.targetEl.getElements('.js_shr_chk_copy')
        .addEvent('keypress', function(event) {
            if(event.key == "enter"){
                var element = this.emailPopup.targetEl.getElement('.js_shr_chk_copy');
                element.checked = !element.checked;
            }
        }.bind(this));

        this.formEl.addEvent('submit', function(event) {
            event && event.stop();
            this.onEmailFormSubmit();
        }.bind(this));

        this.emailPopup.hide();
    },

    /**
     * @method bindSocialLinks
     * @description attach events to the social networks links (open
     *              third-party popup with sharing functionality)
     */
    bindSocialLinks : function() {
        this.mainPopupEl.getElements('.js_shr_wdg_scl a').each(function(link, index, arr) {
            var rel = link.get('rel');
            link.setProperty('tabindex', this.options.tabIndex + 1);

            if (rel == 'email') {
                this.buildEmailPopup(link, this.emailPopupEl);
            } else {
                this.bindSocialLink(link, rel);
            }

            if (index == 0) {
                link.addEvent('keypress', function(event) {
                    if (event.key == 'tab' && event.shift) this.mainPopup.hide();
                }.bind(this));
            }

            if (index == arr.length - 1) {
                link.addEvent('keypress', function(event) {
                    if (event.key == 'tab' && !event.shift) this.mainPopup.hide();
					(function() {this.emailPopup.targetEl.getElement('.js_shr_wdg_form').getElement('input[name=email_to]').focus();}).delay(200, this)	
                }.bind(this));
            }
        }, this);
    },

    /**
     * @method bindSocialLink
     * @description attach events social link by its type. If type is
     *              unknown (see types object) will throw error TODO:
     *              Seems like it will be better to be able to add more
     *              social networks types from outside - need to make it
     *              as a public property
     */
    bindSocialLink : (function() {

        var applyLink = function(link, linkHref, trackName) {
            link.setProperty('href', linkHref);
            link.addEvent('click', function(event) {
                event.stop();
                window.open(linkHref, 'socialNetwork',
                        'height=400,width=760');
                try {
                    trackMetrics('socialInteraction', {
                        type : 'link',
                        id : 'social:' + trackName + ':' + gup('URI')
                    });
                } catch (e) {
                }
            });
        };

        var gup = function(name) {
            name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
            var regExp = new RegExp('[\\?&]' + name + '=([^&#]*)');
            var results = regExp.exec(window.location.href);
            return results ? results[1] : '';
        };

        var types = {
            facebook : function(link, url, title) {
                applyLink(link, 'http://www.facebook.com/sharer.php?u='
                        + url + '&amp;t=' + title, 'facebook');
            },

            twitter : function(link, url, title) {
                /*  applyLink(link, 'http://twitter.com/home?status='
                        + title + ': ' + url, 'twitter');  */
                applyLink(link, 'http://twitter.com/share?url='
                         + url, 'twitter');
            },

            digg : function(link, url, title) {
                applyLink(link,
                        'http://digg.com/submit?phase=2&amp;url=' + url
                                + '&amp;title=' + title, 'digg');
            },

            myspace : function(link, url, title) {
                applyLink(link,
                        'http://www.myspace.com/Modules/PostTo/Pages/?t='
                                +  encodeURIComponent(title) + '&amp;u=' + encodeURIComponent(url), 'myspace');
            },

            delicious : function(link, url, title) {
                applyLink(link, 'http://del.icio.us/post?url=' + url
                        + '&amp;title=' + title, 'delicious');
            },

            linkedin : function(link, url, title) {
                applyLink(link,
                        'http://www.linkedin.com/shareArticle?mini=true&amp;url='
                                + url + '&amp;title=' + title,
                        'linkedin');
            }
        };

        return function(link, type) {
            if (types[type]) {
                types[type](link, this.options.shareUrl,
                        this.options.shareTitle)
            } else {
                throw new Error('Unable to attach social link for: '
                        + type);
            }
        }
    })(),

    setTabIndexes: function() {
        if (!$defined(this.emailPopup)) {
            this.mainPopup.targetEl.getElements('a, input, textarea').each(function(element) {
                element.set('tabindex', this.options.tabIndex);
            }, this);
            return;
        }

        [
            this.mainPopup.targetEl.getElements('a, input, textarea'),
            this.emailPopup.targetEl.getElements('a, input, textarea')
        ].flatten().each(function(element) {
            element.set('tabindex', this.options.tabIndex);
        }, this);
    },

    /**
     * @method applyPositioning
     * @description position all popups container to the trigger
     */
    applyPositioning: function() {
        var position = this.triggerEl.getCoordinates();
        var dir = document.getElement('html').get('dir');
        var width = 250;
        var styles = {
            width: width,
            position: 'absolute',
            top: position.top + this.options.popupOffset.y
        };

        if (dir && dir == 'rtl') {
            styles.left = position.left + this.options.popupOffset.x - width;
        } else {
            styles.left = position.right + this.options.popupOffset.x;
        }


        this.containerEl.setStyles(styles);
    },

    /**
     * @method onEmailFormSubmit
     * @description submit event handler. Validates input fields and
     *              open email client
     */
    onEmailFormSubmit : function() {
        var validationErrors = [];
        var checkEmail = function(field, error) {
            var email = field.get('value').toString();
            if (!email
                    .match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)) {
                validationErrors.push(error);
            }
        };

        var emailToEl = this.formEl.getElement('input[name=email_to]');
        var emailFromEl = this.formEl.getElement('input[name=email_from]');
        var nameFromEl = this.formEl.getElement('input[name=name_from]');
        var messageEl = this.formEl.getElement('textarea[name=message]');
        var needCopyToSender = !emailFromEl.get('disabled');

        var senderErrorEl = this.formEl.getElement('.js_error_sender');
        var recipientErrorEl = this.formEl.getElement('.js_error_recipient');

        var senderErrorText = senderErrorEl ? senderErrorEl.get('text') : 'Sender email has invalid format';
        var recipientErrorText = recipientErrorEl ? recipientErrorEl.get('text') : 'Recipient email has invalid format';

        checkEmail(emailToEl, recipientErrorText);
        if (needCopyToSender) {
            checkEmail(emailFromEl, senderErrorText);
        }

        if (validationErrors.length) {
            alert(validationErrors.join('\n'))
        } else {
            var recommendation = 'Title: ' + this.options.shareTitle
                    + '%0D%0A' + 'Link to Article: '
                    + encodeURIComponent(this.options.shareUrl)
                    + '%0D%0A';
            var template = 'mailto:{emailTo}?subject={nameFrom} from {title}&body={message}%0D%0A%0D%0A{recommendation}%0D%0ALink to {title}: {encUrl}%0D%0A%0D%0A{nameFrom}';

            if (needCopyToSender) {
                template += '&cc={emailFrom}';
            }

            window.location = template.substitute({
                emailTo : emailToEl.get('value'),
                emailFrom : emailFromEl.get('value'),
                nameFrom : nameFromEl.get('value'),
                message : messageEl.get('value'),
                encUrl : encodeURIComponent(this.options.shareUrl),
                title : this.options.shareTitle,
                recommendation : recommendation
            });
        }
    },

    /**
     * @method onSendCopyClick
     * @description click event handler. Disable or enable sender copy
     *              input field
     */
    onSendCopyClick : function() {
        var checkbox = this.formEl.getElement('input[name=copy]');
        var field = this.formEl.getElement('input[name=email_from]');

        if (checkbox.get('checked')) {
            field.set('disabled', false);
            field.removeClass('inp_txt_dsbl');
        } else {
            field.set('disabled', true);
            field.addClass('inp_txt_dsbl');
        }
    }

});

var DropDowns = new Class({
    initialize : function(triggerClass, targetClass, closeClass, hideElements) {
        if (!triggerClass || !targetClass || !closeClass) {
            return;
        }

        var triggers = $$(triggerClass);
        var targets = $$(targetClass);
        var popups = [];

        triggers.each(function(trigger, index) {

            var target = targets[index];
            var links = target.getElements('a');
            var popup = new CHKCustomPopUp(trigger, target, {
                showEvent : ['click'],
                hideEvent : []
            });

            popup.addHideElement(target.getElements(closeClass), 'click');

            popup.addEvent('onshow', function() {
                popups.each(function(p) {
                    if (p.targetEl != popup.targetEl && p.isOpen) p.hide();
                });
				if($defined(links[0])){
                links[0].focus();
				}
            });

            if($defined(links[0])){
            links[0].addEvent('keypress', function(event) {
                if (event.key == 'tab' && event.shift) {
                    popup.hide();
                    popup.triggerEl.focus();
                }
            });
			

            links.getLast().addEvent('keypress', function(event) {
                if (event.key == 'tab' && !event.shift) {
                    popup.hide();
                    popup.triggerEl.focus();
                }
            });

			}

            links.each(function(l){
                l.addEvent('click', function(event){
                    var drp_tgt = l.getParent('.js_dropdwn_target');
                    if(!$defined(drp_tgt)) {
                        return;
                    }
                    var drp_trigger = drp_tgt.getParent().getElements('.js_dropdwn_trigger');
                    if(!$defined(drp_trigger)){
                        return;
                    }
                    var val = drp_trigger.getElements('.js_dropdwn_trigger_label');
                    if( !$defined(val) || val.length == 0 ) {
                        return;
                    }
                    val[0].each(function(v){
                        v.innerHTML = 'sort: ' + l.innerHTML;
                    });

                });
            });

            popups.push(popup);
        });

        $$(document.body, hideElements || []).addEvent('click', function() {
            popups.each(function(p) {
                p.isOpen && p.hide();
            });
        });

    }
});

var PriceWidget = new Class({

    initialize : function(containerEl) {
        this.containerEl = $(containerEl);

        this.initBuyPopup();
        this.initSmBuyPopup();
    },

    initBuyPopup : function() {
        var triggerEls = this.containerEl.getElements('.js_acc_buy_trg');
        var targetEl = this.containerEl.getElement('.js_acc_buy_pop');
        var closeEl = this.containerEl.getElement('.js_acc_buy_pop_cls');

        this.buyPopup = new CHKCustomPopUp(null, targetEl, {
            showEvent : 'click',
            hideEvent : '',
            useFx : true,
            enableTriggerToggle : true,
            fxOpenStyle : {
                opacity : 1
            },
            fxOpenStylePre : {
                opacity : 0,
                display : 'block',
                visibility : 'visible'
            },
            fxCloseStyle : {
                opacity : 0
            },
            fxCloseStylePost : {
                opacity : 0,
                display : 'none',
                visibility : 'hidden'
            },
            fxDuration : 100,
            fxTransition : Fx.Transitions.Sine.easeInOut,
            enableKeypress : false
        });

        this.buyPopup.addEvents({
            onhide : function() {
                this.smBuyPopup && this.smBuyPopup.hide();
            }.bind(this)
        });

        triggerEls.each(function(trigger) {
            this.buyPopup.addShowElement(trigger, 'click');
        }, this);

        if (closeEl) {
            this.buyPopup.addHideElement(closeEl, 'click');
        }

        this.buyPopup.hide();
    },

    initSmBuyPopup : function() {
        var triggerEls = this.containerEl.getElements('.js_acc_smb_trg');
        var targetEl = this.containerEl.getElement('.js_acc_smb_pop');

        this.smBuyPopup = new CHKCustomPopUp(null, targetEl, {
            showEvent : 'click',
            hideEvent : '',
            useFx : true,
            enableTriggerToggle : true,
            fxOpenStyle : {
                opacity : 1
            },
            fxOpenStylePre : {
                opacity : 0,
                display : 'block',
                visibility : 'visible'
            },
            fxCloseStyle : {
                opacity : 0
            },
            fxCloseStylePost : {
                opacity : 0,
                display : 'none',
                visibility : 'hidden'
            },
            fxDuration : 100,
            fxTransition : Fx.Transitions.Sine.easeInOut,
            enableKeypress : false
        });

        triggerEls.each(function(trigger) {
            this.smBuyPopup.addShowElement(trigger, 'click');
        }, this);

        this.smBuyPopup.hide();
    }

});

var AccessoriesWidget = new Class({

    initialize : function(containerEl) {
        this.containerEl = $(containerEl);
        this.initDetailsPopup();
    },

    initDetailsPopup : function() {
        var triggerEl = this.containerEl.getElement('.js_acc_dtl_trg');
        var targetEl = this.containerEl.getElement('.js_acc_dtl_pop');
        var closeEl = this.containerEl.getElement('.js_acc_dtl_pop_cls');
        var viewDetailsText = triggerEl.get('text');
        var hideDetailsText = triggerEl.get('rel') || viewDetailsText;

        this.detailsPopup = new CHKCustomPopUp(triggerEl, targetEl, {
            showEvent : 'click',
            hideEvent : '',
            useFx : true,
            enableTriggerToggle : true,
            fxOpenStyle : {
                opacity : 1
            },
            fxOpenStylePre : {
                opacity : 0,
                display : 'block',
                visibility : 'visible'
            },
            fxCloseStyle : {
                opacity : 0
            },
            fxCloseStylePost : {
                opacity : 0,
                display : 'none',
                visibility : 'hidden'
            },
            fxDuration : 100,
            fxTransition : Fx.Transitions.Sine.easeInOut,
            enableKeypress : false
        });

        this.detailsPopup.addEvents({
            onshow : function() {
                this.detailsPopup.triggerEl.set('text', hideDetailsText);
            }.bind(this),
            onhide : function() {
                this.detailsPopup.triggerEl.set('text', viewDetailsText);
            }.bind(this)
        });

        if (closeEl) {
            this.detailsPopup.addHideElement(closeEl, 'click');
        }

        this.detailsPopup.hide();
    }
});

/*EB SecondaryNav Object*/
		var SecondaryNav= new Class({
			options:{
				targetClassL1:'.js_snav_lev1_tab_cnt',
				triggerClassL1:'.js_snav_lev1_tab',
				targetWrapper:'.js_snav_tab_wrapper',
				triggerClassL2:'.js_snav_lev2_tab',
				targetClassL2:'.js_snav_lev2_tab_cnt'
			},
			initialize:function(){
			this.initFirstLevelTabs();
			this.initSecondLevelTabs();
			
 
			},
			initFirstLevelTabs:function(){
			var tabControl = new CHKTabControl($(document.body));
			var currentTab = 1;
      		var triggerEls = $$(this.options.triggerClassL1);
        	var targetEls = $$(this.options.targetClassL1);
			var targetWrapper=$$(this.options.targetWrapper)[0];
			
			
			triggerEls.each(function(triggerEl,index){
				var openTabArea= new CHKCustomPopUp(triggerEl,targetWrapper,{
				 showEvent : '',
				 hideEvent:'',
				 useFx:true,
				fxOpenStylePre : {opacity : 0,display : 'none',height:'0px', overflow:'hidden'},
				fxOpenStyle : {opacity : 1,display : 'block',height:'300px' },  
        		fxCloseStyle : {opacity : 0,height:'0px', overflow:'hidden'},
        		fxCloseStylePost : {display : 'none'},
				fxDuration : 600,
        		fxTransition : Fx.Transitions.Sine.easeInOut

				});
				triggerEl.addEvent('click',function(){
				if(!targetWrapper.hasClass('expanded')){				
				openTabArea.show();	
				targetWrapper.addClass('expanded');	
				}
				targetEls[index].getElements('.snav_main_img').each(function(el){
					if(!el.hasClass('img_loaded')){
					el.setProperty('src',el.getProperty('title'));
					el.removeProperty('title');
					el.addClass('img_loaded');
					}
					});
				});
				
				targetWrapper.getParent().addEvent('mouseleave',function(){		
				openTabArea.hide();		
				targetWrapper.removeClass('expanded');			
				});
			});
			
			triggerEls.each(function(triggerEl, index) {
            tabControl.addTab(new CHKCustomPopUp(triggerEl, $(triggerEl.getProperty('rel')), {
                showEvent : 'click',
                hideEvent : '',
                showTriggerClass : 'current',
                hideTriggerClass : '',
				showTargetClass:'tab_opened',
				hideTargetClass:'tab_closed',
		        preventDefault : false,
				
                overrides: {
                    keypressHandler: function(event) {
                        if (event && event.key && event.key == 'enter') {
                            if (this.options.stopPropagation) event.stopPropagation();
                            if (this.options.preventDefault) event.preventDefault();
                            $clear(this.timer);
                            if (this.isOpen === false) {
                                this.show();
                            }
                        }
                    }
                }
            }));

            if (triggerEl.hasClass('current')) {
                currentTab = index;
            }
			 }.bind(this));
			 
			 tabControl.hideAllTabs();
       		 core.addView(tabControl);
			},
			initSecondLevelTabs:function(){
			var tabControl = new CHKTabControl($(document.body));
			var currentTab = 0;
      		var triggerEls = $$(this.options.triggerClassL2);
        	var targetEls = $$(this.options.targetClassL2);
			triggerEls.each(function(triggerEl, index) {
            tabControl.addTab(new CHKCustomPopUp(triggerEl, $(triggerEl.getProperty('rel')), {
                showEvent : 'click',
                hideEvent : '',
                showTriggerClass : 'current',
                hideTriggerClass : '',
		        preventDefault : false,
				
				
                overrides: {
                    keypressHandler: function(event) {
                        if (event && event.key && event.key == 'enter') {
                            if (this.options.stopPropagation) event.stopPropagation();
                            if (this.options.preventDefault) event.preventDefault();
                            $clear(this.timer);
                            if (this.isOpen === false) {
                                this.show();
                            }
                        }
                    }
                }
            }));

            if (triggerEl.hasClass('current')) {
                currentTab = index;
            }
			 }.bind(this));			 
			
       		 core.addView(tabControl);
			 tabControl.showTab(currentTab, false);
			
			}		
		});
function transparentizeIE6PNGs(imagesSelector) {
    /* FILTER FOR IE6 */
    /* transparency for non background png images */
    if (Browser.Engine.trident4) {
        $$(imagesSelector)
                .each(
                function(image) {
                    var size = image.getSize();
                    var src = image.getProperty('src');
                    var div = new Element('div');
                    div.setProperty('title', image.getProperty('alt'));
                    div.replaces(image); // image is replaced by a
                    // div with its height and
                    // width and a title instead
                    // of an alt property
                    div
                            .setStyles({
                                           filter : 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'
                                                   + src
                                                   + '"),sizingMethod="scale")',
                                           width : size.x,
                                           height : size.y
                                       });
                });
    }
}

function addBannersBackground(bannersSelector) {
    $$(bannersSelector).each(function(banner) {
        if (!banner) {
            return;
        }

        var bannerImageEl = banner.getElement('img');
        if (!bannerImageEl) {
            return;
        }

        banner.setProperty('title', bannerImageEl.getProperty('alt'));
		banner.getElements('.abs').each(function(el) {
            if (!el.hasClass('js_banner_tabs')) {
                el.removeClass('abs');
            }
        });
		var img_height= (bannerImageEl.getProperty('height'))?bannerImageEl.getProperty('height')+'px':'auto';
		var img_width=(bannerImageEl.getProperty('width'))?bannerImageEl.getProperty('width')+'px':'auto';
		
        banner.setStyles({
            background : 'url(' + bannerImageEl.getProperty('src') + ') no-repeat',
            height : img_height,
			width: img_width,
            zoom: 1,
			overflow:'hidden'
        });
		
		/*Temporary fix for EB banner issue*/
		if (banner.getElements('.js_dropdwn_trigger').length>0){
		
		banner.setStyles({overflow:'visible'});
		}

        bannerImageEl.destroy();
    });
}

/**/
function addIEButtonRoundedCorners(buttonClass, leftClass, rightClass) {
    // If IE add Rounded corners
    if (Browser.Engine.trident) {
        if (!buttonClass || !leftClass || !rightClass) {
            return;
        }

        $$('.' + buttonClass).each(function(button) {
            if ($defined(button)) {
				if(!button.hasClass("rounded")){
					button.addClass("rounded");
                	var left_corner = new Element('span', {
                    	'class' : leftClass + ' png'
                	});
                	var right_corner = new Element('span', {
                    	'class' : rightClass + ' png'
                	});
                	button.getParent().adopt(left_corner);
                	left_corner.adopt(right_corner);
                	right_corner.adopt(button);
            	}
			}
        });
    }
}

/* Constructor for Tabbed Navigation, configurable */
function initTabbedNav(tabTriggerClass, tabTargetClass) {
    tabTriggerClass = tabTriggerClass || '.js_tab_trigger';
    tabTargetClass = tabTargetClass || '.js_tab_content';

    new TabbedNavigation(tabTriggerClass, tabTargetClass);
}

/**
 * @global
 * @method initCountryLanguageWidget
 * @description create CountryLanguageWidget instance All params are optional -
 *              in case any is undefined - default value will be used
 * @param triggerEl
 *            {String|Element}
 * @param targetEl
 *            {String|Element}
 * @param options
 *            {Object}
 * @example initCountryLanguageWidget() eq. to
 *          initCountryLanguageWidget('js_lng_trigger', 'js_lng_target', {});
 *          initCountryLanguageWidget(null, 'some_id') eq. to
 *          initCountryLanguageWidget('js_lng_trigger', 'some_id', {});
 */
function initCountryLanguageWidget(triggerEl, targetEl, options) {
    return new CountryLanguageWidget(triggerEl || 'js_lng_trigger', targetEl
            || 'js_lng_target', options || {});
}

function initSurveyWidget(targetEl, options) {
    return new SurveyWidget(targetEl || 'js_survey_target', options || {});
}

/* Constructor for NavToggler object in side navigation, pre-wired */
function initNavTogglerListAccordions(pathSelector, event, toggledClass) {
    pathSelector = pathSelector || '.cat_exp li .js_toggler';
    event = event || 'click';
    toggledClass = toggledClass || 'exp';

    new NavTogglerListAccordion(pathSelector, event, toggledClass);
}

/* Constructor for Support Topics, pre-wired */
function initExpandableAreas(triggerClass, targetClass) {
    triggerClass = triggerClass || '.js_result';
    targetClass = targetClass || '.js_expander';

    $$(triggerClass).each(
            function(triggerEl) {
                new ExpandableContentArea(triggerEl, triggerEl
                        .getElement(targetClass));
            });
}

/* init function for simple column popup layout, pre-wired */
function initSimpleColPopupHover(popupTriggerClass, popupTargetClass) {
    popupTriggerClass = popupTriggerClass || '.js_col_popup_trigger';
    popupTargetClass = popupTargetClass || '.js_col_popup_target';

    $$(popupTriggerClass).each(function(trigger, index) {
        new SimpleColPopUpHover(trigger, $$(popupTargetClass)[index]);
    });
}

var PopupHoverGatewayOptions = {
    fxOpenStyle : {
        opacity : 1
    },
    fxOpenStylePre : {
        opacity : 0,
        display: 'block'
    },
    fxCloseStyle : {
        opacity : 0
    },
    fxCloseStylePost : {
        display: 'none'
    }
};

function _setCorrectSizeForPopupHoverGateway(popup, triggerPositionInRow) {
    popup.addEvent('onshow', function() {
        var table = this.triggerEl.getParent('table');
        var f_height= (table.getSize().y>this.targetEl.getScrollSize().y?table.getSize().y:this.targetEl.getScrollSize().y);
        this.targetEl.setStyles({
            'height': f_height + 'px',
            'width': table.getElements('td')[triggerPositionInRow].getSize().x + 'px',
			'top' : table.getTop()
        });
    });
}
/* init function for simple column popup layout, pre-wired */
function initSimpleColPopupHoverGateway(popupTriggerClass, popupTargetClass) {
    popupTriggerClass = popupTriggerClass || '.js_col_popup_trigger';
    popupTargetClass = popupTargetClass || '.js_col_popup_target';

    var popupTargets = $$(popupTargetClass);

    $$(popupTriggerClass).each(function(trigger, index) {
        var popupTarget = popupTargets[index];
        popupTarget.setStyle('left', trigger.getParent('td').getCoordinates(trigger.getParent('table')).left);
        var popup = new SimpleColPopUpHover(trigger, popupTarget, PopupHoverGatewayOptions);

        var triggerPositionInRow = trigger.getParent().getAllPrevious('td').length;

        var otherTriggers = getOtherTriggers(trigger, triggerPositionInRow);
        otherTriggers.each(function(otherTrigger) {
            popup.addShowElement(otherTrigger, popup.options.showEvent);
        });

        _setCorrectSizeForPopupHoverGateway(popup, triggerPositionInRow);
    });

    function getOtherTriggers(trigger, triggerPositionInRow) {
        var parentRow = trigger.getParent('tr');
        var siblingRows = parentRow.getParent().getChildren();
        var siblingsCount = siblingRows.length;
        var otherTriggers = [];

        for (var i = 0; i < siblingsCount; i++) {
            var row = siblingRows[i];
            if (row != parentRow) {
                otherTriggers.push(row.getChildren()[triggerPositionInRow]);
            }
        }

        return otherTriggers;
    }
}

function initSimpleRowPopupHoverGateway(popupTriggerClass, popupTargetClass) {
    popupTriggerClass = popupTriggerClass || '.js_row_popup_trigger';
    popupTargetClass = popupTargetClass || '.js_row_popup_target';

    var popupTargets = $$(popupTargetClass);

    $$(popupTriggerClass).each(function(trigger, index) {
        var popupTarget = popupTargets[index];
        popupTarget.setStyle('left', trigger.getCoordinates(trigger.getParent()).left);
        var popup = new SimpleColPopUpHover(trigger, popupTarget, PopupHoverGatewayOptions);

        var triggerPositionInRow = trigger.getParent().getAllPrevious('td').length;

		_setCorrectSizeForPopupHoverGateway(popup, triggerPositionInRow);
    });

}

function createDropRotative() {
    $$('.js_old_dropdown').each(function (el) {

        var singleLabel = el.getElement('.js_special_offer_single').get("text");
        var multipleLabel = el.getElement('.js_special_offer_multiple').get("text");
        var itemsList = el.getElement("ul");
        if (!singleLabel || !multipleLabel || !itemsList) {
            return;
        }

        var triggerCnt = new Element("div", {'class': "btn_tnp flt js_dropdwn_trigger"});
        var tgr_a = new Element("a", {'class': 'wht js_rotate_trigger','tabindex':'30','href':'javascript:void(0);','html':singleLabel + '&nbsp;'});
        triggerCnt.adopt(tgr_a);

        triggerCnt.adopt(buildRotationElements(itemsList));

        var drop = buildDropBox(itemsList, multipleLabel);
        drop.inject(el, "after");
        triggerCnt.inject(el, "after");

        el.destroy();
    });


    function buildRotationElements(itemsList) {
        var ul = new Element("ul", {"class": "js_rotate_text js_rotate_trigger", style:"display: inline; cursor: pointer;"});
        itemsList.getElements('li').each(function (item) {
            ul.adopt(new Element("li", {"class": "gry hidden", html:item.get("text").trim()}))
        });
        return ul
    }

    function buildDropBox(itemsList, multipleLabel) {
        var ul = new Element("ul", {"class": "drp_dwn_4 js_dropdwn_target wdh_dbx", style:"visibility: hidden; display: none;"});
        ul.adopt(new Element("li", {"class": "cnt3_6_6_6 bkg_mbl h1_hgr", html:'<a tabindex="30"  class="js_dropdwn_header f85 upr bld lgr arr_wht_u dsb" href="javascript:void(0);">' + multipleLabel + '</a>'}));

        itemsList.getElements('li').each(function (item) {
            ul.adopt(new Element("li", {"class": "cnt6 bkg_dbl h1_hgr", html:'<a tabindex="30"  class="f90  gry  hvr_gry dot_gry" href="' + item.getElement('a').get("href").trim() + '">' + item.get("text").trim() + '</a>'}))
        });
        return ul
    }


    /*   function buildTriggerElement(trigger, singleLabel) {
     trigger.removeClass("js_dropdwn_trigger");
     trigger.getChildren().each(function (child) { child.destroy() });
     trigger.set("text", singleLabel);
     return trigger;
     }*/

}

function initDropDowns(additionalHideElements) {
    createDropRotative();

    new DropDowns('.js_dropdwn_trigger', '.js_dropdwn_target','.js_dropdwn_header', [ '.banner', '.ui_content_area' ].concat(additionalHideElements || []));
}

function initUnderLayedPopup(triggerClass, targetAttr, options) {
    triggerClass = triggerClass || '.js_vdo_trigger';
    targetAttr = targetAttr || 'rel';
    options = options || {};
    options.syncFlash = true;

    var groupByRel = {};

    $$(triggerClass).each(function(triggerEl) {
        var rel = triggerEl.getProperty(targetAttr);
        var targetEl = $(rel);

        if (!groupByRel[rel]) {
            groupByRel[rel] = new UnderLayedPopup(triggerEl, targetEl,
                    options);
        } else {
            groupByRel[rel].addShowElement(triggerEl);
        }

        groupByRel[rel].addEvent('onshow', function(){
            targetEl.getElement('a').focus();
        });
    });
}

function initShareWidget() {
    var shareTriggers = $$('.js_share_popup_trigger');
    var shareTargets = $$('.dynamic_layers');

    shareTriggers.each(function(trigger, index) {
        new ShareWidget(trigger, shareTargets[index]);
    });
}

function initProgressiveDisclosure(options) {
    // Loop through all root elements on page and initialize Progressive
    // disclosure functionality
    $$('.js_prg_dsc_root').each(function(rootEl) {
        new ProgressiveDisclosure(rootEl, $extend({
            expandAllEls: rootEl.getPrevious().getElements('.js_prg_dsc_exp'),
            expandAllElsDisabledClass: 'disabled',
            collapseAllEls: rootEl.getPrevious().getElements('.js_prg_dsc_clp'),
            collapseAllElsDisabledClass: 'disabled'
        }, options));
    });

    // Loop through all root elements on page and initialize Products
    // progressive disclosure functionality
    $$('.js_prg_dsc_prd_root').each(function(rootEl) {
        var disclosure = new ProgressiveDisclosure(rootEl, $extend({
            expandedClass : 'icon_plus',
            collapsedClass : 'icon_minus',
            expandAllEls: rootEl.getPrevious().getElements('.js_prg_dsc_exp'),
            expandAllElsDisabledClass: 'disabled',
            collapseAllEls: rootEl.getPrevious().getElements('.js_prg_dsc_clp'),
            collapseAllElsDisabledClass: 'disabled'
        }, options));
        disclosure.toggleAll(true, true);
    });
	
	// Loop through all root elements on Harris survey and initialize 
    // progressive disclosure functionality
	 $$('.js_prg_dsc_svy_root').each(function(rootEl) {
        var disclosure = new ProgressiveDisclosure(rootEl, $extend({
             expandAllElsDisabledClass: 'disabled',
            collapseAllElsDisabledClass: 'disabled'
        }, options));
    
    });
}

function initPriceWidget(priceWidgetClass) {
    $$(priceWidgetClass || '.js_pricing').each(function(containerEl) {
        new PriceWidget(containerEl);
    });

}

function initAccessoriesWidget(accessoriesWidgetClass) {
    $$(accessoriesWidgetClass || '.js_acc').each(function(containerEl) {
        new AccessoriesWidget(containerEl);
    });
}


/*
Generic function in charge of calling an external server and replacing the content of a div with the response.
Features:
	1.- Show loading animation
	2.- Cache in the client side the responses (using jstorage.js)

	Posible options: 
	{
		showLoading: true,
		loadingClass: 'ajax-loading',
		saveResponseInCache: true,
		hoursToSaveInCache: 10,
		callbackFn: null
	}
*/
function replaceWithAjaxResponse(div, url, options) {

	if (typeof(options) == 'undefined'){options = {};}
	options = options || {};
	
	response = false;
	if ((options.saveResponseInCache) && ($.jStorage)){
		cachedObject = $.jStorage.get(url);
		if (cachedObject){
			if (cachedObject.expiration){
				dt = new Date();
				dt.setTime(cachedObject.expiration);
				
				if (dt > new Date()){
					response = cachedObject.value;
				}
			}
			else{
				$.jStorage.deleteKey(url); //The cached object has already expired, so we are removing it
			}
		}
	}

	//If we have the response in the cache... we only show it
	if (response){
		$(div).set('html',response); 
		if ((options.callbackFn) && (typeof(options.callbackFn) == 'function')){
			options.callbackFn();	
		}
	}
	//If it's not there, or we select not to save it or we don't have the storage library in place we go and get it from the server
	else{
		if (options.loadingClass){
			options.loadingClass = options.loadingClass.toString();
		}
		else{ 
			options.loadingClass = 'ajax-loading';
		}
		
		if (options.showLoading == true){
			$(div).empty().addClass(options.loadingClass);
		}
		
		var req = new Request({
			method: 'get',
			url: url,
			onComplete: function(response) {
				$(div).set('html',response); 
				$(div).removeClass(options.loadingClass);
				
				if ((options.callbackFn) && (typeof(options.callbackFn) == 'function')){
					options.callbackFn();	
				}
				
				if ((options.saveResponseInCache) && ($.jStorage)){
				
					if ((options.hoursToSaveInCache) && (options.hoursToSaveInCache > 0)){
						options.hoursToSaveInCache = 2; //Default value is 2 hours; it's override by the options parameter
					}
					
					expirationDate = new Date();
					expirationDate.setHours(expirationDate.getHours() + options.hoursToSaveInCache);
					
					$.jStorage.set(url, {value: response, expiration: expirationDate.getTime()});
				}
			}	
		}).send();
	}
}

function initTooltips() {
    var parent = $$('.js_tip').getParent();
    var tips = new ArrowTips(parent, {
        title: '',
        fixed: true,
        showDelay: 200,
        offset: { x: 0, y: 10 },
        text: function(element) {
            return element.getElement('.js_tip').get('html');
        }
    });

    parent.each(function (el) {
        var shown = false;
        function keypressHandler(event) {
            if (event.key == "enter") {
                if (shown) {
                    tips.elementLeave(event, el);
                    shown = false;
                } else {
                    tips.elementEnter(event, el);
                    shown = true;
                }
            }
        }

        el.addEvents({
            focus: function (e) {
                this.addEvent("keypress", keypressHandler);
            },

            blur: function (e) {
                this.removeEvent("keypress", keypressHandler);
            }
        });
    });
    return tips;
}

function initFlashBanner(options){
 return new FlashBanner(options||{});
}

/*Printable version code*/
function printPage(printableClass){
var printable=$$(printableClass);

printable.each(function(el){
	el.addEvent('click',function(e){
		new Event(e).stop();
		setPrintLogo();
		window.print();
	});	
	el.addEvent('keypress',function(e){
		if(e.key=='enter'){
			new Event(e).stop();
			setPrintLogo();
			window.print();
		}
	});	
});
}

/*Adding a printable logo*/
function setPrintLogo(){
	if($$('.hplogo')[0].getElements('img')<=1){
		var printlogo= new Element('img',{'class':'printable logo png'});
		$$('.hplogo')[0].adopt(printlogo);
		$$('.hplogo img.logo')[0].setProperty('src',$$('.hplogo img.logo')[0].getStyle('background-image').replace('url("','').replace('")',''));
	}
	else{
		return;
	}
}

//Support for Browser Print Event (i.e. Control+P, File->Print)
function loadPrintLogo(){ 
	if(isIE){
		window.onbeforeprint=function(){
			setPrintLogo();
		}
	}
	else{
		//Pre-load the image when user mouseleave the everything div
		$$('.everything')[0].addEvent('mouseleave',function(){
			setPrintLogo();  
		});
	}
}


//Placeholder for IE6 CSS patches and hacks
function patchIE6(){
var dir = document.getElement('html').get('dir');
	if(Browser.Engine.trident4){//When we upgrade to 1.3 change to Browser.ie6
	$$('.white.bkg_35').setStyles({'background':'#f0f0f0 url(/us/en/images/i/rgt_col_bg_white_left_462697.jpg) repeat-y left top','margin-left':'0px','padding-left':'0px','margin-bottom':'-2000px','padding-bottom':'2000px'});
    $$('.white.bkg_65').setStyles({'background':'#f0f0f0 url(/us/en/images/i/rgt_col_bg_white_left_462697.jpg) repeat-y left top','margin-left':'0px','padding-left':'0px','margin-bottom':'-2000px','padding-bottom':'2000px'});
    $$('.white.cnt15_topics').setStyle('padding','20px 14px');
    $$('.gray.cnt15_topics').setStyle('padding','20px 0px 10px 14px');
	
	if (dir == 'rtl') {
	 $$('.gray.cnt15_topics').setStyle('padding','20px 14px 10px 0px');
	}
	
	}
	else
	return;
}

function updateScreenReading(parentEl, src_selector) {
	var src_el = parentEl.getElement(src_selector);
	var tar_el = parentEl.getElement('.screenReading');
	if (src_el && tar_el) {
		tar_el.innerHTML = src_el.innerHTML;
	}
}
/*
 Last modified
 Date: 4/9/2011 4:14 CST - Restored back correct code (using log)
 Date: 4-25/11 5:40 CST - Style was add in the dropboxes
 */

/* UnCompressed - Reason: DISABLED_TARGET-LIVECWADEPLOYER# */

/*
Date: 12/15/2011 10:03:13 PM
Non-published images:
/webdav/17%20United%20States-English%20Web/Building%20Blocks/System/00%20Shared/Content/CSS/i/"',''
*/
