﻿   
function submitForm(pagename,rating)
{ 
  var pagepath="";
  var pathlist = window.location.pathname.split('/');
  if (window.location.hostname=="localhost")
  {
        pagepath="/" + pathlist[1];
  }
  else
  {
    pagepath="";
  }
  //var cookiepath = window.location.pathname.
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
  
    xhr.onreadystatechange  = function()
    { 
     closebar(pagename);
    }; 

   xhr.open('Post', pagepath +"/utility/surveyresults.aspx?pageid=" + pagename +"&pagerating=" + rating,  true); 
   xhr.send(null); 
} 
  
function closebar(path)
{
    if (persistclose)
        createCookie(path,'1','30','/')
    document.getElementById("footer2").style.visibility="hidden"
}

function createCookie(name,value,days,path) 
{
    if (days) 
    {
	    var date = new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
	    var expires = '; expires='+date.toGMTString();
    }
    else 
        var expires = '';
    document.cookie = name+'='+value+expires+'; path=' +path;
}

function get_cookie(Name) 
{
    var search = Name + '='
    var returnvalue = "";
    if (document.cookie.length > 0) 
    {
        offset = document.cookie.indexOf(search)
        if (offset != -1) 
        {
            offset += search.length
            end = document.cookie.indexOf(';', offset);
            if (end == -1) end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

// zoom code
function Zoomer (id,sWidth,sHeight,mWidth,mHeight) { 
    
    this.id = id; 
    this.handle = document.getElementById(id); 
    this.handle.style.visibility="visible";
    this.width=parseInt(this.handle.style.width);
    this.height=parseInt(this.handle.style.height);
    this.x = parseInt(this.handle.style.left); 
    this.y = parseInt(this.handle.style.top); 
    if (isNaN(this.y))
       this.y = parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - parseInt(100);
    this.dx  = 0; 
    this.dy  = 0; 
    this.ddx = 0; 
    this.ddy = 0; 
    this.minWidth=sWidth;
    this.maxWidth=mWidth;
    this.minHeight=sHeight;
    this.maxHeight=mHeight;
    //this.minx = parseInt(this.boundary.style.left); 
    //alert("minx: " + this.minx + " :: " + this.boundary.style.posLeft);
    //this.maxx = this.minx + (parseInt(this.boundary.style.width)-parseInt(this.handle.style.width)); 
    //alert("maxx: " + this.maxx);
    // + " :: " + this.boundary.style.posWidth-this.handle.style.posWidth);
    //this.miny = parseInt(this.boundary.style.top); 
    //alert("miny: " + this.miny);
    //alert("1:" + parseInt(this.boundary.style.height));
    //alert("2:" + parseInt(this.handle.style.height))
    //this.maxy = this.miny + (parseInt(this.boundary.style.height)-parseInt(this.handle.style.height)); 
	//alert("maxy: " + this.maxy);
    //alert( " this.maxx " +this.minx + "  " + this.boundary.style.left);
    //alert( " this.maxy " +this.miny);

    //alert ("this.boundary.style.posHeight: "+this.boundary.style.posHeight);
    //alert("this.handle.style.posHeight: "+this.handle.style.posHeight);
    this.place = function () { 
        this.handle.style.left=this.x; 
	    this.handle.style.top=this.y; 
        this.handle.style.width=this.width;
        this.handle.style.height=this.height;
    } 
    this.update = function () { 
        this.dx+=this.ddx; 
        this.dy+=this.ddy; 

        this.width+=this.dx; 
        this.height+=this.dy;
        
        //this.x-=parseInt(this.dx/2); 
        this.y-=parseInt(this.dy); 
        //this.x-=parseInt(this.dx/2); 
        //this.y-=parseInt(this.dy/2); 
		this.bounce(); 
        this.fit(); 
        this.place();     
    } 
    this.fit = function() { 
        if (this.width<this.minWidth) this.width=this.minWidth; 
        if (this.width>this.maxWidth) this.width=this.maxWidth; 
        if (this.height<this.minHeight) this.height=this.minHeight; 
        if (this.height>this.maxHeight) this.height=this.maxHeight; 
    } 
    this.bounce = function () { 
        if (this.width<this.minWidth && this.dx<0) this.dx=-this.dx+(this.dx*0.4); 
        if (this.height<this.minHeight && this.dy<0) this.dy=-this.dy+(this.dy*0.4); // damping factor
        if (this.width>this.maxWidth && this.dx>0) this.dx=-this.dx+(this.dx*0.4); 
        if (this.height>this.maxHeight && this.dy>0) this.dy=-this.dy+(this.dy*0.4); // damping factor
        
        if (Math.round(this.height)==this.maxHeight && this.dy<1)
        {
            //alert("finished");
            clearInterval (zoomInt);
        }

        //if (this.x<this.minx && this.dx<0) this.dx=-this.dx; 
        //if (this.y<this.miny && this.dy<0) this.dy=-this.dy+(this.dy*0.1); // damping factor
        //if (this.x>this.maxx && this.dx>0) this.dx=-this.dx; 
        //if (this.y>this.maxy && this.dy>0) this.dy=-this.dy+(this.dy*0.1); // damping factor
    } 
} 
function zoomit() { 
   window.ball.update(); 
} 
var zoomInt;
function expand() { 
   window.ball = new Zoomer("footer2",300,100,500,500); 
   window.ball.dx=5; 
   window.ball.dy=5; // initial velocity 
   window.ball.ddy=1; // initial gravity
   window.ball.ddx=1;
   window.ball.y += 0; 
   zoomInt = setInterval("zoomit();",10); 
   
} 
function shrink() { 
   window.ball = new Zoomer("footer2",500,500,300,100); 
   window.ball.dx=-5; 
   window.ball.dy=-5; // initial velocity 
   window.ball.ddy=-1; // initial gravity
   window.ball.ddx=-1;
   window.ball.y += 0; 
   zoomInt = setInterval("zoomit();",10); 
   
} 


