
/* 3ef16f3c-9863-9597-f341-8f9913c99c11.res */

if(!window.console||!console.firebug){var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];window.console={};for(var i=0;i<names.length;++i)window.console[names[i]]=function(){}}

function function_exists(function_name) {
    if (typeof function_name == 'string'){
        return (typeof window[function_name] == 'function');
    } else{
        return (function_name instanceof Function);
    }
}

/**
 * fnx 4 HTMLContainer
 * lmd: 2009-01-21
 */

function windowHeight()
{
    var de = document.documentElement;
    return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
}

function windowWidth()
{
    var de = document.documentElement;
    return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
}

var hchw = hchml = hchcentered = 0;

function hchShowPage(pc)
{
  hchcentered = parseInt(pc) > 0 ? 1 : 0;
  var h = w = divw = divh = 1;
  var aa = new Array();
  jQuery("#container>div").each(function(i){
    var t = jQuery(this);
    divh = t.height()  + (parseInt(t.offset().top) || 0);
    h = divh > h ? divh : h;
    divw = t.width() + (parseInt(t.css('left')) || 0);
    w = divw > w ? divw : w;
    aa[i] = w;//fantastic trick
  });
  jQuery("#container").height(h).width(w).css({ width: w });
  w = aa[i];
  hchw = w;
  hchml = (w / 2) * (-1);
  hchFixCentered();
//  jQuery(window).resize(function(){
      hchFixCentered();
//  });
  jQuery("div[rel$=footer]").css("top", h);
}

function hchFixCentered()
{
//    if (hchcentered > 0 && windowWidth() > hchw) {
//        jQuery("#container").css({ left: '50%', marginLeft: hchml });
    if (hchcentered > 0) {
        jQuery("#container").css({ position: 'relative', margin: '0 auto' });
    } else {
        jQuery("#container").css({ position: 'absolute', left: 0, marginLeft: 0 });
    }
}

function hchInit(cen,col)
{
    hchcentered = parseInt(cen) > 0 ? true : false;
    if (hchcentered) {
        document.body.style.overflow='hidden';
        document.write('<div id="hch_loa" style="z-index:99999;position:absolute;width:'+windowWidth()+'px;height:'+windowHeight()+'px;top:0;left:0;background-color:'+col+'"></div>');
    }
    jQuery(document).ready(function(){
        hchShowPage(cen);
        if (hchcentered) {
            jQuery('#hch_loa').hide();
            document.body.style.overflow='auto';
        }
    });
}

function onloadInit()
{
    jQuery(document).ready(function(){
//        execEventBinded(APPLICATION_ID.replace(/\-/g, "_"), 'onload');
/*
        for (var i=0; i<o.eventEngine.eventDispatcher.eventArray.length; i++) {
            if (o.eventEngine.eventDispatcher.eventArray[i].eventSrc == "o_"+srcID+":"+evtName) {
                var nev = new VDOM_Event();
                nev.srcObj = document.getElementById("o_"+srcID);
                nev.name = evtName;
                if (params != undefined) {
                    for (key in params) {
                        nev.addParameter(key, params[key]);
                    }
//                    for (var i=0;i<params.length;i++) {
//                        nev.addParameter(params[i].Name, params[i].Value);
//                    };
                }
                o.eventEngine.processEvent(nev);
            }
        }
*/    
    });
}


/**
 * E2VDOM: UI helpers for client actions
 * lmd: 2009-02-10
 */

function vdom_evt_setvalue(o, value)
{
    jQuery(o.domCont).val(value);
    var ve = new VDOM_Event();
    ve.srcObj = o.domCont;
    ve.name = 'valuechange';
    ve.addParameter('itemValue', value);
    o.execEvent(ve);
}

function vdom_ui_hide(obj, fade, zi, toparent)
{
    if (jQuery(obj).css('display')!='none') {
        if (parseInt(fade) > 0) {
            var n = jQuery(obj).queue('fx'); 
            if (n.length <= 0) {
                var nn = parseInt(fade);
                jQuery(obj).fadeOut(nn);
            }
        } else {
            obj.style.display = 'none';
        }
        if (zi != undefined && parseInt(zi) > 0) {
            if (toparent != undefined && parseInt(toparent) > 0) {
                var o = obj.parentNode.style.zIndex;
            } else {
                var o = obj.style.zIndex;
            }
            o = zi;
        }
    }
}

function vdom_ui_show(obj, fade, zi, toparent)
{
    if (jQuery(obj).css('display')=='none') {
        if (parseInt(fade) > 0) {
            var n = jQuery(obj).queue('fx'); 
            if (n.length <= 0) {
                var nn = parseInt(fade);
                jQuery(obj).stop().fadeIn(nn);
            }
        } else {
            obj.style.display = 'block';
        }
    //    jQuery(obj).parent().css('z-index', '99999');
        if (zi != undefined && parseInt(zi) > 0) {
            if (toparent != undefined && parseInt(toparent) > 0) {
                var o = jQuery(obj).parent();
            } else {
                var o = jQuery(obj);
            }
            o.css('z-index', zi);
        }
    }
}

function vdom_ui_moveZindexTo(obj, newz)
{
    obj.style.zindex = parseInt(newz);
}

function vdom_ui_moveTo(obj, newX, newY, Effect)
{
    var xx = parseInt(newX) + "px";
    var yy = parseInt(newY) + "px";
    if (parseInt(Effect) > 0) {
        var n = jQuery(obj).queue('fx'); 
        if (n.length <= 0) {
            var num = parseInt(Effect);
            jQuery(obj).animate( { left:xx, top:yy }, num ) 
        }
    } else {
        obj.style.left = xx;
        obj.style.top = yy;
    }
}

function vdom_ui_addItem(obj, item, itemValue, selected)
{
    var x = obj.appendChild(document.createElement("option"));
    x.value = jQuery.trim(itemValue);
    x.innerHTML = item;
    if (parseInt(selected) > 0) {
        x.selected = true;
    }
}

function vdom_ui_removeItem(obj, item, itemValue)
{
    if (obj.length > 0 && (item !== '' || itemValue !== '')) {
        for (i = 0; i < obj.length; i++) {
            var node = obj[i];
            if (node) {
                if (/option/i.test(node.nodeName)) {
                    var x1 = item !== '' ? (item == node.innerHTML ? true : false) : true;
                    var x2 = itemValue !== '' ? (itemValue == node.value ? true : false) : true;
                    if (x1 && x2) {
                        obj.removeChild(node);
                        break;
                    }
                }
            }
        }
    }
}

function vdom_ui_sortItem(obj, sort)
{
    var lb = obj;
    var oldValue = lb[obj.selectedIndex].value;
    arrTexts = new Array();
    for(i=0; i < lb.length; i++) {
        arrTexts[i] = lb.options[i].text+':'+lb.options[i].value;
    }
    arrTexts.sort();
    var xx = sort > 0 ? lb.length - 1 : 0;
    for (i=0; i < lb.length; i++) {
        op = lb.options[xx - (xx-i < 0 ? 0 : xx-i)];
        el = arrTexts[i].split(':');
        op.text = el[0];
        op.value = el[1];
        if (oldValue == op.value) {
            op.selected = true;
        } else {
            op.selected = false;
        }
    }
}

function vdom_ui_setButtonImage(obj, resourceUrl)
{
    var ob = jQuery(obj).find('img:first');
    var iw = jQuery(ob).attr('width');
    var ih = jQuery(ob).attr('height');
    var isrc = resourceUrl;
    var srcover = jQuery(ob).attr("srcover");
    var iover = "this.src='" + srcover + "'";
    var iout = "this.src='" + resourceUrl + "'";
    jQuery(ob).replaceWith('<img width="'+iw+'" height="'+ih+'" border="0" alt="" src="'+isrc+'" srcover="'+srcover+'" onmouseover="'+iover+'" onmouseout="'+iout+'" />');
}

function vdom_ui_setButtonRollover(obj, resourceUrl)
{
    var ob = jQuery(obj).find('img:first');
    var iw = jQuery(ob).attr('width');
    var ih = jQuery(ob).attr('height');
    var isrc = jQuery(ob).attr("src");
    var srcover = resourceUrl;
    var iover = "this.src='" + resourceUrl + "'";
    var iout = "this.src='" + isrc + "'";
    jQuery(ob).replaceWith('<img width="'+iw+'" height="'+ih+'" border="0" alt="" src="'+isrc+'" srcover="'+srcover+'" onmouseover="'+iover+'" onmouseout="'+iout+'" />');
}

function vdom_ui_setLink(obj, containerUrl)
{
    var ob = jQuery(obj).find('a:first');
    jQuery(ob).attr('href', containerUrl);
}

function vdom_ui_unselect(obj)
{
    var a = obj.childNodes;
    if (a.length) { 
        for (i = 0; i < a.length; i++) {
            if (a[i].type == 'checkbox') {
                a[i].checked = false;
            }
        }
    }
}

function vdom_ui_select(obj)
{
    var a = obj.childNodes;
    if (a.length) { 
        for (i = 0; i < a.length; i++) {
            if (a[i].type == 'checkbox') {
                a[i].checked = true;
            }
        }
    }
}

function vdom_ui_addHTML(obj, value)
{
    tt = jQuery(obj).html(value) + value;
    jQuery(obj).html(tt);
}

function vdom_ui_resizeTo(obj, width, height)
{
    obj.style.width = parseInt(newZindex);
    obj.style.height = parseInt(newZindex);
}

/* drag */

function vdom_ui_dragStart(obj)
{
    if (drag_current_obj !== null) {
        dragStop_();
    }
    drag_current_obj = obj;
    dragInit_(obj);
}

function vdom_ui_dragStop()
{
    dragStop_();
}

/**/

function vdom_ui_setMenuHide(obj, msec, zi, toparent)
{
    jQuery('#'+obj.id).stopTime(obj.id);
    jQuery('#'+obj.id).mouseover(function(e){
        jQuery('#'+obj.id).stopTime(obj.id);
    }).mouseout(function(){
        jQuery('#'+obj.id).oneTime(msec, obj.id, function() {
            jQuery('#'+obj.id).hide()
            if (zi != undefined && parseInt(zi) > 0) {
                if (toparent != undefined && parseInt(toparent) > 0) {
                    var o = jQuery(obj).parent();
                } else {
                    var o = jQuery(obj);
                }
                o.css('z-index', zi);
            }
        });
    });
    jQuery('#'+obj.id).oneTime(msec, obj.id, function() {
        jQuery('#'+obj.id).hide();
        if (zi != undefined && parseInt(zi) > 0) {
            if (toparent != undefined && parseInt(toparent) > 0) {
                var o = jQuery(obj).parent();
            } else {
                var o = jQuery(obj);
            }
            o.css('z-index', zi);
        }
    });
}

/* resize */

function vdom_ui_startResizeXY(obj)
{
//TODO: reset resizable if already binded
    jQuery(obj).resizable({
        transparent: true
    });
}

function vdom_ui_startResizeX(obj)
{
    var th = jQuery(obj).height();
    jQuery(obj).resizable({
        transparent: true,
        minHeight: th,
        maxHeight: th
    });
}

function vdom_ui_startResizeY(obj)
{
    var tw = jQuery(obj).width();
    jQuery(obj).resizable({
        transparent: true,
        minWidth: tw,
        maxWidth: tw
    });
}

/* timer */

function vdom_ui_timerStart(obj, interval)
{
    if (interval == undefined) interval = 500;
    jQuery(obj).stopTime();
    obj.timerfreeze = 0;
    jQuery(obj).everyTime(interval, function(i){
        if (parseInt(obj.timerfreeze) == 0) {
            var vdomEvent = new VDOM_Event();
            vdomEvent.srcObj = obj.domCont;
            vdomEvent.name = 'timechange';
        	vdomEvent.addParameter('count', i);
        	vdomEvent.addParameter('time', new Date);
            obj.execEvent(vdomEvent);
        }
    });
}

function vdom_ui_timerStop(obj)
{
    jQuery(obj).stopTime();
}

function vdom_ui_timerFreeze(obj, freeze)
{
    obj.timerfreeze = parseInt(freeze);
}

function vdom_ui_timerSetInterval(obj, interval)
{
    vdom_ui_timerStart(obj, interval);
}

/* calendar */

function vdom_ui_calendarDateChange(o,d,m,y)
{
    execEventBinded(o, 'datechange', { day: d, month: m, year: y });
}

/*
* @author iNils
* @version 1.2 (20.07.07)
* @adds Leo: coords in styles added
*/
function showFlash(o){
	var bg,q,s,v;
	if(o.bgcolor){bg=o.bgcolor;}else{bg="#FFFFFF";}
	if(o.quality){q=o.quality;}else{q="high";}
	if(o.scale){s=o.scale;}else{s="noscale";}
    x=(o.x)?o.x:0;
    y=(o.y)?o.y:0;
	sty=(o.x||o.y)?'style="position:absolute;left:'+x+'px;top:'+y+'px;width:'+o.width+'px;height:'+o.height+'px"':'';
	if(o.nocache=="true"){o.name+="?"+new Date().getTime();}
	if(o.ver){v=o.ver;}else{v='9,0,0,0';}
	var str='<object '+sty+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+v+'" ';
	str+='id="'+o.id+'" ';
	if(o.align){str+='align="'+o.align+'" ';}
	str+='width="'+o.width+'" height="'+o.height+'"><param name="movie" value="'+o.name+'"/><param name="bgcolor" value="'+bg+'"/><param name="quality" value="'+q+'"/>';
	if(o.base){str+='<param name="base" value="'+o.base+'"/>';}
	if(o.flashvars){str+='<param name="flashvars" value="'+o.flashvars+'"/>';}
	if(o.allowScriptAccess){str+='<param name="allowScriptAccess" value="'+o.allowScriptAccess+'"/>';}
	if(o.salign){str+='<param name="salign" value="'+o.salign+'"/>';}
	if(o.wmode){str+='<param name="wmode" value="'+o.wmode+'"/>';}
	str+='<param name="scale" value="'+s+'"/><embed '+sty+' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="'+o.id+'" src="'+o.name+'" bgcolor="'+bg+'" ';
	if(o.flashvars){str+='flashvars="'+o.flashvars+'" ';}
	if(o.swLiveConnect){str+='swLiveConnect="'+o.swLiveConnect+'" ';}
	if(o.allowScriptAccess){str+='allowScriptAccess="'+o.allowScriptAccess+'" ';}
	str+='quality="'+q+'" ';
	if(o.base){str+='base="'+o.base+'" ';}
	if(o.wmode){str+='wmode="'+o.wmode+'" ';}
	if(o.salign){str+='salign="'+o.salign+'" ';}
	str+='scale="'+s+'" width="'+o.width+'" height="'+o.height+'"></embed></object>';
//	document.writeln(str);
    jQuery('body').append(str);
}

document.attachCP = [];
document.attachCP.length = 0;

function attachPickColor(id)
{
    jQuery(document).ready(function(){
        attachPickColorDo(id);
    });
}

function attachPickColorDo(id)
{
    if(jQuery.inArray(id,document.attachCP)<0){
        document.attachCP.length++;document.attachCP[document.attachCP.length-1]=id;
        var cp=jQuery('#'+id);
        cp.colorpickered = true;
        cp.ColorPicker({
            onShow:function(cp){jQuery(cp).css('z-index',9999).fadeIn(100);return false;},
            onSubmit:function(hsb,hex,rgb){
                jQuery('#'+id).css('backgroundColor','#'+hex);
                execEventBinded(id.substring(2, id.length),'changecolor',{color:'#'+hex});
                jQuery('#'+id+'>span').text('#'+hex);
                jQuery('#'+id).ColorPickerHidePicker();
            }
        });
        cp.ColorPickerSetColor('#'+cp.find('span').text());
    }
}

function vdom_ui_formSubmit(o)
{
    if (o.alreadySubmitted == undefined) {
       	o.alreadySubmitted = true;
    	return true;
    }
    return false;
}

