AG = function(){
    AG.prototype.select={
        byName:function(name){
            return document.getElementsByName(name);
        },
        byTagName:function(tagName){
            return document.getElementsByTagName(tagName.toUpperCase());
        },
        byClassName:function(className,parentNode){
            return document.getElementsByClassName(className,parentNode);
        }
    };
    AG.prototype.browser={
        isIE:function(){
            return (navigator.appVersion.indexOf('MSIE') != -1);
        },
        isIE6:function(){
            return (navigator.appVersion.indexOf('MSIE 6') != -1);
        },
        isGecko:function(){
            return (navigator.userAgent.indexOf('Gecko') != -1);
        },
        isFF:function(){
            return (navigator.userAgent.indexOf('Firefox') != -1);
        },
        isSafari:function(){
            return (navigator.userAgent.indexOf('Safari') != -1);
        },
        isOpera:function(){
            return (navigator.userAgent.indexOf('Opera') != -1);
        },
        width:function()
        {
            return window.getWidth();
        },
        scrollWidth:function(){
            return window.getScrollWidth();
        },
        height:function()
        {
            if (window.innerHeight){
                return window.innerHeight;
            }
            else{
                return document.body.offsetHeight;
            }
        },
        scrollHeight:function(){
            return window.getScrollHeight();
        },
        detectFlash:function(){
            if(SKAGTOOLS.FLASH_VERSION > 8){
                return true;
            }else{
                return false;
            }
        }
    };
    AG.prototype.cookie={
        set:function(name, value, duration){
            var expire = new Date ();
            expire.setTime (expire.getTime() + (duration* 1000));
            document.cookie = name + "=" + escape(value) + "; expires=" +expire.toGMTString()+"; path=/";
        },
        get:function(name){
            var startIndex = document.cookie.indexOf(name);
            if (startIndex != -1){
                var endIndex = document.cookie.indexOf(";", startIndex);
                if (endIndex == -1) endIndex = document.cookie.length;
                return unescape(document.cookie.substring(startIndex+name.length+1, endIndex));
            }
            else{
                return null;
            }
        },
        del:function(name){
            var expire = new Date ();
            expire.setTime (expire.getTime() - (24 * 60 * 60 * 1000));
            document.cookie = name + "=; expires=" + expire.toGMTString();
        }
    };
    AG.prototype.dom={
        createElement:function (tag, attribs, styles, parent) {
            var ag = new AG;
            var el = document.createElement(tag);
            if (attribs) ag.dom.setAttribute(el, attribs);
            if (styles) ag.dom.setStyle(el, styles);
            if (parent) parent.appendChild(el);
            return el;
        },
        setAttribute:function (el, attribs) {
            for (var x in attribs) {
                el[x] = attribs[x];
            }
        },
        setStyle:function (el, styles) {
            var ag = new AG;
            for (var x in styles) {
                try {
                    if (ag.browser.isIE() && x == 'opacity') el.style.filter = 'alpha(opacity='+ (styles[x] * 100) +')';
                    else el.style[x] = styles[x];
                }
                catch (e) {}
            }
        }
    };
    AG.prototype.effects={
        frame:0,
        time:0,
        timePerFrame:0,
        intervalId:false,
        element:0,
        numFrames:0,
        timePerFrame:0,
        animation:0,
        whendone:0,
        animate:function(element,numFrames,timePerFrame,animation,whendone){
            ag.effects.element = element;
            ag.effects.numFrames = numFrames;
            ag.effects.timePerFrame = timePerFrame;
            ag.effects.animation = animation;
            ag.effects.whendone = whendone;
            ag.effects.intervalId=setInterval(ag.effects.displayNextFrame,ag.effects.timePerFrame);
        },
        displayNextFrame:function()
        {
            ag.effects.timePerFrame=ag.effects.timePerFrame;
            if (ag.effects.frame >= ag.effects.numFrames)
            {
                clearInterval(ag.effects.intervalId);
                if(ag.effects.whendone)
                {
                    ag.effects.whendone(ag.effects.element);
                    return;
                }
            }
            for(var cssprop in ag.effects.animation)
            {
                try
                {
                    ag.effects.element.style[cssprop] = ag.effects.animation[cssprop](frame,time);
                }
                catch(e) {}
            }
            ag.effects.frame++;
            ag.effects.time += ag.effects.timePerFrame;
        }
    };
    AG.prototype.formCheck={
        email:function(fieldId)
        {

            if(!field){return false;}
            var regexp = /^\w+([\+\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
            return regexp.test(field.value);
        },
        checkboxChecked:function(fieldId)
        {
            var field=($(fieldId))?$(fieldId):fieldId;
            if(!field){return false;}
            return field.checked;
        },
        emptyText:function(fieldId)
        {
            var field=($(fieldId))?$(fieldId):fieldId;
            if(!field){return false;}
            if(field.value.length < 1)
            {
                return false;
            }
            else
            {
                return true;
            }
        },
        alphaText:function(fieldId)
        {
            var field=($(fieldId))?$(fieldId):fieldId;
            if(!field){return false;}
            var regexp = /[A-Z a-z]+/;
            return regexp.test(field.value);
        },
        alphaNumText:function(fieldId)
        {
            var field=($(fieldId))?$(fieldId):fieldId;
            if(!field){return false;}
            var regexp = /[A-Z a-z0-9]+/;
            return regexp.test(field.value);
        },
        alphaNumTextNoSpace:function(fieldId)
        {
            var field=($(fieldId))?$(fieldId):fieldId;
            if(!field){return false;}
            var regexp = /[A-Za-z0-9]+/;
            return regexp.test(field.value);
        },
        valueLength:function(fieldId)
        {
            var field=($(fieldId))?$(fieldId):fieldId;
            if(!field){return false;}
            return field.value.length;
        }
    };
    AG.prototype.debug={
        show:function(content)
        {
            var ag = new AG;
            if($('agTgtMainDebugWindow'))
            {
                debugWindowContent = $('agTgtDebugWindowContent');
                $('agTgtMainDebugWindow').style.display = 'block';
            }
            else
            {
                var width = ag.browser.width();
                var temp;
                var height = 60;
                temp = null;
                //tag, attribs, styles, parent
                var debugWindow = ag.dom.createElement(
                'div',
                {id:'agTgtMainDebugWindow',align:'left'},
                {
                    display:'block',
                    position:'absolute',
                    border:'1px solid red',
                    backgroundColor:'white',
                    width:width-2+'px',
                    height:height+'px',
                    top:0,
                    left:0,
                    fontSize:'10px',
                    zIndex:1000
                },
                $T('BODY')[0]
                );
                var debugWindowTitle = ag.dom.createElement(
                'div',
                {id:'agTgtDebugWindowTitle'},
                {
                    display:'block',
                    height:'14px',
                    borderBottom:'1px solid red'
                },
                $('agTgtMainDebugWindow')
                );
                debugWindowTitle.innerHTML = '<b>Debug Window</b> | <a href="" id="agTgtDebugWindowClearLink">Clear</a> | <a href="" id="agTgtDebugWindowCloseLink">Close</a>';
                $('agTgtDebugWindowClearLink').onclick = function(){ag.debug.clear();return false;};
                $('agTgtDebugWindowCloseLink').onclick = function(){ag.debug.close();return false;};
                var debugWindowContent = ag.dom.createElement(
                'div',
                {id:'agTgtDebugWindowContent'},
                {
                    display:'block',
                    overflow:'auto',
                    width:'100%',
                    height:'45px'
                },
                $('agTgtMainDebugWindow')
                );
            }
            debugWindowContent.innerHTML = content + '<br>' + debugWindowContent.innerHTML;
            return;
        },
        clear:function()
        {
            if($('agTgtDebugWindowContent'))
            {
                $('agTgtDebugWindowContent').innerHTML = '';
            }
        },
        close:function()
        {
            if($('agTgtMainDebugWindow'))
            {
                $('agTgtMainDebugWindow').style.display = 'none';
            }
        }
    }
    AG.prototype.loading={
        display:function(){
            if($('big_loading_div'))
            {
                $('big_loading_div').style.visibility = 'hidden';
                $('big_loading_div').style.display = 'block';
                $('big_loading_div').style.width=ag.browser.width()+'px';
                $('big_loading_div').style.height=ag.browser.scrollHeight()+'px';
                $('big_loading_div').style.visibility = 'visible';
            }
            else
            {
                ag.dom.createElement(
                'div',
                {id:'big_loading_div',className:'white_loading_screen'},
                {
                    width:ag.browser.width()+'px',
                    height:ag.browser.scrollHeight()+'px',
                    display:'block',
                    zIndex:1000
                },
                $T('BODY')[0]
                );
            }
            if($('loading_animation'))
            {
                $('loading_animation').style.display = 'block';
            }
            else
            {
                ag.dom.createElement(
                'div',
                {id:'loading_animation',className:'loading_animation'},
                {
                    display:'block',
                    zIndex:5000
                },
                $T('BODY')[0]
                );
                ag.dom.createElement(
                'img',
                {
                    id:'loading_animation_img',
                    src:SKAGTOOLS.AGS_LOGOS_IMG_PATH+"logo_anime.gif"
                },
                null,
                $('loading_animation')
                );
            }
            if(ag.browser.isIE6())
            {
                $('loading_animation').style.paddingLeft = '10px';
            }

            var blackLoadingScreensDisplayed = false;
            var blackLoadingScreens = $A(document.getElements('.loading_screen'));
            blackLoadingScreens.each(
            function(blackLoadingScreen){
                if((!blackLoadingScreensDisplayed) && (blackLoadingScreen.getStyle('display')=='block'))
                {
                    blackLoadingScreensDisplayed = true;
                }
            }
            );
            if(blackLoadingScreensDisplayed)
            {
                $('loading_animation_img').src=SKAGTOOLS.AGS_LOGOS_IMG_PATH+"logo_anime2.gif";//black background image
            }
            else
            {
                $('loading_animation_img').src=SKAGTOOLS.AGS_LOGOS_IMG_PATH+"logo_anime.gif";//transparent background image
            }

            for(var i=0;i<document.getElementsByTagName("embed").length;i++)
            {
                document.getElementsByTagName("embed")[i].style.visibility = "hidden";
            }
            for(var i=0;i<document.getElementsByTagName("applet").length;i++)
            {
                document.getElementsByTagName("applet")[i].style.visibility = "hidden";
            }
            for(var i=0;i<document.getElementsByTagName("object").length;i++)
            {
                document.getElementsByTagName("object")[i].style.visibility = "hidden";
            }
        },
        hide:function(){
            if($('big_loading_div')){
                $('big_loading_div').style.display = 'none';
            }
            if($('loading_animation')){
                $('loading_animation').style.display = 'none';
            }
            var blackLoadingScreensDisplayed = false;
            var blackLoadingScreens = document.getElements('.loading_screen');
            blackLoadingScreens.each(
            function(blackLoadingScreen){
                if(!blackLoadingScreensDisplayed && blackLoadingScreen.style.display!='none')
                {
                    blackLoadingScreensDisplayed = true;
                }
            }
            );
            if(!blackLoadingScreensDisplayed && $('slideshow_shade_div').style.display == "none")
            {
                for(var i=0;i<document.getElementsByTagName("embed").length;i++)
                {
                    document.getElementsByTagName("embed")[i].style.visibility = "visible";
                }
                for(var i=0;i<document.getElementsByTagName("applet").length;i++)
                {
                    document.getElementsByTagName("applet")[i].style.visibility = "visible";
                }
                for(var i=0;i<document.getElementsByTagName("object").length;i++)
                {
                    document.getElementsByTagName("object")[i].style.visibility = "visible";
                }
            }
        }
    }
    AG.prototype.layer={
        lock:false,
        visible: false,
        display:function(layerName)
        {
            if(ag.layer.lock == false){
                $('AgTgtLayerContainer').setStyle('top',window.getScrollTop()+'px');
                window.addEvent('scroll',function(){
                    $('AgTgtLayerContainer').setStyle('top',window.getScrollTop()+'px');
                });
                $('AgTgtLayerContent').innerHTML = '<img src="'+SKAGTOOLS.AGS_LOADING_IMG_PATH+'loading.gif" border="0"/>';
                $('AgTgtLayerInfoBox').style.visibility = 'hidden';
                //*/
                $('AgTgtLayerContent').align = 'center';
                $('AgTgtLayerTitle').innerHTML = ag.layers[layerName].title;
                $('AgTgtLayerMainIconDiv').innerHTML = '<img src="'+SKAGTOOLS.AGS_IMG_PATH+'dummy.gif" id="AgTgtLayerMainIcon" alt="" title="" style="width:'+ag.layers[layerName].icon.width+';height:'+ag.layers[layerName].icon.height+';background-image:url('+ag.layers[layerName].icon.url+');filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+ag.layers[layerName].icon.url+'\', sizingMethod=\'scale\');_background-image:none;border:0;"/>';

                if(ag.browser.width() > 1000)
                {
                    var targetWidth = ag.browser.width();
                }
                else
                {
                    var targetWidth = 1000;
                }
                if(ag.browser.scrollHeight() > 574)
                {
                    var targetHeight = ag.browser.scrollHeight();
                }
                else
                {
                    var targetHeight = 574;
                }
                if(layerName == 'INFOS')
                {
                    $('AgTgtLayerTitle').style.marginBottom = '0';
                }
                else if((layerName == 'RECEIVED')||(layerName == 'SENT'))
                {
                    $('AgTgtLayerTitle').style.marginBottom = '0';
                    $('AgTgtLayerTitle').style.width = '530px';
                    $('AgTgtLayerTitle').style.overflow = 'hidden';
                    $('AgTgtLayerTitle').setStyle('white-space', 'nowrap');
                }
                else if(layerName == 'SETTINGS')
                {
                    $('AgTgtLayerTitle').style.marginBottom = '20px';
                    $('AgTgtLayerTitle').style.width = '450px';
                }
                else
                {
                    $('AgTgtLayerTitle').style.marginBottom = '25px';
                    $('AgTgtLayerTitle').style.width = '';
                }
                if(layerName == 'UPLOAD' || layerName == 'MULTIUPLOAD' || layerName == 'CSV')
                {
                    $('AgTrgCloseLayerBtn').onclick = function(){location.reload();return false;};
                }
                else if (layerName == 'SHARE_STEP_1')
                {
                    $('AgTrgCloseLayerBtn').onclick = function(){ ag.cancel_share_step_1(); };
                }
                else
                {
                    $('AgTrgCloseLayerBtn').onclick = function(){  ag.layer.close(); return false; };
                }
                if ($defined($('AgTgtShareDateInfo'))){
                    $('AgTgtShareDateInfo').remove();
                }
                for(var i=0;i<document.getElementsByTagName("embed").length;i++)
                {
                    document.getElementsByTagName("embed")[i].style.visibility = "hidden";
                }
                for(var i=0;i<document.getElementsByTagName("applet").length;i++)
                {
                    document.getElementsByTagName("applet")[i].style.visibility = "hidden";
                }
                for(var i=0;i<document.getElementsByTagName("object").length;i++)
                {
                    document.getElementsByTagName("object")[i].style.visibility = "hidden";
                }
                if($('agTgtLayerLoadingScreen'))
                {
                    $('agTgtLayerLoadingScreen').style.top = 0;
                    $('agTgtLayerLoadingScreen').style.left = 0;
                    $('agTgtLayerLoadingScreen').style.width = targetWidth+'px';
                    $('agTgtLayerLoadingScreen').style.height = targetHeight+'px';
                    $('agTgtLayerLoadingScreen').style.display = 'block';
                    $('agTgtLayerLoadingScreen').style.zIndex = '200';
                }
                else
                {
                    var loadingScreen = ag.dom.createElement(
                    'div',
                    {
                        id:'agTgtLayerLoadingScreen',
                        className:'loading_screen'
                    },
                    {
                        top:0,
                        left:0,
                        width:targetWidth+'px',
                        height:targetHeight+'px',
                        display:'block',
                        zIndex:'200'
                    },
                    $T('BODY')[0]
                    );
                }
                ag.layer.lock = true;
                $('AgTgtLayerBox').style.filter = "Alpha(opacity=0)";
                $('AgTgtLayerBox').style.opacity = 0;
                $('AgTgtLayerContainer').style.display = 'block';
                $('AgTgtLayerContainer').style.zIndex='201';
                animateCSS($('AgTgtLayerBox'),5,10,{
                    opacity:function(frame,time){
                        $('AgTgtLayerBox').style.filter = "Alpha(opacity="+(frame*20)+")";
                        return (frame*20)/100;
                    }
                },
                function(element){
                    $('AgTgtLayerBox').style.filter = '';
                    $('AgTgtLayerBox').style.opacity = '';
                    ag.layer.lock=false;
                }
                );
            }
            ag.layer.visible=true;
        },
        close:function(element){
            $('agTgtLayerLoadingScreen').style.display = 'none';
            //ag.loading.hide();

            //reset image loading
            if ( $('loading_animation_img')) {
                $('loading_animation_img').src=SKAGTOOLS.AGS_LOGOS_IMG_PATH+"logo_anime.gif"; //transparent background image
            }
            //reset content layer class
            $('AgTgtLayerPage').className='';
            $('AgTgtLayerContainer').style.display = 'none';
            $('AgTgtLayerBox').style.opacity = 0;

            for(var i=0;i<document.getElementsByTagName("embed").length;i++)
            {
                document.getElementsByTagName("embed")[i].style.visibility = "visible";
            }
            for(var i=0;i<document.getElementsByTagName("applet").length;i++)
            {
                document.getElementsByTagName("applet")[i].style.visibility = "visible";
            }
            for(var i=0;i<document.getElementsByTagName("object").length;i++)
            {
                document.getElementsByTagName("object")[i].style.visibility = "visible";
            }
            ag.layer.visible=false;
        }

    }
    AG.prototype.alert={
        lock:false,
        open:function(message, callback){
            if(ag.alert.lock == false){
                var targetWidth = ag.browser.width();
                var targetHeight = ag.browser.scrollHeight();
                for(var i=0;i<document.getElementsByTagName("embed").length;i++)
                {
                    document.getElementsByTagName("embed")[i].style.visibility = "hidden";
                }
                for(var i=0;i<document.getElementsByTagName("applet").length;i++)
                {
                    document.getElementsByTagName("applet")[i].style.visibility = "hidden";
                }
                for(var i=0;i<document.getElementsByTagName("object").length;i++)
                {
                    document.getElementsByTagName("object")[i].style.visibility = "hidden";
                }
                if($('agTgtAlertLoadingScreen'))
                {
                    $('agTgtAlertLoadingScreen').style.top = 0;
                    $('agTgtAlertLoadingScreen').style.left = 0;
                    $('agTgtAlertLoadingScreen').style.width = targetWidth+'px';
                    $('agTgtAlertLoadingScreen').style.height = targetHeight+'px';
                    $('agTgtAlertLoadingScreen').style.display = 'block';
                    $('agTgtAlertLoadingScreen').style.zIndex = '300';
                }
                else
                {
                    var loadingScreen = ag.dom.createElement(
                    'div',
                    {
                        id:'agTgtAlertLoadingScreen',
                        className:'loading_screen'
                    },
                    {
                        top:0,
                        left:0,
                        width:targetWidth+'px',
                        height:targetHeight+'px',
                        display:'block',
                        zIndex:'300'
                    },
                    $T('BODY')[0]
                    );
                }

                //callback
                if($defined(callback)){
                    ag.callback = callback;
                    $('AgTrgAlertCloseBtn').removeEvents();
                    $('AgTrgAlertCloseBtn').addEvent('click',function(event){
                        eval(ag.callback);
                        event = new Event(event);
                        event.stop();
                    });
                }
                else{
                    ag.callback = '';
                    $('AgTrgAlertCloseBtn').removeEvents();
                    $('AgTrgAlertCloseBtn').addEvent('click',function(event){
                        ag.alert.close();
                        event = new Event(event);
                        event.stop();
                    });
                }
                $('AgTrgAlertOkBtn').removeEvents();
                $('AgTrgAlertOkBtn').cloneEvents($('AgTrgAlertCloseBtn'));

                //loadingScreen.style.display = 'block';
                //ag.loading.display();
                ag.alert.lock = true;
                $('AgTgtAlertBox').style.filter = "Alpha(opacity=0)";
                $('AgTgtAlertBox').style.opacity = 0;
                $('AgTgtAlertContent').innerHTML = message;
                $('AgTgtAlertContainer').setStyle('top',window.getScrollTop()+'px');
                window.addEvent('scroll',function(){
                    $('AgTgtAlertContainer').setStyle('top',window.getScrollTop()+'px');
                });
                $('AgTgtAlertContainer').style.display = 'block';
                animateCSS($('AgTgtAlertBox'),12,10,{
                    opacity:function(frame,time){
                        $('AgTgtAlertBox').style.filter = "Alpha(opacity="+(frame*8)+")";
                        return (frame*8)/100;
                    }
                },
                function(element){
                    $('AgTgtAlertBox').style.filter = '';
                    $('AgTgtAlertBox').style.opacity = '';
                    ag.alert.lock=false;
                }
                );
            }
        },
        close:function(){


            $('agTgtAlertLoadingScreen').style.display = 'none';
            if (!ag.layer.visible)
            {
                for(var i=0;i<document.getElementsByTagName("embed").length;i++)
                {
                    document.getElementsByTagName("embed")[i].style.visibility = "visible";
                }
                for(var i=0;i<document.getElementsByTagName("applet").length;i++)
                {
                    document.getElementsByTagName("applet")[i].style.visibility = "visible";
                }
                for(var i=0;i<document.getElementsByTagName("object").length;i++)
                {
                    document.getElementsByTagName("object")[i].style.visibility = "visible";
                }
            }
            $('AgTgtAlertContainer').style.display = 'none';
            $('AgTgtAlertBox').style.opacity = 0;
            $('AgTgtAlertContent').innerHTML = '';
        }
    }
    AG.prototype.confirm={
        lock:false,
        callback:{},
        open:function(message,callbackBtnLabel,cancelBtnLabel,customStyles){
            if(ag.confirm.lock == false){
                var test = ag.confirm.callback.toString();
                var targetWidth = ag.browser.width();
                var targetHeight = ag.browser.scrollHeight();
                for(var i=0;i<document.getElementsByTagName("embed").length;i++)
                {
                    document.getElementsByTagName("embed")[i].style.visibility = "hidden";
                }
                for(var i=0;i<document.getElementsByTagName("applet").length;i++)
                {
                    document.getElementsByTagName("applet")[i].style.visibility = "hidden";
                }
                for(var i=0;i<document.getElementsByTagName("object").length;i++)
                {
                    document.getElementsByTagName("object")[i].style.visibility = "hidden";
                }
                if($('agTgtConfirmLoadingScreen'))
                {
                    $('agTgtConfirmLoadingScreen').style.top = 0;
                    $('agTgtConfirmLoadingScreen').style.left = 0;
                    $('agTgtConfirmLoadingScreen').style.width = targetWidth+'px';
                    $('agTgtConfirmLoadingScreen').style.height = targetHeight+'px';
                    $('agTgtConfirmLoadingScreen').style.display = 'block';
                    $('agTgtConfirmLoadingScreen').style.zIndex = '300';
                }
                else
                {
                    var loadingScreen = ag.dom.createElement(
                    'div',
                    {
                        id:'agTgtConfirmLoadingScreen',
                        className:'loading_screen'
                    },
                    {
                        top:0,
                        left:0,
                        width:targetWidth+'px',
                        height:targetHeight+'px',
                        display:'block',
                        zIndex:'300'
                    },
                    $('main')
                    );
                }
                ag.confirm.lock = true;
                if($defined(callbackBtnLabel)){
                    $('SKCallbackBtnLabel').setHTML(callbackBtnLabel);
                }
                else{
                    $('SKCallbackBtnLabel').setHTML(txt('partages-recap_share|YES'));
                }
                if($defined(cancelBtnLabel)){
                    $('SKCancelBtnLabel').setHTML(cancelBtnLabel);
                }
                else{
                    $('SKCancelBtnLabel').setHTML(txt('partages-recap_share|NO'));
                }
                if($defined(customStyles)){
                    if($defined(customStyles.panelBtnWidth)){
                        $('SKTgtConfirmPanelBtn').setStyle('width',customStyles.panelBtnWidth);
                    }
                    else{
                        $('SKTgtConfirmPanelBtn').setStyle('width','160px');
                    }
                    if($defined(customStyles.contentWidth)){
                        $$('div#AgTgtConfirmContainer div#content').setStyle('width',customStyles.contentWidth);
                    }
                    else{
                        $$('div#AgTgtConfirmContainer div#content').setStyle('width','300px');
                    }
                    if($defined(customStyles.contentHeight)){
                        $$('div#AgTgtConfirmContainer div#content').setStyle('height',customStyles.contentHeight);
                    }
                    else{
                        $$('div#AgTgtConfirmContainer div#content').setStyle('height','125px');
                    }
                    if($defined(customStyles.containerMarginLeft)){
                        $('AgTgtConfirmContainer').setStyle('margin-left',customStyles.containerMarginLeft);
                    }
                    else{
                        $('AgTgtConfirmContainer').setStyle('margin-left','-200px');
                    }
                }
                else{
                    $('SKTgtConfirmPanelBtn').setStyle('width','160px');
                    $$('div#AgTgtConfirmContainer div#content').setStyle('width','300px');
                    $$('div#AgTgtConfirmContainer div#content').setStyle('height','125px');
                    $('AgTgtConfirmContainer').setStyle('margin-left','-200px');
                }
                $('AgTgtConfirmBox').style.filter = "Alpha(opacity=0)";
                $('AgTgtConfirmBox').style.opacity = 0;
                $('AgTgtConfirmContent').innerHTML = message;
                $('AgTgtConfirmContainer').setStyle('top',window.getScrollTop()+'px');
                window.addEvent('scroll',function(){
                    $('AgTgtConfirmContainer').setStyle('top',window.getScrollTop()+'px');
                });
                $('AgTgtConfirmContainer').style.display = 'block';
                $('AgTgtConfirmBox').style.display = 'block';
                if(window.ie6){
                    var originalheight = $$('div#AgTgtConfirmContainer div#content').getSize()[0];
                    $$('div#AgTgtConfirmContainer div#content').setStyle('height',originalheight.size.y+5+'px');
                }
                animateCSS($('AgTgtConfirmBox'),12,10,{
                    opacity:function(frame,time){
                        $('AgTgtConfirmBox').style.filter = "Alpha(opacity="+(frame*8)+")";
                        return (frame*8)/100;
                    }
                },
                function(element){
                    $('AgTgtConfirmBox').style.filter = '';
                    $('AgTgtConfirmBox').style.opacity = '';
                    ag.confirm.lock=false;
                }
                );
            }
        },
        close:function(){
            $('agTgtConfirmLoadingScreen').style.display = 'none';
            for(var i=0;i<document.getElementsByTagName("embed").length;i++)
            {
                document.getElementsByTagName("embed")[i].style.visibility = "visible";
            }
            for(var i=0;i<document.getElementsByTagName("applet").length;i++)
            {
                document.getElementsByTagName("applet")[i].style.visibility = "visible";
            }
            for(var i=0;i<document.getElementsByTagName("object").length;i++)
            {
                document.getElementsByTagName("object")[i].style.visibility = "visible";
            }
            $('AgTgtConfirmContainer').style.display = 'none';
            $('AgTgtConfirmBox').style.display = 'none';
            $('AgTgtConfirmContent').innerHTML = '';
        },
        valid:function(){
            var test = $('main');
            ag.confirm.callback();
        }
    },
    AG.prototype.infoBox={
        lock:false,
        display:function(message){
            if(ag.infoBox.lock == false){
                ag.infoBox.lock = true;
                $('AgTgtInfoBox').style.filter = "Alpha(opacity=0)";
                $('AgTgtInfoBox').style.opacity = 0;
                $('AgTgtInfoBoxContent').innerHTML = message;
                $('AgTgtInfoBox').style.display = 'block';
                $('AgTgtInfoBox').style.left = (ag.browser.width()-200)/2+"px";
                animateCSS($('AgTgtInfoBox'),12,10,{
                    opacity:function(frame,time){
                        $('AgTgtInfoBox').style.filter = "Alpha(opacity="+(frame*8)+")";
                        return (frame*8)/100;
                    }
                },
                function(element){
                    $('AgTgtInfoBox').style.filter = '';
                    $('AgTgtInfoBox').style.opacity = '';
                    ag.infoBox.lock=false;
                    window.setTimeout("ag.infoBox.close()",5000);
                }
                );
            }
        },
        close:function(){
            animateCSS($('AgTgtInfoBox'),12,10,{
                opacity:function(frame,time){
                    $('AgTgtInfoBox').style.filter = "Alpha(opacity="+(100 - (frame*8))+")";
                    return (1-((frame*8)/100));
                }
            },
            function(element){
                $('AgTgtInfoBox').style.filter = '';
                $('AgTgtInfoBox').style.opacity = '';
                $('AgTgtInfoBox').style.display = 'none';
            }
            );
        }
    },
    AG.prototype.JSON={
        to:function(object) {
            var a = ['{ '], b, i, v;
            for (i in object) {
                if(i == 'toJSONString') continue;
                v = object[i];
                if (b) { a.push(', '); }
                a.push("\"", i, "\"", ':');
                switch(typeof v) {
                    case 'string':
                    a.push("\"", v, "\"");
                    break;
                    default:
                    a.push(v);
                    break;
                }
                b = true;
            }
            a.push(' }');
            return a.join('');
        }
    },
    AG.prototype.misc={
        valid_move:function(){}
    }
};


var ag = new AG;
var SK = {};
function $N(name){
    return ag.select.byName(name);
}
function $T(tagName){
    return ag.select.byTagName(tagName);
}
function $C(className,parentNode){
    return ag.select.byClassName(className,parentNode);
}
window.alert = function(message,callback){ag.alert.open(message,callback);};
window.confirm = function(message,callback){ag.confirm.open(message,callback);};

var SKConfirmBox = new Class({
    initialize: function(params){
        this.msg = params.msg;
        this.callbackBtnLabel = params.callbackBtnLabel;
        this.cancelBtnLabel = params.cancelBtnLabel;
        this.callback = params.callback;
        this.customStyles = params.customStyles;
        this.open();
    },
    open:function(){
        ag.confirm.callback = this.callback;
        ag.confirm.open(this.msg,this.callbackBtnLabel,this.cancelBtnLabel,this.customStyles);
    }
});

var SKTips = Tips.extend({
    initialize: function(elements, options){
        this.parent(elements, options);
        if (window.ie6){
            this.toolTip.removeClass(this.options.className + '-tip');
            this.toolTip.addClass(this.options.className + '-tipie6');
        }
    }
});

function fixPNG(el) {
    try {
        if (window.ie6){
            el = $(el);
            if (!el) return el;
            if (el.getTag() == "img" && el.getProperty('src').test(".png")) {
                var vis = el.isVisible();
                try { //safari sometimes crashes here, so catch it
                    dim = el.getSize();
                }catch(e){}
                if(!vis){
                    var before = {};
                    //use this method instead of getStyles
                    ['visibility', 'display', 'position'].each(function(style){
                        before[style] = this.style[style]||'';
                    }, this);
                    //this.getStyles('visibility', 'display', 'position');
                    this.setStyles({
                        visibility: 'hidden',
                        display: 'block',
                        position:'absolute'
                    });
                    dim = el.getSize(); //works now, because the display isn't none
                    this.setStyles(before); //put it back where it was
                    el.hide();
                }
                var replacement = new Element('span', {
                    id:(el.id)?el.id:'',
                    'class':(el.className)?el.className:'',
                    title:(el.title)?el.title:(el.alt)?el.alt:'',
                    styles: {
                        display: vis?'inline-block':'none',
                        width: dim.size.x+'px',
                        height: dim.size.y+'px',
                        filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"
                        + el.src + "', sizingMethod='scale');"
                    },
                    src: el.src
                });
                if(el.style.cssText) {
                    try {
                        var styles = {};
                        var s = el.style.cssText.split(';');
                        s.each(function(style){
                            var n = style.split(':');
                            styles[n[0]] = n[1];
                        });
                        replacement.setStyle(styles);
                    } catch(e){ dbug.log('fixPNG1: ', e)}
                }
                if(replacement.cloneEvents) replacement.cloneEvents(el);
                el.replaceWith(replacement);
            } else if (el.getTag() != "img") {
                var imgURL = el.getStyle('background-image');
                if (imgURL.test(/\((.+)\)/)){
                el.setStyles({
                    background: '',
                    filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='crop', src='" + imgURL.match(/\((.+)\)/)[1] + "')"
                });
            };
        }
    }
} catch(e) {dbug.log('fixPNG2: ', e)}
};

function fixPNG2(img) {
    if(window.ie6 && $defined(img.src)) {
        var imgName = img.src.toUpperCase()
        if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
        {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='fixed');\"></span>"
            //scale
            img.outerHTML = strNewHTML
            i = i-1
        }
    }
}
if(window.ie6){
    window.addEvent('load', function(){$$('.fixPNG').each(function(img){
        fixPNG2(img);
    }
    )})
};