/***************************************************** 
                    scripts.js
*****************************************************/
var isDeploy = true;
var baseUrl = window.location.protocol + "//" + window.location.host;
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

// if region cookie is not set, go get one
goGetCookie();

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function getBaseDir(){
	var baseDir = '';
	if (isDeploy) baseDir = baseUrl + '/us/';
	else          baseDir = baseUrl + '/';	
	return baseDir;  
}

/***************************************************** 
         Image Swapping Utility Used On:
					      - /products/boards.html
					      - /sales/products/boards_sales.html
						  - /products/accessories.html
*****************************************************/

function getProducts(){
	var productsResDir = getBaseDir() + 'products/res/';
	var salesResDir    = getBaseDir() + 'sales/products/res/';
	
	if(!document.products) {
		document.products = new Object();
		document.products.boards = new Object();
		document.products.boards_sales = new Object();
		document.products.accessories = new Object();
		 
		// boards.html
		var b = document.products.boards;
		var b_resDir = productsResDir + 'boards/';
		b.silver                   = b_resDir + 'silver-board.jpg';
		b.checker                  = b_resDir + 'checkers-board.jpg';
		b.sketch                   = b_resDir + 'sketch-board.jpg';
		b.red_and_silver           = b_resDir + 'red_silver-board.jpg';
		b.graffiti                 = b_resDir + 'grafitti-board.jpg';
		b.scrolls_and_skulls       = b_resDir + 'scrolls_and_skulls-board.jpg';
		b.hibiscus                 = b_resDir + 'hibiscus-board.jpg';
		b.black_and_white          = b_resDir + 'black_and_white-board.jpg';
		
		// boards_sales.html
		var b_sales = document.products.boards_sales;
		var b_salesResDir = salesResDir + 'boards/';
		b_sales.silver             = b_salesResDir + 'silver_board_sales.jpg';
		b_sales.checker            = b_salesResDir + 'checker_board_sales.jpg';
		b_sales.sketch             = b_salesResDir + 'sketchy_board_sales.jpg';
		b_sales.red_and_silver     = b_salesResDir + 'red_silver_board_sales.jpg';
		b_sales.graffiti           = b_salesResDir + 'graffiti_board_sales.jpg';
		b_sales.scrolls_and_skulls = b_salesResDir + 'scrolls_and_skulls_sales.jpg';
		b_sales.hibiscus           = b_salesResDir + 'hibiscus_board_sales.jpg';
		b_sales.black_and_white    = b_salesResDir + 'blackandwhite_board_sales.jpg';
		b_sales.green              = b_salesResDir + 'green_board_sales.jpg';
		
		// accessories.html
		var acc = document.products.accessories;
		var accResDir = productsResDir + 'accessories/';
		
		acc.deckplates           = new Object();
		acc.helmets_orange_green = new Object();
		acc.helmets_black        = new Object();
		acc.bags                 = new Object();
		acc.wheels_black         = new Object();
		acc.wheels_pink          = new Object();
		acc.wheels_green         = new Object();
		acc.wheels_red           = new Object();
		
		acc.deckplates.image = accResDir + 'deckplates.jpg';
		acc.deckplates.descr = '<h3><img src="res/accessories/titles/title-deckplates.png" alt="Street Surfing Deck Plates for The Wave" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>Now you can upgrade your Wave board with our new line of deck plate sets.  Each set comes with instructions and mounting screws.  Just think of it as &ldquo;bling for your board&rdquo;!</p>';
		
		acc.helmets_orange_green.image    = accResDir + 'helmets_orange_green.jpg'; 
		acc.helmets_orange_green.descr    = '<h3><img src="res/accessories/titles/title-helmets.png" alt="Signature Street Surfing Helmets" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>We, at Street Surfing, want to keep riders safe whenever they ride The Wave.  That is why we developed our own CPSC approved helmet.  Use it when riding The Wave, or any other skate product.  It has a comfortable fit with an adjustable chin strap and plenty of vents to keep your head cool while riding.  Outrageous graphics keep this helmet a &ldquo;head&rdquo; of the crowd.</p>';
		
		acc.helmets_black.image    = accResDir + 'helmets_black.jpg'; 
		acc.helmets_black.descr    = '<h3><img src="res/accessories/titles/title-helmets.png" alt="Signature Street Surfing Helmets" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>We, at Street Surfing, want to keep riders safe whenever they ride The Wave.  That is why we developed our own CPSC approved helmet.  Use it when riding The Wave, or any other skate product.  It has a comfortable fit with an adjustable chin strap and plenty of vents to keep your head cool while riding.  Outrageous graphics keep this helmet a &ldquo;head&rdquo; of the crowd.</p>';
		
		acc.bags.image       = accResDir + 'bags.jpg'; 
		acc.bags.descr       = '<h3><img src="res/accessories/titles/title-bags.png" alt="Street Surfing Carry Bags" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>Take The Wave wherever you go and carry it around in style. The Wave carry bags make it so easy to carry The Wave and they look good, too. The bags even have a place to hold a cell phone or mp3 player.  Bags come in two styles, classic black and red and a grey camouflage.  Check them out in the StreetSurfing online store.</p>'; 
		
		acc.wheels_black.image = accResDir + 'wheels_black.jpg';
		acc.wheels_black.descr = '<h3><img src="res/accessories/titles/title-wheels.png" alt="Black Street Surfing Wheels for The Wave" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>Street Surfing wheels look good and feel good too. &nbsp;They are specially made for optimum performance of the Wave and will last longer than the average inline skate wheel. Each pair of wheels comes with ABEC 5 bearings and wheel spacers. </p>';
		
		acc.wheels_pink.image = accResDir + 'wheels_pink.jpg';
		acc.wheels_pink.descr = '<h3><img src="res/accessories/titles/title-wheels.png" alt="Pink Street Surfing Wheels for The Wave" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>Street Surfing wheels look good and feel good too. &nbsp;They are specially made for optimum performance of the Wave and will last longer than the average inline skate wheel. Each pair of wheels comes with ABEC 5 bearings and wheel spacers. </p>';
		
		acc.wheels_green.image = accResDir + 'wheels_green.jpg';
		acc.wheels_green.descr = '<h3><img src="res/accessories/titles/title-wheels.png" alt="Green Street Surfing Wheels for The Wave" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>Street Surfing wheels look good and feel good too. &nbsp;They are specially made for optimum performance of the Wave and will last longer than the average inline skate wheel. Each pair of wheels comes with ABEC 5 bearings and wheel spacers. </p>';
		
		acc.wheels_red.image = accResDir + 'wheels_red.jpg';
		acc.wheels_red.descr = '<h3><img src="res/accessories/titles/title-wheels.png" alt="Red Street Surfing Wheels for The Wave" width="229" height="37" style="margin-left:-5px;" onload="fixPNG(this)"></h3><p>Street Surfing wheels look good and feel good too. &nbsp;They are specially made for optimum performance of the Wave and will last longer than the average inline skate wheel. Each pair of wheels comes with ABEC 5 bearings and wheel spacers. </p>';
		
	} else {
	  // fall through
	}
	return document.products;
}		
function initProductsPage(type){
	var inProduct = getProductFromURL();
	var page_type = getPageType();
	var products = getProducts();
	
	// preload all the images for this page_type for fast switching
	if(page_type == 'accessories'){
		// go one level deeper to get image paths out of object
		for ( var node in products[page_type] ){
		  preloadImages(products[page_type][node].image);
		}
	} else {		
		for( var img in products[page_type]){
			preloadImages(products[page_type][img]);
		}		
	}
	// if theres a product definition riding in the url, set it here
	if (inProduct){ swapProduct(inProduct); }
	else { setDefaultProduct(page_type);	}
}
function swapProduct(inProduct){
	var page_type = getPageType();
	var products = getProducts();	
	var cont = getContainer();
	
	if(page_type == 'accessories'){
		var cont_2 = document.getElementById('bottom_panel_left');
		cont.innerHTML = '<img src="'+products[page_type][inProduct].image+'" width="720" height="215" />';
		cont_2.innerHTML = products[page_type][inProduct].descr;
	} else {
		cont.innerHTML = '<img src="'+products[page_type][inProduct]+'" width="720" height="215" />';
	}
}

function getContainer(){
	var cont = document.getElementById('productContainer');
	return cont;
}
function setContainer(){
	var cont = getContainer();
	cont.style.width = "720px";
	cont.style.height = "215px";
	cont.align = "center";
	return cont;
}
function setDefaultProduct(page_type){
	var cont = getContainer();
	var path = location.pathname;
	var default_image = "";
	
	switch(page_type){
		case 'boards':
		  default_image = 'res/boards/silver-board.jpg';
			cont.innerHTML = '<img src="'+ default_image +'" width="720" height="215" />';
			break;	
		case 'boards_sales':
		  default_image = 'res/boards/silver_board_sales.jpg';
			cont.innerHTML = '<img src="'+ default_image +'" width="720" height="215" />';
			break;	
		case 'accessories':
		  var def = document.products.accessories.deckplates;
		  var cont_2 = document.getElementById('bottom_panel_left');
			cont.innerHTML = '<img src="'+ def.image +'" width="720" height="215" />';
			cont_2.innerHTML = def.descr;
			break;	
		default:	
		  console.log('this page type has not been defined yet');
			break;
	}
	
}
function getProductFromURL(){
	// check for url argument specifying which board  or product we have
	// i.e. takes '?board=green' and splits it up to return 'green'
  var args = new Object;
	var query = location.search.substring(1);
	var pos = query.indexOf('=');
	var argName = query.substring(0, pos);
	var value = query.substring(pos+1);
	if (argName == 'board' || argName == 'prod'){ return value; }
	else { return null; }
}
function getPageType(){
	var path = location.pathname;
	var page_type = '';
	if(path.search(/boards.html/i) > 0){	page_type = 'boards'; }	
	else if (path.search(/boards_sales.html/i) > 0){ page_type = 'boards_sales';	}	
	else if (path.search(/accessories.html/i) > 0){ page_type = 'accessories';	}	
	else { console.log('getPageType -> page type unknown'); }
	return page_type;
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}
/***************************************************** 
                 index.html
*****************************************************/

function twinersPreload(){ 
	var args = twinersPreload.arguments;
	if(document.imageArray){
		var oldPos = document.imageArray.length;
	  var newArgs = args.length;
		var msg = '';
		var counter = oldPos + newArgs;
		//alert('oldPos: ' + oldPos + '\nnewArgs: ' + newArgs + '\ncounter: ' + counter);
		for(var i=oldPos; i< counter; i++){
			document.imageArray[i] = new Image;
			document.imageArray[i].src = args[i];
			//msg += 'i: ' + i + '\n';
		}
		//alert(msg);
	} else {
		document.imageArray = new Array(args.length);
		for(var i=0; i<args.length; i++){
			document.imageArray[i] = new Image;
			document.imageArray[i].src = args[i];
		}
	}
	return true;
}
function getRegion(){
// get the value of the region cookie
	var allCookies = document.cookie;
	var pos = allCookies.indexOf("region=");
	if(pos != -1){
	  var start = pos + 7;                        	// start of cookie value
		var end = allCookies.indexOf(";", start);   	// end of cookie value
		if(end == -1) end = allCookies.length;
		var value = allCookies.substring(start, end); // extract the value
		region = unescape(value);
		//alert(region);
	} else {
	  region = 'US';
	}
	return region;
}
// if there is no cookie, go to the region selection page
function goGetCookie(){
	var allCookies = document.cookie;
	var regionCookie = allCookies.indexOf("region=");	
	
	if(regionCookie != -1){
		// get the cookie value
		var start = regionCookie + 7;                	// start of cookie value
		var end = allCookies.indexOf(";", start);   	// end of cookie value
		if(end == -1) end = allCookies.length;
		var value = allCookies.substring(start, end); // extract the value
		region = unescape(value);
		
		// if US do nothing otherwise go to the php pages
		if (region == 'US'){
			// do nothing
		} else {
			location.replace('http://www.streetsurfing.com');
		}
	} else {
		location.replace('http://www.streetsurfing.com/src/php/setRegion.php?region=Reset');
	}
	
}
function initHome(){
	
	// NOTE: ititial image for img_container is set in main.css
	var baseDir   = getBaseDir();
	var regDir    = baseDir + "res/regular_pages/";
	var homeDir   = baseDir + "res/home_images/";
	var longDir   = baseDir + "res/long_pages/";
	var uiDir     = baseDir + "res/ui/";
	var bannerDir = baseDir + "res/banners/";
	
	document.rotationImages = new Array(homeDir+'01.jpg', 
																			 homeDir+'02.jpg',
																			 homeDir+'03.jpg',
																			 homeDir+'04.jpg',  
																			 homeDir+'05.jpg');
	document.currImage = 'a0';
	
	// first we make sure that the ui elements are loaded
	if(twinersPreload(uiDir+'gray_tile-16x16.png',
										 uiDir+'quicknav_bg.png',
										 uiDir+'image_controller.png')){
		// ...then we make sure that images are available for rotation
		twinersPreload(homeDir+'01.jpg', 
									 homeDir+'02.jpg', 
									 homeDir+'03.jpg', 
									 homeDir+'04.jpg',
									 homeDir+'05.jpg');
	}
	// begin the process of rotating the home images
  document.counter = 1;
	var selected = document.getElementById(document.currImage).style;
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
	  selected.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../res/ui/quicknav_bg.png', sizingMethod='scale')";
	} else {
	  //alert("setting bg img");
		selected.backgroundImage = "url(../res/ui/quicknav_bg.png)";
	}
	addLinkArea();
	startAutoSwap();
}
function initPage(pgType, img){	
  // random image selector
	var baseDir = getBaseDir();
	var images, container, dir, rand;
	
	switch(pgType){
	  case 'regular':
			dir = baseDir + "res/regular_pages/";
		  container = document.getElementById('img_container');
			images = new Array('001.jpg', '002.jpg', '003.jpg', '004.jpg', '005.jpg',
												  '006.jpg', '007.jpg', '008.jpg');
			break;
	  case 'long':
			dir = baseDir + "res/long_pages/";
		  container = document.getElementById('img_containerLong');
			images = new Array('004_fade.jpg', 'how_to_ride-tips.jpg', 'how_to_ride-tips02.jpg', 'how_to_ride-tricks.jpg', 'how_to_ride-video.jpg', 'carry_bags_bg.jpg', 'press_room.jpg');
		  break;
		case 'mail':
		  dir = baseDir + "res/mail_pages/";
		  container = document.getElementById('img_container');
			break;			
	}
	// if img is specified, don't use a random image
	if(img){
		if(pgType == 'mail'){
			setBanner();
			return;
		}	else {	
			container.style.backgroundImage = "url("+dir+img+")";
		}
	}	else {
		rand = Math.floor(Math.random() * (images.length));
		container.style.backgroundImage = "url("+dir+images[rand]+")";
	}
	setBanner();
}
function setBanner(){
	var baseDir = getBaseDir();
  var banner = document.getElementById('flash_banner');
	var dir = baseDir + "res/banners/";
	var images = new Array('board.jpg', 'boarding.jpg', 'plain.jpg', 'wave.jpg');
	var rand = Math.floor(Math.random() * (images.length));
	banner.innerHTML = '<img src="'+dir+images[rand]+'">';
	if (document.all) banner.style.cursor = 'hand';
  else banner.style.cursor = 'pointer';
	banner.onclick = function(){
	  top.location.href = baseDir +'index.html';
	}
}	
function addLinkArea(){
	var baseDir   = getBaseDir();
	var homeDir   = baseDir + "res/home_images/";
	var container = document.getElementById('img_container');
	var oldLinkDiv;
	if(oldLinkDiv = document.getElementById('linkDiv')){
		container.removeChild(oldLinkDiv);
	}
	// get the index value of the currImage and look up its path from the rotationImages array
	var index = new String(document.currImage);
	var pos = index.charAt(1);
	var channel = document.rotationImages[pos];
	
	// get the value of the region cookie
  var region = getRegion();

	// state which images have linkAreas on them here
	// order of values for image maps: top, left, height, width
	switch (channel){
	   case homeDir+'01.jpg': 
		  // link to...
			//generateLinkArea(container, '0px', '25px', '260px', '440px', 'http://www.streetsurfing.com/cart/index.php?main_page=product_info&cPath=1&products_id=55', true);
		  break;	
		case homeDir+'02.jpg':
		  // link visitor to wave product page
			generateLinkArea(container, '-100px', '25px', '150px', '440px','http://www.whiplashscooter.com/', true);
			break;
		case homeDir+'03.jpg':
		  // link visitor to team page
			generateLinkArea(container, '-100px', '300px', '450px', '590px','/fun/team.html', false);
			break;
		case homeDir+'04.jpg':
		  // link visitor to team page
			generateLinkArea(container, '-0px', '25px', '200px', '440px', 'products/wavelx.html', true);
			break;
		case homeDir+'05.jpg':
		  // link visitor to video page
			generateLinkArea(container, '-50px', '300px', '400px', '580px', 'http://www.streetsurfing.com/cart/', true);
			break;
		default:
		  // do nothing
			break;
	}
}
function generateLinkDiv(id, divLink, color, overColor, width, border, padding){
  var linkDiv = document.getElementById(id);
	linkDiv.onclick = function(){ location.href = divLink;}
  linkDiv.onmouseover = function(){
		if (document.all) linkDiv.style.cursor = 'hand';
		else linkDiv.style.cursor = 'pointer';
		linkDiv.style.backgroundColor = overColor;
  }
	linkDiv.onmouseout = function(){ linkDiv.style.backgroundColor = color; }
  if(color) linkDiv.style.backgroundColor = color;
	if(width) linkDiv.style.width = width;
	if(border) linkDiv.style.border = border;
	if(padding) linkDiv.style.padding = padding;
		  
}
function generateLinkArea(container, top, left, height, width, inPath, isAbsolute){
	var baseDir = getBaseDir();	
	var path = "";
	if (isAbsolute){ 	path = inPath; } 
	else { path = baseDir + inPath; }
	
	var linkDiv = document.createElement('div');
	var linkDivStyle = linkDiv.style;
	linkDiv.id = 'linkDiv';
	linkDivStyle.position = 'relative';
	linkDivStyle.top = top;
	linkDivStyle.left = left;
	linkDivStyle.height = height;
	linkDivStyle.width = width;
	
	//linkDivStyle.border = '1px solid white';
	
	if (document.all) linkDivStyle.cursor = 'hand';
  else linkDivStyle.cursor = 'pointer';
	
	linkDiv.onclick = function(){
		if(isAbsolute){
			// spawn an entirely new window - currently used for the myspace link
			window.open(path);
		} else {
		  location.href = path;
		}
	}
	linkDiv.onmouseover = function(){
	  window.status = path;
	}
	container.appendChild(linkDiv);
}
function startAutoSwap(){
	document.intervalID = setInterval('autoSwap()', 5000);
}
function autoSwap(){
  var msg = document.getElementById('msg');
	var imgCSS = document.getElementById('img_container').style;
	var counter = document.counter;
	imgCSS.backgroundImage = 'url('+document.rotationImages[document.counter]+')';
	
	var oldBttn = document.currImage;
	document.currImage = 'a'+document.counter;
	var newBttn = document.currImage;
	
	selectImgBttn(oldBttn, newBttn);
	
	addLinkArea();
	
	document.counter++;
	if(document.counter == document.rotationImages.length) document.counter = 0;
}
function swap(id, pos){
	clearInterval(document.intervalID); // disable autoSwap
	if(document.timer) clearTimeout(document.timer);
	
	var imgCSS = document.getElementById('img_container').style;
	imgCSS.backgroundImage = 'url('+document.rotationImages[pos]+')';
	
	var oldId = document.currImage;
	if(oldId != id){
		var newId = id;
		document.currImage = newId;
		document.counter = pos;
		addLinkArea();
			
		selectImgBttn(oldId, newId);
	}
	//document.timer = setTimeout('startAutoSwap()', 10000);  // resumes autoSwap
}
function selectImgBttn(oldId, newId){
	var unSel_ImgPath = "/res/ui/gray_tile-16x16.png";
	var sel_ImgPath   = "/res/ui/quicknav_bg.png";
	var oldBttn       = document.getElementById(oldId);
	var newBttn       = document.getElementById(newId);
	var oldBttnStyle  = document.getElementById(oldId).style;
	var currBttnStyle = document.getElementById(newId).style;
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
		oldBttnStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+baseUrl+unSel_ImgPath+"', sizingMethod='scale')";
		currBttnStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+baseUrl+sel_ImgPath+"', sizingMethod='scale')";
	} else {	
		oldBttnStyle.backgroundImage = "url("+baseUrl+unSel_ImgPath+")";
		currBttnStyle.backgroundImage = "url("+baseUrl+sel_ImgPath+")";
	}
  oldBttn.onmouseover = function(){
	  oldBttnStyle.backgroundImage = "url("+baseUrl+sel_ImgPath+")";
		if (document.all) oldBttnStylee.cursor = 'hand';
		else oldBttnStyle.cursor = 'pointer';
	}
	oldBttn.onmouseout = function(){
		if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
			oldBttnStyle.backgroundImage = "url("+baseUrl+unSel_ImgPath+")";
		} else {
			oldBttnStyle.backgroundImage = "url("+baseUrl+unSel_ImgPath+")";
		}
	}
	newBttn.onmouseout = function(){
	  // don't let us the oldBttn.onmouseout persist
	}
}
function popUpWindow(URLStr, left, top, width, height){
	if(popUpWin){if(!popUpWin.closed) popUpWin.close();}
	popUpWin = window.open('', 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

	var d = popUpWin.document;
	d.write('<html>'+'<head>'+ '<title>Street Surfing Action Photos</title>'+
			 '</head>'+
			 '<body bgcolor="#000" marginheight="0" marginwidth="0">'+
			 '<div align="center">' +
			 '  <div> '+
			 '	<img src="/res/popups/popup_header.jpg" alt="Photo Gallery" width="600" height="69" /> '+
			 '  </div> '+
			 '  <img src="'+URLStr+'" alt="Photo Gallery" style="border: 1px solid white;"/> '+
			 '</div>'+
			 '<div align="center">'+
			 '  <input type="button" name="Button" value="Close" onclick="self.close()" />'+
			 '</div>'+
			 '</body>'+'</html>'); 
	d.close();
}

function popUpWinRipple(URLStr, left, top, width, height){
	if(popUpWin){if(!popUpWin.closed) popUpWin.close();}
	popUpWin = window.open('', 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

	var d = popUpWin.document;
	d.write('<html>'+'<head>'+ '<title>Ripple Photo Gallery</title>'+
			 '</head>'+
			 '<body bgcolor="#000" marginheight="0" marginwidth="0">'+
			 '<div align="center">' +
			 '  <div> '+
			 '	<img src="../res/popups/popup_header.jpg" alt="Photo Gallery" width="600" height="69" /> '+
			 '  </div> '+
			 '  <img src="'+URLStr+'" alt="Photo Gallery" style="border: 1px solid white;"/> '+
			 '</div>'+
			 '<div align="center">'+
			 '  <input type="button" name="Button" value="Close" onclick="self.close()" />'+
			 '</div>'+
			 '</body>'+'</html>'); 
	d.close();
}

function fixPNG(myImage){
	if ((version >= 5.5) && (version < 7) && (document.body.filters)){
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
		var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";
		var imgStyle = "display:inline-block;" + myImage.style.cssText;
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
						+ " style=\"" + "width:" + myImage.width 
						+ "px; height:" + myImage.height 
						+ "px;" + imgStyle + ";"
						+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
						+ "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
		myImage.outerHTML = strNewHTML;
	}
}