function switchImage(imgName, imgSrc){
	if (document.images){ 
		if (imgSrc != "none"){ 
			document.images[imgName].src = imgSrc; 
		} 
	}
} 

function browse(imgName){
	_openWindow('gallery.popup.html?imgName=' + imgName, 'PoolBrowser', 480, 264, 'no', 'no');
}

function browseWindow(imgName, width, height){
	_openWindow('gallery.popup.html?imgName=' + imgName, 'PromotionWindow', width, height, 'no', 'no');
}

function _openWindow(url, win, width, height, scroll, resize){
		var txt = "screenX=0,screenY=0,top=0,left=0,scrollbars="+scroll+",resizable="+resize+",status=no,width="+width+",height="+height;
        if(navigator.appName == "Netscape") {//moz
	        popWin = window.open(url,win,txt);
	        popWin.focus();
        }
        else{  //ie
	       if (navigator.userAgent.indexOf("MSIE 3") >= 0){ 
	           popWin = window.open(url,win,txt);
	           popWin.location.href = url;
	           //if (popWin.opener == null) popWin.opener = window; 
	           //popWin.opener.name = "opener";
			   popWin.focus();
	       }
	       else{
	           var popWin = window.open(url,win,txt);
			   popWin.focus();
	       }
       }       
}

function getImage(key){
	var keys 	= new Array();
	var values 	= new Array();
	var value 	= null;
	var query 	= window.location.search.substring(1);
	var pairs 	= query.split("&");
	
	for (var i=0; i < pairs.length; i++){
		var pos = pairs[i].indexOf('=');
		if (pos >= 0){
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			keys[keys.length] 		= argname;
			values[values.length] 	= value;		
		}
	}

	for (var i=0; i < keys.length; i++){
		if (keys[i] == key){
			value = values[i];
			break;
		}
	}
	return value;
}

function embedFlash(srcURL, swfName, imgUrl, swfbgColor, width, height, debug){
	if ((! hasPlugin()) || (debug == true)){
		if (imgUrl != ''){
			document.write('<img src="' + imgUrl + '" width="' + width + '" height="' + height + '" alt="" border="0">');
		}
	}else{
		var defaultColor 	= (document.bgColor != null) ? document.bgColor : "#ffffff";
		var bgcolor 		= (swfbgColor != null) ? swfbgColor : defaultColor;
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
							'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"' +
							'ID="' + swfName + '" WIDTH="' + width + '" HEIGHT="' + height + '">' +
							'<PARAM NAME="movie" VALUE="' + srcURL + '">' + 
							'<PARAM NAME="quality" VALUE="high">' +
							'<PARAM NAME="wmode" VALUE="transparent">'+
							'<PARAM NAME="autostart" VALUE="true">'+
							'<PARAM NAME="bgcolor" VALUE=' + bgcolor + '>' +
							'<embed src="' + srcURL + '" quality="high"' + 'bgcolor="' + 
							bgcolor + '"' + 'width="' + width + '" height="' + height + '"' +
							'type="application/x-shockwave-flash" NAME="' + swfName + '"' +
							'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>' +
						'</OBJECT>');
		eval('window.document.' + swfName + '.rewind()');
		eval('window.document.' + swfName + '.play()');
	}
}

function hasPlugin(){
	var bool;
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 ){
		bool = "true";
	}

	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0); 

	if ((navigator.appName == "Microsoft Internet Explorer" &&	navigator.appVersion.indexOf("Mac") == -1 && navigator.appVersion.indexOf("3.1") == -1) || (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4)){
		bool = "true";
	}else{
		bool = "false";
	}
	return bool;
}
