/*************************************
INLINE PANEL OBJECT
author: Jamil HASSAN Spain
namespace: http://www.iqbs.biz
date: January 2007
*****************************************/

function inlinePanelObject( name ) {
  if (! $(name) ){
    alert("Sorry.. Cannot instantiate your Panel.. Div "+name+" does not exist!");

  }else{
    this.element = $(name);
  }
}
inlinePanelObject.prototype.panelType = function ( name,shadow ){ 
		if ( shadow == 'Y' ){ this.shadow = true; }else{ this.shadow = false;}
		 this.panelname = name; 
}
 
inlinePanelObject.prototype.cfgTitle = function ( height,color ) {
		if ( !color ){ 
			this.titlecolor = true; 
		}else{  
			if( color == 'Y' ){ this.titlecolor = true; }else{ this.titlecolor = false; }
		}
		if ( !height ){ this.titleheight = "25px"; } else{ this.titleheight = height+"px"; }
		
}
inlinePanelObject.prototype.setTitleContent = function ( text, textcolor, textsize,textfamily ){
		if ( !text ) { this.titletext = ""; }else{ this.titletext = text; } 
		if ( !textcolor ) { this.titletextcolor = "#000000"; }else{ this.titletextcolor = textcolor;  }
		if ( !textsize ) {  this.titletextsize = "10pt"; }else{  this.titletextsize = textsize; }
		if ( !textfamily ) { this.titletextfont = "Arial"; }else{ this.titletextfont = textfamily; }
}
inlinePanelObject.prototype.cfgPanel = function ( width,height,bgcolor,size) {
		this.width = width+"px";
		this.titlewidth = (width-10); 
		if ( height == 'auto' ){ this.height = height; }else{ 
			this.height = height+"px"; }
		this.bgcolor = bgcolor;
		if (!size){ this.size = "4px"; }else{ this.size = size+"px";  }
		
		// let's create panel elements
	if ( this.shadow ) {
		this.outerdiv = document.createElement("div");
			this.outerdiv.id = "outerpanel-"+this.panelname;
			this.outerdiv.name = "outerpanel-"+this.panelname;
			this.outerdiv.style["backgroundColor"]= this.bgcolor; //
			
			this.outerdiv.style["width"]=this.width; this.outerdiv.style["height"]=this.height; 
			this.outerdiv.style["margin"]=this.size; this.outerdiv.style["position"]="absolute";
			  
			
		this.innerdiv = document.createElement("div");
			this.innerdiv.id = "innerpanel-"+this.panelname;
			this.innerdiv.name = "innerpanel-"+this.panelname;
			this.innerdiv.style["backgroundColor"]="#FFF"; this.innerdiv.style["border"]="1px solid "+this.bgcolor; 
			this.innerdiv.style["position"]="relative"; this.innerdiv.style["top"] = "-5px"; this.innerdiv.style["left"]="-5px";				            this.innerdiv.style["width"]=this.width; this.innerdiv.style["height"]=this.height; 
			//this.innerdiv.style["z-index"]="105";  
			
		this.ptitle = document.createElement("div");
			this.ptitle.id = "ptitle-"+this.panelname;
			this.ptitle.name = "ptitle-"+this.panelname;
			this.ptitle.style["height"]= this.titleheight; this.ptitle.style["padding"]="3px";
			this.ptitle.style["width"] = this.titlewidth+"px"; //this.ptitle.style["margin-top"] = "3px";
			this.ptitle.style["border"]="0px solid red"; 
			if ( this.titlecolor ) { this.ptitle.style["backgroundColor"]= this.bgcolor;  }
			//this.ptitle.style["z-index"]="106";   
			
			 this.ptitle.style["position"] = "relative"; this.ptitle.style["left"] = "0px"; this.ptitle.style["top"] = "3px";
			 this.ptitle.style["text-align"] = "center"; 	 this.ptitle.style["color"] = this.titletextcolor; 
			 	 this.ptitle.style["font-family"] = "center"; 
			 this.ptitle.innerHTML =  this.titletext;
	}else{
		
		this.innerdiv = document.createElement("div");
			this.innerdiv.id = "innerpanel-"+this.panelname;
			this.innerdiv.name = "innerpanel-"+this.panelname;
			this.innerdiv.style["backgroundColor"]="#FFF"; this.innerdiv.style["border"]="1px solid "+bgcolor; 
			this.innerdiv.style["position"]="relative"; this.innerdiv.style["top"] = "-5px"; this.innerdiv.style["left"]="-5px";				            this.innerdiv.style["width"]=this.width; this.innerdiv.style["height"]=this.height; 
			//this.innerdiv.style["z-index"]="105";  
	
	
		this.ptitle = document.createElement("div");
			this.ptitle.id = "ptitle-"+this.panelname;
			this.ptitle.name = "ptitle-"+this.panelname;
			this.ptitle.style["height"]=this.titleheight; 
			//this.ptitle.style["padding"]="3px";
			this.ptitle.style["width"] = this.width; //this.ptitle.style["margin-top"] = "3px";
			this.ptitle.style["border"]="0px solid red"; 
			if ( this.titlecolor ) { this.ptitle.style["backgroundColor"]= this.bgcolor;  }
			//this.ptitle.style["z-index"]="106";   
			
			 this.ptitle.style["position"] = "relative";//this.ptitle.style["left"] = "2px"; this.ptitle.style["top"] = "5px";
			 //this.ptitle.style["text-align"] = "center"; 
			 this.ptitle.innerHTML =  this.titletext;
	} // end if shadow	
	
		this.pbody = document.createElement("div");
				this.pbody.id = "pbody-"+this.panelname; this.pbody.name = "pbody-"+this.panelname;
				this.pbody.style["width"] = this.width; this.pbody.style["height"]="auto"; 
				//this.pbody.style["z-index"]="106";   
				
		this.pfooter = document.createElement("div");
				this.pfooter.id = "pfooter-"+this.panelname; this.pfooter.name = "pfooter-"+this.panelname;
				this.pfooter.style["width"] = this.width; this.pfooter.style["height"]="25px"; 	
				//this.pfooter.style["z-index"]="106";   	
} 
inlinePanelObject.prototype.render = function ( ) {
	if ( this.shadow ) {
	
		this.element.appendChild(this.outerdiv);
		this.outerdiv.appendChild(this.innerdiv);
		this.innerdiv.appendChild(this.ptitle);
		this.innerdiv.appendChild(this.pbody);
		this.innerdiv.appendChild(this.pfooter);			
	 
		
	}else{
		
		this.element.appendChild(this.innerdiv);
		//this.outerdiv.appendChild(this.innerdiv);
		this.innerdiv.appendChild(this.ptitle);
		this.innerdiv.appendChild(this.pbody);
		this.innerdiv.appendChild(this.pfooter);
	}
}
/*************************************
DOM OBJECT
author: Jamil HASSAN Spain
namespace: http://www.iqbs.biz
date: January 2007
*****************************************/
var DomObject = {
	showme:function ( name ) {
		if (!name) {
			alert(' You must define an element to use this class');	
		}else{
			$(name).style["display"] = "block";
		}
	},
	hideme:function ( name ) {
		if (!name) {
			alert(' You must define an element to use this class');	
		}else{
			$(name).style["display"] = "none";
		}		
	},
	fademe:function (el,color1,color2,time,frame) {
		if (!time){ var mytime = 5000; }else{ var mytime = time; }
		if (!frame){ var myframe = 30; }else{  var myframe = frame; }
		Fat.fade_element(el, myframe, mytime, color1, color2);		
	},
	replaceText:function (el,text) {
		if ( el ){
			this.clearText(el);
			var newNode = document.createTextNode(text);
			el.appendChild(newNode);
		}
	},
	getText:function (el) {
		  var text = "";
		  if (el != null) {
			if (el.childNodes) {
			  for (var i = 0; i < el.childNodes.length; i++) {
				var childNode = el.childNodes[i];
				if (childNode.nodeValue != null) {
				  text = text + childNode.nodeValue;
				}
			  }// end for
			}
		  }
		  return text;
	},
	clearText:function (el) {
		if (el != null) {
			if (el.childNodes) {
			  for (var i = 0; i < el.childNodes.length; i++) {
				var childNode = el.childNodes[i];
				el.removeChild(childNode);
			  }
			}
		}
	},
	detectIE:function(){
	   if(navigator.appName == "Microsoft Internet Explorer"){
		  return true;
	   }else{
		  return false;
	   }	
	},
	removePanel:function(target,inside){
	 	$(target).removeChild($(inside));	
	}
	
}		 

// @name      The Fade Anything Technique
// @namespace http://www.axentric.com/aside/fat/
// @version   1.0-RC1
// @author    Adam Michela
var Fat = {
	make_hex : function (r,g,b) 
	{
		r = r.toString(16); if (r.length == 1) r = '0' + r;
		g = g.toString(16); if (g.length == 1) g = '0' + g;
		b = b.toString(16); if (b.length == 1) b = '0' + b;
		return "#" + r + g + b;
	},
	fade_all : function ()
	{
		var a = document.getElementsByTagName("*");
		for (var i = 0; i < a.length; i++) 
		{
			var o = a[i];
			var r = /fade-?(\w{3,6})?/.exec(o.className);
			if (r)
			{
				if (!r[1]) r[1] = "";
				if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
			}
		}
	},
	fade_element : function (id, fps, duration, from, to) 
	{
		if (!fps) fps = 30;
		if (!duration) duration = 3000;
		if (!from || from=="#") from = "#FFFF33";
		if (!to) to = this.get_bgcolor(id);
		
		var frames = Math.round(fps * (duration / 1000));
		var interval = duration / frames;
		var delay = interval;
		var frame = 0;
		
		if (from.length < 7) from += from.substr(1,3);
		if (to.length < 7) to += to.substr(1,3);
		
		var rf = parseInt(from.substr(1,2),16);
		var gf = parseInt(from.substr(3,2),16);
		var bf = parseInt(from.substr(5,2),16);
		var rt = parseInt(to.substr(1,2),16);
		var gt = parseInt(to.substr(3,2),16);
		var bt = parseInt(to.substr(5,2),16);
		
		var r,g,b,h;
		while (frame < frames)
		{
			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
			h = this.make_hex(r,g,b);
		
			setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);

			frame++;
			delay = interval * frame; 
		}
		setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
	},
	set_bgcolor : function (id, c)
	{
		var o = document.getElementById(id);
		o.style.backgroundColor = c;
	},
	get_bgcolor : function (id)
	{
		var o = document.getElementById(id);
		while(o)
		{
			var c;
			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			if (o.currentStyle) c = o.currentStyle.backgroundColor;
			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
			o = o.parentNode;
		}
		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
		return c;
	}
};
/*****************************************************
FORM OBJECT 
name: Jamil Hassan Spain
Date: Jan 2007
webspace: http://www.iqbs.biz
*****************************************************/
var FormObject = {
	validateEmail:function (noun) {
//		alert(noun);	
		if ( noun == '' ){
			return ('Email Address Field is Blank!\n\n');
		}else{

		var atcount = noun.split("@");
		
		if ( atcount.length == 2 ){
			var domain = atcount["1"].split(".");
			if ( domain.length >= 2 ){  return ''; }else{ return ('Invalid Email Address -- Missing Email Address Ending!\n\n'); }
		}else{
			return ('Invalid Email Address -- Missing @ sign!\n\n');   
		}

		}
	}, 
	validateValue:function (noun,errortext) {
		if ( noun == '' ) { return errortext; }else{ return ''; }
	}
}

