﻿var jspath = "js/";
var JaGa = {
	
    enginepath: jspath + "engine/",
	modulepath: jspath + "modules/",
	controlspath: "controls/",
	
    run: function(){

		this.loadEngine("jquery");
		this.loadEngine("ajax");
		
		this.loadControl("listbox");
		this.loadControl("grid");
		this.loadControl("uploader");
		this.loadControl("schedule");
		
		this.loadModule("lightbox");
	},
	
	include : function(file){
		document.write('<script type="text/javascript" src="'+ file + '"></script>'); 
	},
	
	loadEngine : function(name){
		this.include(this.enginepath + name + ".js");
	},
	
	loadModule : function(name){
		this.include(this.modulepath + name + ".js");
	},
	
	loadControl : function(name){
		this.include(this.controlspath + name + "/core.js");
	},
	
	selfTest : function(){
		alert("JaGa dla JS działa xD");
	},

	validateEntry : function(entry,chars){
		
		if(chars == "numeric")
					chars = "0987654321";
		if(chars == "alfa")
					chars = "abcdefghijklmnoprstquwvxyzABCDEFGHIJKLMNOPRSTQUWVXYZ";
		if(chars == "plalfa")
					chars = "ąĄćĆóÓżŻźŹłŁńŃśŚęĘabcdefghijklmnoprstquwvxyzABCDEFGHIJKLMNOPRSTQUWVXYZ";
		if(chars == "files")
					chars = "abcdefghijklmnoprstquwvxyzABCDEFGHIJKLMNOPRSTQUWVXYZ0123456789_";
		for(var ex = 0; ex <= entry.length-1; ex++){
			if(chars.indexOf(entry.substring(ex,ex+1)) == -1)
				return false;
		}
		return true;
	}

}
JaGa.run();


var jgValidator = {
	
	entry : "",
	
	charset : "",
	
	valid : function(){
	
		
	
	},
	
	chars : function(chars){
		
		if(chars == "numeric")
					chars = "0987654321";
		if(chars == "alfa")
					chars = "abcdefghijklmnoprstquwvxyzABCDEFGHIJKLMNOPRSTQUWVXYZ";
		if(chars == "plalfa")
					chars = "ąĄćĆóÓżŻźŹłŁńŃśŚęĘabcdefghijklmnoprstquwvxyzABCDEFGHIJKLMNOPRSTQUWVXYZ";
		if(chars == "files")
					chars = "abcdefghijklmnoprstquwvxyzABCDEFGHIJKLMNOPRSTQUWVXYZ0123456789_";
		for(var ex = 0; ex <= this.entry.length-1; ex++){
			if(chars.indexOf(this.entry.substring(ex,ex+1)) == -1)
				return false;
		}
		return true;
	}
	
}
