if (!FJS)
	var FJS = {};
FJS.Requist=Class.create({   
	initialize: function(url) 
	{   
		this.url=url;
		this.data={};
	},
	setData:function(k,v){
		this.data[k]=v;
	},
	send:function(){
		var frm=Element("FORM");
		frm.method=this.method || 'post';
		frm.action=this.url;
		for(var i in this.data){
			var input=Element("INPUT");
			input.type="hidden";
			input.name=i;
			input.value=this.data[i];
			frm.appendChild(input);
		}
		document.body.appendChild(frm);
		frm.submit();		
	}
});
FJS.DropDownMenu=Class.create({ 
	initialize: function(menuElement,ul_handle) {
		var uls=menuElement.select('ul');
		uls.each(function(el){
			el.setStyle({'display':'none'});						
		});
		
		this.ulHandle=ul_handle;		
		this.ulList=[];
		this.applyUl(menuElement);
		
		
		
	},
	applyLi:function(li){
		if(Object.isElement(li) && li.tagName=='LI'){
			var ul=li.down('ul');
			
			var isUL=false;
			if(Object.isElement(ul)){
				isUL=true;
				this.applyUl(ul);
				this.ulList.push(ul);				
			}
			li.observe('mouseover', function(event){				
				this.ElHide(li);
								
				if(isUL){
					ul.show();					
					if(Object.isFunction(this.ulHandle)) this.ulHandle(li,ul);
				}
				li.addClassName('over');				
			}.bind(this));			
			
			li.observe('mouseout', function(event){
				if(isUL)
				ul.hide();	
			}.bind(this));
		}
	},
	applyUl:function(ul){
		if(Object.isElement(ul)){
			ul.childElements().each(function(li){
				this.applyLi(li);
			}.bind(this));
		}
	},
	ElHide:function(li){
		this.ulList.each(function(ul){
			if(li.descendantOf(ul) );//
			else ul.hide();
		}.bind(this));
		/*$('out1').update(' ');
		$('out2').update(' ');
		if(Object.isElement(this.oldLi)){
			this.oldLi.removeClassName('over');
			$('out1').update('li');
			var ul=this.oldLi.down('ul');
			//if(Object.isElement(ul))	ul.hide();
		}
		/*
		if(Object.isElement(this.oldUl)){
			$('out2').update('ul');
			this.oldUl.hide();
		}*/
	}
});
FJS.swf=function(movieName){	
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
    } else {
        return document[movieName];
    }
};
FJS.getXMLDoc=function(text){
	var xmlDoc;

	try //Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(text);
	}
	catch(e)
	{
		try //Firefox, Mozilla, Opera, etc.
		{
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(text,"text/xml");
		}
		catch(ex) {
			alert(ex.message);
		}
	}
	return xmlDoc;
}

FJS.Validation=Class.create({
	initialize: function(txt) 
	{   
		this.txt=txt;
	},
	isEmail:function(){		
		if (this.txt.match(/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/))
			return true;
		else
			return false;
	}
});


FJS.Cookies = Class.create({
    initialize: function(path, domain) {
        this.path = path || '/';
        this.domain = domain || null;
    },
    // Sets a cookie
    set: function(key, value, days) {
        if (typeof key != 'string') {
            throw "Invalid key";
        }
        if (typeof value != 'string' && typeof value != 'number') {
            throw "Invalid value";
        }
        if (days && typeof days != 'number') {
            throw "Invalid expiration time";
        }
        var setValue = key+'='+escape(new String(value));
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var setExpiration = "; expires="+date.toGMTString();
        } else var setExpiration = "";
        var setPath = '; path='+escape(this.path);
        var setDomain = (this.domain) ? '; domain='+escape(this.domain) : '';
        var cookieString = setValue+setExpiration+setPath+setDomain;
        document.cookie = cookieString;
    },
    // Returns a cookie value or false
    get: function(key) {
        var keyEquals = key+"=";
        var value = false;
        document.cookie.split(';').invoke('strip').each(function(s){
            if (s.startsWith(keyEquals)) {
                value = unescape(s.substring(keyEquals.length, s.length));
                throw $break;
            }
        });
        return value;
    },
    // Clears a cookie
    clear: function(key) {
        this.set(key,'',-1);
    },
    // Clears all cookies
    clearAll: function() {
        document.cookie.split(';').collect(function(s){
            return s.split('=').first().strip();
        }).each(function(key){
            this.clear(key);
        }.bind(this));
    }
});
FJS.JsonCookies = Class.create(FJS.Cookies, {});
FJS.JsonCookies.addMethods({
    // Overridden set method to JSON-encode value
    set: function($super, key, value, days) {
        switch (typeof value) {
            case 'undefined':
            case 'function':
            case 'unknown':
                throw "Invalid value type";
                break;
            case 'boolean':
            case 'string':
            case 'number':
                value = String(value.toString());
            break;
        }
        $super(key, Object.toJSON(value), days);
    },
    // Overriden get method to JSON-decode the value
    get: function($super, key) {
        var value = $super(key);
        return (value) ? value.evalJSON() : false;
    }
});
