/*
	StyledWin


*/
	var w=null;
	var off=true;
	var color;
	var bgcolor;
	var link;

        var StyledWin = {
        init: function() {
     		$(document.body).addEvent('mousedown', function() {
        		if (w && off) {
				link.setStyle('color', color);
				link.setStyle('background-color', bgcolor);
				w.destroy();w=null;
				}
        		});
        	},

        click: function(l,type,id,id2) {
		link=l;
        	if (w ==null) {
			color=link.getStyle('color');
			bgcolor=link.getStyle('background-color');
			link.setStyle('color', '#ffF');
			link.setStyle('background-color', '#146798');

			w=new StickyWin({
                       	content: '<div id="styledpopup"> <div id="styledpopup-content" style="border: 2px solid #146798; background-color: #95bad0; padding: 2px;"><img src="img/loading.gif"></div> </div>',
			relativeTo: link,
                        position: 'bottomLeft'
                        });
		this.load (type,id,id2);
		$('styledpopup').addEvent('mouseover', function() {off=false;});
        	$('styledpopup').addEvent('mouseout', function() {off=true});
                }
        	},
	close: function() {
				link.setStyle('color', color);
				link.setStyle('background-color', bgcolor);
				off=true;
				w.destroy();w=null;
	},

	load: function (type,id,id2) {
        var url = "/_do_StyledPopup.php?"+Object.toQueryString({p: type, id: id, id2: id2});
        var cc;
        new Ajax(url, {
                method: 'get',
                evalScripts: true,
                onSuccess: function(){
                $('styledpopup-content').setHTML((this.response.text))
                }
        }).request();

		},

	//to check not run br1 20070104
	append: function (type,id) {
        var url = "/_do_StyledPopup.php?"+Object.toQueryString({type: type, id: id});
        var cc;
        new Ajax(url, {
                method: 'get',
                evalScripts: true,
                onSuccess: function(){
		//ee=new Element(this.response.text);
                $('styledpopup-content').appendText((this.response.text))
                }
        }).request();

		}


        };

window.addEvent('domready', StyledWin.init.bind());



