//::SET GLOBAL VARIABLES

	host = document.domain;
	
	if(host == "localhost"){
		
		HOME = "http://localhost/business/My%20Dropbox/PMY/";
		
		PUBLIC = "http://localhost/business/My%20Dropbox/PMY/core-public/";
		
		MEMBER = "http://localhost/business/My%20Dropbox/PMY/core-member/";
		
		ADMIN = "http://localhost/business/My%20Dropbox/PMY/core-administrator/";
		
		BROWSER = navigator.appName;
		
	}
	else{
		
	}

/*::SUPER FUNCTIONS [superFxn]
	As Defined : Is an object that holds fixed and universally accessible sets of function of varying purposes.
	Object Definition:
		1. ifPageReady - detects if the page has been loaded completely then executes a callback function.
		2. ifLoaded - function that detects if the document body or image has been loaded. [Accepts body and image as tgt values]
		3. pmyAjax - function for ajax. It is used for setting global variables and ajax response [method, parameter for get, pg, parsing [text|xml], type[init | execute]]
		4. setGlobal - function for setting the main js variables
		5. getVariable - function to capture ajax response
*/
var superFxn = {
	"ifPageReady" : function(callback){ //::TO add a function put function() {//desired function to execute after loading}
			superObject.init_fxn = callback;
			superFxn.ifPageFxnLoader();
		},
	"ifPageFxnLoader" : function(){
			if(document.readyState == "complete"){
				superObject.init_fxn();
			}
			else{
				setTimeout("superFxn.ifPageFxnLoader()",100);
			}
		},
	"pmyAjax" : function(){
			
			//DECLARE VARIABLES
			mtd = this.mtd;
			
			param = this.param;
			
			pg = this.pg;
			
			parsing = this.parsing;
			
			type = this.type;
			
			callback = this.callback;
			
			fallback = this.fallback;
			
			//PROCESS
			
			mtd == "get" ? method = "GET" : method = "POST";
			method == "GET" ? parameter = null : parameter = param;
			method == "GET" ? page = pg+"?"+param : page = pg;
			
			var request;
			
			try{
				request = new XMLHttpRequest();
			}
			catch(e){
				try{
					request = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){
					try{
						request = new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch(e){
						alert("Your browser is an old version and cannot support features of this application. Download a newer browser.");
						return false; //arrest any execution
					}
				}
			}
						
			
			request.open(method,page,true);
			request.setRequestHeader("Content-type","application/x-www-form-urlencoded"); //::USE THIS CONTENT TYPE FOR FORM BEHAVIOR
			request.send(parameter);
			

			request.onreadystatechange = function(){
				
				parsing == "text" ? parseAs = request.responseText : parseAs = request.responseXML;
				
				if(request.readyState == 4 && request.status == 200){
					
					type == "init" ? superFxn.setGlobal(true,parseAs, callback, fallback) : superFxn.getVariable(true,parseAs, callback, fallback);
				
				}
				else{
					type == "init" ? superFxn.setGlobal(false,parseAs, callback, fallback) : superFxn.getVariable(false,parseAs, callback, fallback);
				}
				
			}
			
			return true; //state if read all through*/
			
		},
	"setGlobal"  : function(boolean,value, callback, fallback){
			if(boolean){
				
				//::FOR TOOLTIP SETTING
				
				xpath = "//tooltip/item[@publish = 'yes']";
				
				if(BROWSER != "Microsoft Internet Explorer"){
					
					xpathResult = value.evaluate(xpath,value,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
					iterator = xpathResult.iterateNext();
					while(iterator){
						superObject.globalArray.tooltip[iterator.getAttribute("id")] = iterator.getAttribute("tip");
						iterator = xpathResult.iterateNext();
					}
					
				}
				else{
					
					var xpathResult = value.selectNodes(xpath);
					for(iterator = 0; iterator < xpathResult.length; iterator++){
						superObject.globalArray.tooltip[xpathResult[iterator].getAttribute("id")] = xpathResult[iterator].getAttribute("tip");
					}
					
				}
				
				callback();
				
			}
			else{ fallback(); } //::OPTIONAL ELSE CLAUSE ON FALSE 
		},
	"getVariable" : function(boolean,value, callback, fallback){
			if(boolean){
				//::FOR SETTING AJAX RESPONSE. Pass value to a function or it will be null result
				callback(value);
			}
			else{ fallback(); } //::OPTIONAL ELSE TO REMIND USER THAT FILE IS LOADING
		}, 
	"_create_object" : function(tgt,byWhat){
			switch(byWhat){
				case "id":
					dom = document.getElementById(tgt);
				break;
				case "tag":
					dom = document.getElementsByTagName(tgt);
				break;
				default:
					dom = null;
			}
			
			return dom;
		},
	"create_box" : function(width, height){
			
		},
	"init_move" : function(){
		
		//set general object values for separating activities
		superObject.init_obj.obj = this.tgt;
		superObject.init_obj.robj = this.rtgt;
		superObject.init_obj.type = this.type;
		superObject.init_obj.mode = this.mode;
		superObject.init_obj.front = this.front;
		superObject.init_obj._y1 = this.y1;
		superObject.init_obj._y2 = this.y2;
		superObject.init_obj._x1 = this.x1;
		superObject.init_obj._x2 = this.x2;
		superObject.init_obj._move = (this.dHeight-this.cHeight)/this.y2;
		superObject.init_obj._moveX = (this.dWidth-this.cWidth)/this.x2;
		
		//set Index level
		if(superObject.init_obj.front){
			superObject.init_obj.obj.style.zIndex = superObject.init_obj.index;
			superObject.init_obj.index++; //increment the index
		}
		
		//start the event by specifying that the object must start it
		this.tgt.onmousedown = superFxn.getting;
		//specify how to nullify event triggered by the target object
		document.onmouseup = function(){ 
			document.onmousemove = null; 
		}
		//prevent excess actions
		return false;
	},
	"getting" : function(e){
		
		if(BROWSER == "Microsoft Internet Explorer") { e = window.event; } //::EXPLICIT DECLARATION REQUIRED FOR IE
		
		//object to variable assignment. Just to shorten
		j = superObject.init_obj.type;
		h = superObject.init_obj.obj;
		
		//set initial x and y coordinate values
		superObject.init_obj.x1 = e.clientX;
		superObject.init_obj.y1 = e.clientY;
		
		//set initial top and left values of the target object
		isNaN(parseInt(h.style.top)) ? superObject.init_obj.t1 = 0 : superObject.init_obj.t1 = parseInt(h.style.top);
		isNaN(parseInt(h.style.left)) ? superObject.init_obj.l1 = 0 : superObject.init_obj.l1 = parseInt(h.style.left);
		
		//identify to what dimension should an object be moved
		if(j == "y"){ 
			if(superObject.init_obj.robj != null){ //FOR OBJECT WITH RELATIVE OBJECTS
				if(superObject.init_obj.robj.offsetHeight > superObject.init_obj._y2){
					
					document.onmousemove = superFxn.moveY;
				}
			}
			else{ //FOR OBJECT WITHOUT RELATIVE OBJECTS
					document.onmousemove = superFxn.moveY;
			}
		}
		else if(j == "x"){ document.onmousemove = superFxn.moveX;}
		else if(j == "xy"){ document.onmousemove = superFxn.moveXY;}
		
		//nullify excess actions
		return false;
	},
	"moveY" : function(e){
		
		if(BROWSER == "Microsoft Internet Explorer") { e = window.event; }//FOR IE COMPATIBILITY
		//specify second value for y coordinate
		superObject.init_obj.y2 = e.clientY;
		
		//set new top value of target object
		y = superObject.init_obj.t1 + (e.clientY - superObject.init_obj.y1);
		
		//identify if the object y coordinate must be moved relatively to drag or by smooth glide
		if(superObject.init_obj.mode == "static"){
			
			if(y > superObject.init_obj._y1 && y < superObject.init_obj._y2){
				superObject.init_obj.obj.style.top = y+"px";
				
				if(superObject.init_obj.robj != null){
					superObject.init_obj.robj.style.marginTop = -parseInt(y*superObject.init_obj._move)+"px"; 
				}
			}
			
			superObject.init_obj.t1 = y;
			superObject.init_obj.y1 = e.clientY;
		}
		else if(superObject.init_obj.mode == "dynamic"){
			
			//set to what extent should thw object be glide
			superObject.init_obj.dy = superObject.init_obj.t1 + ((superObject.init_obj.y2 - superObject.init_obj.y1) * 2);
			//call glide function
			superFxn.dynamicGlideY();
		}
		
		//prevent excessive action
		return false;
	},
	"dynamicGlideY" : function(){
		
		if(superObject.init_obj.y2 > superObject.init_obj.y1){ //if second y coordinate is greater than the first one
			
			//detects if the object is within the boundaries of y coordinate
			if(superObject.init_obj.dy > superObject.init_obj._y1 && superObject.init_obj.dy < superObject.init_obj._y2){  
				//detects if the top value is the same as the new top
				if(superObject.init_obj.t1 <= superObject.init_obj.dy){
					//increment the top
					superObject.init_obj.t1++;
					//set new top
					superObject.init_obj.obj.style.top = superObject.init_obj.t1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginTop = -superObject.init_obj.t1+"px";
					}
					
					//recall the function
					setTimeout("superFxn.dynamicGlideY()",1);
					
				}
			}
		}
		else{
			
			if(superObject.init_obj.dy > superObject.init_obj._y1 && superObject.init_obj.dy < superObject.init_obj._y2){
				
				if(superObject.init_obj.t1 >= superObject.init_obj.dy){
					
					superObject.init_obj.t1--;
					//set new top
					superObject.init_obj.obj.style.top = superObject.init_obj.t1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginTop = -superObject.init_obj.t1+"px";
					}
					
					setTimeout("superFxn.dynamicGlideY()",1);
				}
			
			}
		}
	
		return false;
		
	},
	"moveX" : function(e){
		
		if(BROWSER== "Microsoft Internet Explorer") { e = window.event; } //FOR IE COMPATIBILITY
		
		//specify second value for x coordinate
		superObject.init_obj.x2 = e.clientX;
		
		//set new left value of target object
		x = superObject.init_obj.l1 + (e.clientX - superObject.init_obj.x1);
		
		//identify if the object x coordinate must be moved relatively to drag or by smooth glide
		if(superObject.init_obj.mode == "static"){
			
			if(x > superObject.init_obj._x1 && x < superObject.init_obj._x2){
				superObject.init_obj.obj.style.left = x+"px";
				
				if(superObject.init_obj.robj != null){
					superObject.init_obj.robj.style.marginLeft = -x+"px";
				}
			}
			
			superObject.init_obj.l1 = x;
			superObject.init_obj.x1 = e.clientX;
		}
		else if(superObject.init_obj.mode == "dynamic"){
			
			//set to what extent should thw object be glide
			superObject.init_obj.dx = superObject.init_obj.l1 + ((superObject.init_obj.x2 - superObject.init_obj.x1) * 2);
			//call glide function
			superFxn.dynamicGlideX();
		}
		
		//prevent excessive action
		return false;
	},
	"dynamicGlideX" : function(){
		
		if(superObject.init_obj.x2 > superObject.init_obj.x1){ //if second y coordinate is greater than the first one
			
			//detects if the object is within the boundaries of y coordinate
			if(superObject.init_obj.dx > superObject.init_obj._x1 && superObject.init_obj.dx < superObject.init_obj._x2){  
				//detects if the top value is the same as the new top
				if(superObject.init_obj.l1 <= superObject.init_obj.dx){
					//increment the top
					superObject.init_obj.l1++;
					//set new top
					superObject.init_obj.obj.style.left = superObject.init_obj.l1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginLeft = -superObject.init_obj.l1+"px";
					}
					
					//recall the function
					setTimeout("superFxn.dynamicGlideX()",1);
					
				}
			}
		}
		else{
			
			if(superObject.init_obj.dx > superObject.init_obj._x1 && superObject.init_obj.dx < superObject.init_obj._x2){
				
				if(superObject.init_obj.l1 >= superObject.init_obj.dx){
					
					superObject.init_obj.l1--;
					//set new top
					superObject.init_obj.obj.style.left = superObject.init_obj.l1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginLeft = -superObject.init_obj.l1+"px";
					}
					
					setTimeout("superFxn.dynamicGlideX()",1);
				}
			
			}
		}
	
		return false;
		
	},
	"moveXY" : function(e){
		
		if(BROWSER == "Microsoft Internet Explorer") { e = window.event; } //FOR IE COMPATIBILITY
		//alert(superObject.init_obj._x1);
		//specify second value for x and y coordinate
		superObject.init_obj.x2 = e.clientX;
		superObject.init_obj.y2 = e.clientY;
		
		//set new left value of target object
		x = superObject.init_obj.l1 + (superObject.init_obj.x2 - superObject.init_obj.x1);
		y = superObject.init_obj.t1 + (superObject.init_obj.y2 - superObject.init_obj.y1);
		
		//identify if the object x coordinate must be moved relatively to drag or by smooth glide
		if(superObject.init_obj.mode == "static"){
			
			if((x > superObject.init_obj._x1 && x < superObject.init_obj._x2) && (y > superObject.init_obj._y1 && y < superObject.init_obj._y2)){
				
				superObject.init_obj.obj.style.left = x+"px";
				superObject.init_obj.obj.style.top = y+"px";
				
				if(superObject.init_obj.robj != null){
					if(superObject.init_obj._moveX != 0){
						superObject.init_obj.robj.style.marginLeft = -parseInt(x*superObject.init_obj._moveX)+"px";
						superObject.init_obj.robj.style.marginTop = -parseInt(y*superObject.init_obj._move)+"px";
					}
					else{
						superObject.init_obj.robj.style.marginLeft = -x+"px";
						superObject.init_obj.robj.style.marginTop = -y+"px";
					}
				}
			}
			
			superObject.init_obj.l1 = x;
			superObject.init_obj.t1 = y;
			
			superObject.init_obj.x1 = e.clientX;
			superObject.init_obj.y1 = e.clientY;
			
			return false;
		}
		else if(superObject.init_obj.mode == "dynamic"){
			
			//set to what extent should thw object be glide
			superObject.init_obj.dx = superObject.init_obj.l1 + ((superObject.init_obj.x2 - superObject.init_obj.x1) * 2);
			superObject.init_obj.dy = superObject.init_obj.t1 + ((superObject.init_obj.y2 - superObject.init_obj.y1) * 2);
			//call glide function
			superFxn.dynamicGlideXY();
			
			return false;
		}
		
		//prevent excessive action
		return false;
	},
	"dynamicGlideXY" : function(){
		
		if((superObject.init_obj.x2 > superObject.init_obj.x1) && (superObject.init_obj.y2 > superObject.init_obj.y1)){ //if second y coordinate is greater than the first one
			
			//detects if the object is within the boundaries of y coordinate
			if(superObject.init_obj.dx > superObject.init_obj._x1 && superObject.init_obj.dx < superObject.init_obj._x2){  
				//detects if the top value is the same as the new top
				if(superObject.init_obj.l1 <= superObject.init_obj.dx){
					//increment the top
					superObject.init_obj.l1++;
					//set new top
					superObject.init_obj.obj.style.left = superObject.init_obj.l1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginLeft = -superObject.init_obj.l1+"px";
					}
					
					//recall the function
					setTimeout("superFxn.dynamicGlideXY()",1);
					
				}
			}
			
			//detects if the object is within the boundaries of y coordinate
			if(superObject.init_obj.dy > superObject.init_obj._y1 && superObject.init_obj.dy < superObject.init_obj._y2){  
				//detects if the top value is the same as the new top
				if(superObject.init_obj.t1 <= superObject.init_obj.dy){
					//increment the top
					superObject.init_obj.t1++;
					//set new top
					superObject.init_obj.obj.style.top = superObject.init_obj.t1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginTop = -superObject.init_obj.t1+"px";
					}
					
					//recall the function
					setTimeout("superFxn.dynamicGlideXY()",1);
					
				}
			}
		}
		else{
			
			//detects if the object is within the boundaries of y coordinate
			if(superObject.init_obj.dx > superObject.init_obj._x1 && superObject.init_obj.dx < superObject.init_obj._x2){  
				//detects if the top value is the same as the new top
				if(superObject.init_obj.l1 >= superObject.init_obj.dx){
					//increment the top
					superObject.init_obj.l1--;
					//set new top
					superObject.init_obj.obj.style.left = superObject.init_obj.l1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginLeft = -superObject.init_obj.l1+"px";
					}
					
					//recall the function
					setTimeout("superFxn.dynamicGlideXY()",1);
					
				}
			}
			
			//detects if the object is within the boundaries of y coordinate
			if(superObject.init_obj.dy > superObject.init_obj._y1 && superObject.init_obj.dy < superObject.init_obj._y2){  
				//detects if the top value is the same as the new top
				if(superObject.init_obj.t1 >= superObject.init_obj.dy){
					//increment the top
					superObject.init_obj.t1--;
					//set new top
					superObject.init_obj.obj.style.top = superObject.init_obj.t1+"px";
					
					if(superObject.init_obj.robj != null){
						superObject.init_obj.robj.style.marginTop = -superObject.init_obj.t1+"px";
					}
					
					//recall the function
					setTimeout("superFxn.dynamicGlideXY()",1);
					
				}
			}
			
		}
	
		return false;
		
	},
	"createDiv" : function(w,h,id,color){
		
			try{
				
				if(superFxn._create_object(id,"id").id.toString()){
					
					$("#"+id).fadeIn();
					
				}
				
			}
			catch(e){
				
				d1 = document.createElement("div");
				d1.id = id;
				d1.style.width = w+"px";
				d1.style.height = h+"px";
				d1.style.background = color;
				d1.style.border = "5px #666666 solid";
				d1.style.position = "absolute";
				d1.className = "robust";
				d1.style.display = "block";
				d1.style.left = parseInt((screen.availWidth/2)-(w/2))+"px";
				d1.style.top = parseInt((screen.availHeight/2)-(h/2))+"px";
				d1.style.zIndex = superObject.init_obj.index;
				d1.style.borderRadius = "10px";
				d1.style.mozBorderRadius = "10px";
				d1.style.boxShadow = "5px 5px 10px #333333";
				d1.style.mozBoxShadow = "5px 5px 10px #333333";
				document.body.appendChild(d1);
			}
		}
}
/*::SUPER OBJECTS [superObject]
	As Defined : Is an object that holds fixed and universally accessible sets of function of varying purposes.
	Object Definition:
		1. environment - object that holds js variables. It must not be overridden at any case after initialization.
		2. response - holds ajax response.
		3. globalArray - holds frequently used arrayed data.
		4. init_fxn - holds function passed during initialization
*/
var superObject = {
	"environment" : {"path" : null, "debug" : null},
	"response" : null,
	"globalArray" : {"tooltip" : new Array()},
	"init_fxn" : new Object(),
	"init_obj" : new Object(),
	"init_page" : true,
	"count" : null
}

function chooseColor(d)
{
	if(document.getElementById("block_"+d).style.display != "block"){
		$("#block_"+d).slideDown("fast");
	}
	else{
		$("#block_"+d).slideUp("fast");
	}
}
