function gup(query,name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( query );
  if( results == null )
    return "";
  else
    return results[1];
}

//////////////////////////////////////////////////////////////////////////////////////////////
// SHOW POP-OVER
//////////////////////////////////////////////////////////////////////////////////////////////
// LOAD SCREEN ATTRIBUTES
var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;
function loadScreen() {
	if (document.all) {
		// IE
		myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		// NON-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	}
	if (window.innerHeight && window.scrollMaxY) {	
		// NON-IE
        myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { 
		// IE
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	} else { 
		// IE MAC
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}

function showToGo2(roverurl) {
	/* Parse the rover url */
	icep_item = gup(roverurl, 'icep_item');
	campid = gup(roverurl, 'campid');
	//alert(campid); // for testing
	customid = gup(roverurl, 'customid');
	//alert(customid);  // for testing

	// LOAD THE VIEW SIZE + SCROLL POSITION
	loadScreen();
	
	// SHOW THE INNER DIV
	oDiv = document.getElementById('ToGoDiv2');
	oDiv.style.display = 'block';
    oDiv.innerHTML = '<object width="568" height="480">' + 
				   '<param name="movie" value="http://togo.ebay.com/togo/togo.swf?2008013100" />' +
				   '<param name="flashvars" value="base=http://togo.ebay.com/togo/&lang=en-us&mode=normal' + 
				   '&itemid=' + icep_item + '&campid=' + campid + '" />' +
				   '<embed src="http://togo.ebay.com/togo/togo.swf?2008013100" type="application/x-shockwave-flash" width="568" height="480" flashvars="base=http://togo.ebay.com/togo/&lang=en-us&mode=normal' + 
				   '&itemid=' + icep_item + '&campid=' + campid + '" />' + 
				   '</embed>' + '</object>';

	oDiv = document.getElementById('OuterToGoDiv2');
	oDiv.style.display = "block";
	
	// SET THE DIV POSITION
	oDiv.style.left = ((myWidth / 2)-(oDiv.offsetWidth / 2))+"px";
	oDiv.style.top =  ((myHeight / 2)-(oDiv.offsetHeight / 2)+myScroll)+"px";
	
	return false;
}

// CLOSE POP-OVER
function hideToGo2() {
	// HIDE THE DIV
	oDiv = document.getElementById('OuterToGoDiv2');
	oDiv.style.display = "none";
	return false;
}
