/*************************** BEGIN launchPopup.js **************************
author: Keith J. Frank
		Senior Developer
		Oxygen Media
		12/05/03
TO LAUNCH FROM "ONCLICK" USE:
	onclick="launchPopup({url:'urlString', name:'nameString', features:'featuresString'}); return false">
EXAMPLE:
	<a href="" onclick="launchPopup({url:'default.aspx', name:'gallery', features:'top=40,left=40,height=480,width=522,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbar=no'}); return false">launch Watch N' Vote</a><br>

TO lAUNCH FROM "HREF" USE:
	 href="javascript:void(launchPopup({url:'urlString', name:'nameString', features:'featuresString'}))"
EXAMPLE:
	<a href="javascript:void(launchPopup({url:'default.aspx', name:'gallery', features:'top=40,left=40,height=480,width=522,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbar=no'}))">launch Watch N' Vote from href</a><br>
************************************************************************/
PopupManager = new Object();//to refrence Popup Window Object: PopupMamager.nameString + "Window", or PopupMamager.[nameString + "Window"]
function launchPopup(windowArgs){//windowArgs{url:"urlString", name:"nameString", features:"featuresString"}
	var url = windowArgs.url;
	var windowName = windowArgs.name + "Window";
	var featuresString = (windowArgs.features) ? windowArgs.features : "";
	var nameValArray = (featuresString != "") ? featuresString.split(",") : null;
	var features = new Object();
	if(nameValArray)
	{
		for(var i = 0; i < nameValArray.length; i++){
			var tempArray = nameValArray[i].split("=");
			features[tempArray[0]] = tempArray[1];
		}
	
		if(navigator.userAgent.indexOf("Safari") != -1){
			if(features.status == "yes"){
				features.height = parseInt(features.height) + 15;
			}
			else
			{
				features.height = parseInt(features.height) - 1;
			}	
			features.width = parseInt(features.width) - 2;
		}
		features.toString = function(){
			var newFeatureString = "";
			var prefix = "";
			for(props in features){
				if(props != "toString"){
					newFeatureString += prefix + props + "=" + features[props];
					prefix = ",";
				}
			}
			return newFeatureString;
		}
	}
	if(typeof PopupManager[windowName] == "undefined" || (PopupManager[windowName].closed)){
		var feat = features.toString();
		PopupManager[windowName] = window.open(url, windowName, features.toString());
	}
	else{
		PopupManager[windowName].location = url;//if named window exists and is open this changes the location to the new url before focusing it 
	}
	PopupManager[windowName].focus();
	return false;
}
/*************************** END launchPopup.js **************************/

function launchFlash(url, height, width)

{

            if(!height)

            {

                        height = 700;

            }

            if(!width)

            {

                        width = 770;

            }

            launchPopup({url:url, name:'flashy', features:'top=40,left=40,height=' + height + ',width=' + width + ',location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbar=no'});

            return false;

}
