var activeObjects = new Array();

var cssClass = Class.create();

cssClass.prototype = {

// init, call upon creation
initialize: function(){
// set unique ID
 this.objectID = activeObjects.length;
 // store object in list
 activeObjects[activeObjects.length] = this;
 // init element array
 this.elements = new Array();
},

////////////////////////////////////////////
//doc Function  name: position
//
//variables: id-> element to be positioned
//variables" type -> absolute or realtive
//variables" x, y -> positioning values
////////////////////////////////////////////
  position: function(id,type,x,y){
  if($(id)){
      var obj = $(id).style 
      obj.position = type;
      // set
      var str = String(x); 

      // check
      if( str.search("px") >= 0){
        // set left
        obj.left = x;    
      }
      else{
        // set left
        obj.left = x + "px";    
      }

      // set
      var str = String(y); 
      // check
      if( str.search("px") >= 0){
        // set left
        obj.top = y;    
      }
      else{
        // set left
        obj.top = y + "px";    
      }

    }else{
      alert(id + ': this element cant be positioned. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: dimension
//
//variables: id-> element to be positioned
//variables: width -> width of element
//variables: height-> height of element
//variables: z -> z-index of object
////////////////////////////////////////////  
  dimension: function(id,width,height,z){
      if($(id)){
      var obj=$(id).style
      // set
      var str = String(height); 
      // check if the field already includes the "px"
      if( str.search("px") >= 0){
        // set left
        obj.height = height;    
      }
      else{
        // set left
        obj.height = height + "px";    
      }

      // set
      var str = String(width); 
      // check if the field already includes the "px"
      if( str.search("px") >= 0){
        // set left
        obj.width = width;    
      }
      else{
        // set left
        obj.width = width + "px";    
      }

      if( (z!="") && (obj.zIndex != z) ){
        obj.zIndex = z;
      }else{
        z=0;
      }
    }
  },


////////////////////////////////////////////
//doc Function  name: fontStyle
//
//variables:String "id"-> element to be positioned
//variables:String "fontFamily"-> the name of the font to use
//variables:Integer "fontSize"-> sets the point size of the font
//variables:String "textAlign"-> sets the alignment of the text
//variables:String "fontStyle" -> sets the font style
//variables:String,Hexadecimal "color"-> sets the color of the text
////////////////////////////////////////////
  fontStyle: function(id,fontFamily,fontSize,textAlign,fontStyle,color,fontWeight){
    if($(id)){
      var obj=$(id).style
      if(fontFamily!=""){
        obj.fontFamily = fontFamily;
      }else{obj.fontFamily='times';}
      if(fontSize!=""){
        obj.fontSize = fontSize+'px';
      }else{obj.fontSize='12px';}  
      if(textAlign!=""){
        obj.textAlign = textAlign;
      }else{obj.textAlign='left';}  
      if(fontStyle!=""){
        obj.fontStyle = fontStyle;
      }else{obj.fontStyle='normal';} 
      if(color!=""){
        obj.color = color;
      }else{obj.fontStyle=color;} 
      if(fontWeight!=""){
        obj.fontWeight=fontWeight;
      }else{
        obj.fontWeight='normal';
      }  
    }else{alert('this element id does not exist');}
  },
////////////////////////////////////////////
//doc Function  name: colorBorder
//
//variables:String "id"-> element to be styled
//variables:String "background"-> the name of the font to use
//variables:Integer "color"-> sets the point size of the font
//variables:String "border"-> sets the alignment of the text
////////////////////////////////////////////
  colorBorder: function(id,background,color,border){
    if($(id)){
      var obj=$(id).style
      if(background!=""){
        obj.background = background;
      }else{obj.background='white';}
      if(color!=""){
        obj.color = color;
      }else{obj.color='black';}  
      if(border!=""){
        obj.border = border;
      }else{obj.border='';}  

      
    }else{alert('this element id does not exist');}
  },

////////////////////////////////////////////
//doc Function  name: border
//
//variables: id-> element to be positioned
//variables: width -> border width 
//variables: style-> border style
//variables: color -> border color
////////////////////////////////////////////  
  border: function(id,width,style,color){
    if($(id)){
      // get obj
      var obj=$(id).style;

      // set
      obj.borderWidth = width;
      obj.borderStyle = style;
      obj.borderColor = color;
    }
  },

// Retreival Functions

////////////////////////////////////////////
//doc Function  name: getXPosition
//
//variables: id-> element to be positioned
//returns: x position value without the "px" 
////////////////////////////////////////////
  getXPosition: function(id){
  if($(id)){
      var obj = $(id).style 
      // get left with "px"
      x = obj.left;    
      // trim off the "px"
      x = x.slice(0,x.length-2);
      // return  
      return(x);
    }else{
      alert(id + ': this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getYPosition
//
//variables: id-> element to be positioned
//returns: y position value without the "px" 
////////////////////////////////////////////
  getYPosition: function(id){
  if($(id)){
      var obj = $(id).style 
      // get left with "px"
      y = obj.top;    
      // trim off the "px"
      y = y.slice(0,y.length-2);
      // return  
      return(y);
    }else{
      alert(id + ': this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getWidth
//
//variables: id-> element to be positioned
//returns: width value without the "px" 
////////////////////////////////////////////
  getWidth: function(id){
  if($(id)){
      var obj = $(id).style 
      // get left with "px"
      width = obj.width;    
      // trim off the "px"
      width = width.slice(0,width.length-2);
      // return  
      return(width);
    }else{
      alert('this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getHeight
//
//variables: id-> element to be positioned
//returns: height value without the "px" 
////////////////////////////////////////////
  getHeight: function(id){
  if($(id)){
      var obj = $(id).style 
      // get left with "px"
      height = obj.height;

      // check
      if(height.search("px") >=0){
        // trim off the "px"
        height = height.slice(0,height.length-2);
      }
      // return
      return(height);
    }else{
      alert('this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getBorderWidth
//
//variables: id-> element to be positioned
//returns: border width value without the "px" 
////////////////////////////////////////////
  getBorderWidth: function(id){
  if($(id)){
      var obj = $(id).style 
      // get left with "px"
      var borderWidth = obj.borderWidth;    
      // trim off the "px"
      borderWidth = borderWidth.slice(0,borderWidth.length-2);
      // return  
      return(borderWidth);
    }else{
      alert('this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getZOrder
//
//variables: id-> element to be accessed
//returns: z index value 
////////////////////////////////////////////
  getZOrder: function(id){
  if($(id)){
      var obj = $(id).style 
      // return  
      return(obj.zIndex);
    }else{
      alert('this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getBGColor
//
//variables: id-> element to be positioned
//returns: height value without the "px" 
////////////////////////////////////////////
  getBGColor: function(id){
  if($(id)){
      var obj = $(id).style 
      // return  
      return(obj.backgroundColor);
    }else{
      alert('this element cant be accessed. Note: OptiWise should be included');
    }
  },

////////////////////////////////////////////
//doc Function  name: getFontSize
//
//variables: id-> element to be positioned
//returns: font size value without the "px" 
////////////////////////////////////////////
  getFontSize: function(id){
  if($(id)){
      var obj = $(id).style 
      // get left with "px"
      var fontSize = obj.fontSize;    
      // trim off the "px"
      var fontSize = fontSize.slice(0,fontSize.length-2);
      // return  
      return(fontSize);
    }else{
      alert('this element cant be accessed. Note: OptiWise should be included');
    }
  }
}