function rollover(img) {
      var height = img.style.height;
      var left = img.style.backgroundPosition.substring(0,img.style.backgroundPosition.indexOf(" "));
      img.style.backgroundPosition = left + ' -'+(parseFloat(height)+2)+'px';
   }

   function rollout(img) {
      var left = img.style.backgroundPosition.substring(0,img.style.backgroundPosition.indexOf(" "));
      img.style.backgroundPosition = left + ' -1px';
   }

   function isselected(img) {
      var left = img.style.backgroundPosition.substring(0,img.style.backgroundPosition.indexOf(" "));
      return (left != "-1px");
   }

   function toggleSelect(img) {
    if (isselected(img)) {
      deselect(img);
    }
    else {
      select(img);
    }
   } 
   
   function select(img) {
      var top = img.style.backgroundPosition.substring(img.style.backgroundPosition.indexOf(" "));
      var width = img.style.width;
      img.style.backgroundPosition = '-'+(parseFloat(width)+2)+'px ' + top;
   }

   function deselect(img) {
      var top = img.style.backgroundPosition.substring(img.style.backgroundPosition.indexOf(" "));
      img.style.backgroundPosition = '-1px' + top;
   }
   
   function oldselect(img) {
      img.src = img.src.replace("builder3","selected");
   }

   function olddeselect(img) {
	img.src = img.src.replace("selected","builder3");
   }

   function selectOnly(img) {
      deselectGroup(img.className);
      select(img);
   }
   
   function deselectGroup(groupName) {
/*
     deselect("Button_Tab_Gallery");
     deselect("Button_Tab_Feedback");
     deselect("Button_Tab_MyPockets");
     deselect("Button_Tab_Builder");
     deselect("Button_Tab_Faqs");
     
     return;
*/

     var selector = '.'+groupName;
     //alert('xx selector is <'+selector+'>');
     var myGroup=jQuery(selector);
     //alert('myGroup is <'+myGroup+'>');

     jQuery.each(myGroup, function() {
        deselect(this);
     });
  }
  
  function expand(elementID,callback) {
    
     var internalElement = document.getElementById(elementID+"_internal"); 
     sizeToTarget(callback,elementID,internalElement.style.width,internalElement.style.height);
  }
  
  function toggleResize(elementID,callback,width1,height1,width2,height2) {
         var element = document.getElementById(elementID);
         if (element.style.width.replace("px","") == width1 &&
             element.style.height.replace("px","")== height1 ) {
            resize(elementID,callback,width2,height2);
         }
         else {
            resize(elementID,callback,width1,height1);
         }
  }
  
  function resize(elementID,callback,width,height) {
      sizeToTarget(callback,elementID,width,height);
   }
  
  function sizeToTarget(callback,elementID,width,height) {     
      var element = document.getElementById(elementID);
      
      var moving = false;

      if (element.style.width.replace("px","") < width) {
         moving = true;
         element.style.width = (element.style.width.replace("px","") + 5) + "px";
      }
      if (element.style.width.replace("px","")  > width) {
         moving = true;
         element.style.width = (element.style.width.replace("px","") - 5) + "px";
      }
      if (element.style.height.replace("px","")  < height) {
         moving = true;
         element.style.height = (element.style.height.replace("px","") + 5) + "px";
      }
      if (element.style.height.replace("px","")  > height) {
         moving = true;
         element.style.height = (element.style.height.replace("px","") - 5) + "px";
      }

      if (moving == true) {
         tid=setTimeout(function(){sizeToTarget(callback,elementID,width,height)},1);
      }
      else {
         element.style.height = height + "px";
         element.style.width = width + "px";
         //callback
      }
      
  }

  function rollover_old(obj) {
    obj.style.backgroundImage = obj.style.backgroundImage.replace("builder3","over");
}

function rollout_old(obj) {
    obj.style.backgroundImage = obj.style.backgroundImage.replace("over","builder3");
}

function hide(obj) {
    obj.style.opacity = 0.0;
    obj.style.zIndex = -2;
    obj.style.filter = 'alpha(opacity=0)';
    obj.style.display = 'none';
}

function show(obj) {
    obj.style.opacity = 1.0;
    obj.style.zIndex = 2;
    obj.style.filter= 'alpha(opacity=100)';
    obj.style.display = 'block';
}

function isVisible(obj) {
    return obj.style.opacity == 1.0;
}


var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag="";
var x,y;
var dragging_obj;

function movemouse(e)
{
  if (isdrag == "Dragging")
  {
    dragging_obj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dragging_obj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    return false;
  }
}

function selectmouse(e) 
{

  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "HTML";

  while (fobj.tagName != topelement && fobj.className.search("Draggable") == -1 )
  {
    if (fobj.tagName == "TEXTAREA") return;
    if (fobj.tagName == "INPUT") return;
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }

  if (fobj.className.search("Draggable") != -1 )
  {
    isdrag = "Dragging";
    dragging_obj = fobj;
    tx = parseInt(dragging_obj.style.left+0);
    ty = parseInt(dragging_obj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }

}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=''");

/* Client-side access to querystring name=value pairs
    Version 1.2.4
    30 March 2008
    Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
    this.params = {};
    this.get=Querystring_get;

    if (qs == null);
        qs=location.search.substring(1,location.search.length);

    if (qs.length == 0) 
        return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
    qs = qs.replace(/\+/g, ' ');
    var args = qs.split('&'); // parse out name/value pairs separated via &

// split out each name=value pair
    for (var i=0;i<args.length;i++) {
        var pair = args[i].split('=');
        var name = unescape(pair[0]);

        var value = (pair.length==2)
            ? unescape(pair[1])
            : name;

        this.params[name] = value;
    }
}

function Querystring_get(key, default_) {
    var value=this.params[key];
    return (value!=null) ? value : default_;
}
