var ajaxLoaded = 0;
var ulistsLoaded = 0;

function addProdToList_callback(HtmlResp) {
   var my_overlay = document.createElement('div');
   my_overlay.setAttribute('id', 'overlay');
   var my_overlaybubble = document.createElement('div');
   my_overlaybubble.setAttribute('id', 'overlaybubble');
   my_overlaybubble.innerHTML = HtmlResp;
   document.body.appendChild(my_overlay);
   document.body.appendChild(my_overlaybubble);
   addProdToListPost();

}

function addProdToList() {
  if(!document.getElementById('overlaybubble')){
     ajax = new AjaxRequest('POST', '/ulists.php/bubbleContent', true, 3000);
     if(ulist_masterid>0){
        ajax.setParameter('masterid', ulist_masterid);
     }
     if(ulist_isbn>0){
        ajax.setParameter('isbn', ulist_isbn);
     }
     ajax.setResponseType('html');
     ajax.setCallback( addProdToList_callback );
     ajax.send();
   }else{
      addProdToListPost();
   }
}

function addProdToListPost() {
  is_modal = true;
  if(!ulistsLoaded) {
	var s2 = document.createElement('script'); s2.src = 'http://www.pricegrabber.com/js/ulists_from_prodpage.js.php?prodpage_lists_only=1';
	document.body.appendChild(s2);
  }
  if(!ajaxLoaded) {
	var s1 = document.createElement('script'); s1.src = 'http://ah.pricegrabber.com/js/classes/ajaxrequest.js';
	document.body.appendChild(s1);
  }
  waitForLoad();
}
function waitForLoad() {
	if(!ulistsLoaded) {
		if(window.ulists_js) { ulistsLoaded = 1; ShowListMessage('<img src="http://i.pgcdn.com/images/small_wait.gif" width=16 height=16>','Please hold while we process your request ...','#666666');}
		else { setTimeout('waitForLoad("");',200); return 0; }
	}
	if(!ajaxLoaded) {
		if(window.ajax) { ajaxLoaded = 1; }
		else { setTimeout('waitForLoad("");',200); return 0; }
	}
	if(ajaxLoaded && ulistsLoaded) { addToList(); }
}
function openBookmark(ut)
{
    var bkmrk="http://www.pricegrabber.com/?mode=bkmrk";
    var title="PriceGrabber.com - Shopping Comparison";
	window.external.AddFavorite(bkmrk,title);
	url = "/redirect_bookmark.php?ut="+ ut + "";	
	features = "toolbar=no,width=1,height=1,resizable=yes,bgcolor=#000000,scrollbars=no";
    window.name="bookmark";
	window.open( url, "", features );
}
function pg_openPromo(src) {
url = '/info_rebate.php?masterid='+src;
window.open(url, 'promo','height=450,width=550,innerHeight=450,innerWidth=550,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes');
}
function openSoundclips(masterid)
{
	url = "/info_soundclips.php?masterid=" + masterid + "";	
	features = "toolbar=no,width=500,height=450,resizable=yes,bgcolor=#000000,scrollbars=yes";
	window.open( url, "", features );
}
function openVideo( masterid )
{
	url = "/info_streaming.php?PublishedId=" + masterid;	
	features = "toolbar=no,width=300,height=285,resizable=yes,bgcolor=#000000,scrollbars=no";
    window.name="MyWindow";
	window.open( url, "", features );
}
function openlarge( masterid, big_x, big_y )
{
	url = "/info_picture.php?masterid=" + masterid;
	features = "toolbar=no,width=" + big_x + ",height=" + big_y + ",resizable=no,scrollbars=no";
	window.open( url, "techspecs"+masterid+"image", features );
}
function openptw( masterid, desc, topcat )
{
	if( desc )
	{
		url = "/info_ptw.php?masterid=" + masterid + "#description";
	}
	else
	{
		url = "/info_ptw.php?masterid=" + masterid + "&tab_id=" + topcat;	
	}
	features = "toolbar=no,width=540,height=450,resizable=yes,scrollbars=yes";
	window.open( url, "", features );
}
function opengetproddef(type)
{
	url = "/info_getproddef.php?type=" + type;
	features = "toolbar=no,width=400,height=275,resizable=yes,scrollbars=yes";
	window.open( url, "", features );
}
function open_def_win(type)
{
	url = "/info_minipage.php?type=" + type;
	features = "toolbar=no,width=500,height=250,resizable=yes,scrollbars=yes";
	window.open( url, "", features );
}
function openGetCoupon( coupon_id, masterid, redirurl )
{
        url = "/coupons_popup.php?coupon_id=" + coupon_id + "&masterid=" + masterid + "&url=" + redirurl;
		
		features = "toolbar=no,width=444,height=500,resizable=yes,scrollbars=yes";
		window.open( url, "", features );
}
function openGameTrailers( id )
{
  
	url = "/info_streaming_gt.php?gt_id=" + id;
	features = "toolbar=no,width=660,height=400,resizable=yes,bgcolor=#000000,scrollbars=no";
	window.open( url, "", features );
}
function attrib_toggles(subnum,subtype) { 
   if ( subtype == 'a' ) { 
      document.getElementById("sub" + subnum + "_a").style.display = "none"; 
	  document.getElementById("sub" + subnum + "_b").style.display = "block"; 	  
   } 
   else if ( subtype == 'b' ) { 
      document.getElementById("sub" + subnum + "_a").style.display = "block"; 
	  document.getElementById("sub" + subnum + "_b").style.display = "none"; 	  
   } 
}
