var expanded = false;
var maxY=400;
var f = 0;
var g = 0;
var speed = 8;
var x = 180;
var y = maxY;
var w = 500;
var h = 100;
var ru = '';

N=window.navigator.appName.substring(0,8);
function init()
{
dd=document;
ww=window;

if(N=="Microsof"){w=dd.body.clientWidth;h=document.body.clientHeight;}
if(N=="Netscape"){w=ww.innerWidth;h=window.innerHeight;}

w = w - 30;

if (w > 1000)
{
   w = 990;
}

}


function changewidth(){

	if(x>(w)&&f==0){f=1; expandView(); return;}
	if(x<181&&f==1){f=0; compactView(); return;}

	if(f)q=-speed;if(!f)q=speed;x=x+q;
	e=document.getElementById("viewingBowl");
	e.style.width = x + 'px';
	c=document.getElementById("bowlCount");
	c.style.width = x + 'px';

	vb=document.getElementById("vbContent");
	vb.style.width = (x - 17) + 'px';

	t=setTimeout("changewidth();",0);
}

function changeheight(){
 	if(y>(maxY+1)&&g==0){g=1; expandView(); return;}
 	if(y<181&&g==1){g=0; compactView(); return;}
 	if(g)q=-5;if(!g)q=5;y=y+q;
 	e=document.getElementById("viewingBowl");
 	e.style.height = y + 'px';

 	vb=document.getElementById("vbContent");
 	vb.style.height = (y - 45) + 'px';


 	t=setTimeout("changeheight();",0);
}

function getElementById(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	}
	return null;
}

function compactView() {
	if (f == 0 || g == 0) {
		loadXMLDoc('/store/wishlist.php?view=0&ru=' + ru);
	}
}


function expandView() {

	if (f == 1 && g == 1) {
		loadXMLDoc('/store/wishlist.php?view=1&ru=' + ru);
	}

}


var req;

function loadXMLDoc(url) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
            var dom = req.responseXML;
            divs = dom.getElementsByTagName("Div");
            for (var i = 0; i < divs.length; i++) {
				var divId = divs[i].getAttribute("id");
				var nodeValue = "";
				divs[i].normalize();
				for (var idx = 0; idx < divs[i].childNodes.length; idx++) {
					var child =	divs[i].childNodes.item(idx);
					nodeValue += child.nodeValue;
				}
				var theDiv = getElementById(divId);
				
				if (theDiv != null) {
					theDiv.innerHTML = nodeValue;
				}
            }

        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}

var searchControls;
function toggleSearchControl() {
 	sd=document.getElementById("searchDiv");
	if (expanded) {
	  // expand
	  //sd.style.visibility = "hidden";
	  searchControls = sd.innerHTML;
	  sd.innerHTML = "";
	} else {
	  // compact
	  //sd.style.visibility = "visible";
	  if (searchControls != "")
	  	sd.innerHTML = searchControls;
	}
	vb=document.getElementById("vbContent");
	vb.innerHTML = "<div align=\"center\" style=\"padding-top: 20px\"><img src=\"/images/waiting.gif\"></div>";
}

function toggleSize() {
	expanded = !expanded;
	init();
	toggleSearchControl();
	changewidth();
	changeheight();
}

