function writeSWF(width,height,key,merchantid,language,admin)
{
	if(!FlashDetect.installed) {
		document.write('<div style="text-align:center;font-size:12px;color:#333333">The Flash Plugin is required to operate the Room Planner. </ br>The plugin is free and can be downloaded by clicking the "<a href="http://get.adobe.com/flashplayer/" target="_blank">Get Flash Player</a>" button.</ br>To see if you already have the Flash Plugin installed, <a href="http://www.adobe.com/software/flash/about/" target="_blank">click here</a>. </div>');
	}
	else {
		if(merchantid==96) {
			var text = '';
			text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle" style="float:left;">';
			text += '<param name="allowScriptAccess" value="always" />';
		//	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
			text += '<param name="movie" value="http://main.planningwiz.ro/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.ro/" />';
			text += '<param name="quality" value="high" />';
			text += '<param name="allowFullScreen" value="true" />';
			//text += '<param name="wmode" value="transparent" />';
			text += '<param name="bgcolor" value="#FFFFFF" />';
			text += '<embed src="http://main.planningwiz.ro/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.ro/" quality="high" bgcolor="#FFFFFF" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" wmode="transparent" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			text += '</object>';
			if(merchantid!='') {
				if(merchantid==69) {
					//document.write(text);
					document.getElementById('flashContent').innerHTML = text;
		//			document.contentFlash.innerHTML = text;
				}
				else{
					document.write(text);
					//document.getElementById('flashContent').innerHTML = text;
				}
			}
			else {
				window.parent.location="http://www.planningwiz.com";
			}
		}
		else {
			if(merchantid==68 || merchantid==89 || merchantid==98 || merchantid==95 || merchantid==92 || merchantid==94 || merchantid==73 || merchantid==105 || merchantid==81 || merchantid==83 || merchantid==115 || merchantid==107 || merchantid==103 || merchantid==106 || merchantid==109 || merchantid==108 || merchantid==120 || merchantid==125 || merchantid==128 || merchantid==130 || merchantid==131) {
				window.parent.location="http://www.planningwiz.com";
			}
			var text = '';
			text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle" style="float:left;">';
			text += '<param name="allowScriptAccess" value="always" />';
		//	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
			text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
			text += '<param name="quality" value="high" />';
			text += '<param name="allowFullScreen" value="true" />';
			//text += '<param name="wmode" value="transparent" />';
			text += '<param name="bgcolor" value="#FFFFFF" />';
			text += '<embed src="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" quality="high" bgcolor="#FFFFFF" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" wmode="transparent" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			text += '</object>';
			if(merchantid!='') {
				if(merchantid==69) {
					//document.write(text);
					document.getElementById('flashContent').innerHTML = text;
		//			document.contentFlash.innerHTML = text;
				}
				else{
					document.write(text);
					//document.getElementById('flashContent').innerHTML = text;
				}
			}
			else {
				window.parent.location="http://www.planningwiz.com";
			}
		}
	}
}
function writeSWFPW(width,height,key,merchantid,language,admin)
{
	if(merchantid==98 || merchantid==95 || merchantid==73 || merchantid==105 || merchantid==81 || merchantid==83 || merchantid==115) {
		window.parent.location="http://www.planningwiz.com";
	}
	var text = '';
	text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle" style="float:left;">';
	text += '<param name="allowScriptAccess" value="always" />';
//	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="movie" value="http://main.planningwiz.com/MainDebug.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="quality" value="high" />';
	text += '<param name="allowFullScreen" value="true" />';
	text += '<param name="bgcolor" value="#FFFFFF" />';
	text += '<embed src="http://main.planningwiz.com/MainDebug.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" quality="high" bgcolor="#FFFFFF" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	text += '</object>';
	if(merchantid!='') {
		document.write(text);
	}
	else {
		window.parent.location="http://www.planningwiz.com";
	}
}
function writeSWFWatts(width,height,key,merchantid,language,admin)
{
	if(merchantid==98 || merchantid==95 || merchantid==73 || merchantid==105 || merchantid==81 || merchantid==83) {
		window.parent.location="http://www.planningwiz.com";
	}
	var text = '';
	text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle" style="float:left;">';
	text += '<param name="allowScriptAccess" value="always" />';
//	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="movie" value="http://main.planningwiz.com/watts_planner/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/watts_planner/" />';
	text += '<param name="quality" value="high" />';
	text += '<param name="allowFullScreen" value="true" />';
	text += '<param name="bgcolor" value="#FFFFFF" />';
	text += '<embed src="http://main.planningwiz.com/watts_planner/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/watts_planner/" quality="high" bgcolor="#FFFFFF" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	text += '</object>';
	if(merchantid!='') {
		if(merchantid==69) {
			//document.write(text);
			document.getElementById('flashContent').innerHTML = text;
//			document.contentFlash.innerHTML = text;
		}
		else{
			document.write(text);
		}
	}
	else {
		window.parent.location="http://www.planningwiz.com";
	}
}
function writeSWFTest(width,height,key,merchantid,language,admin)
{
	var text = '';
	text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle" style="float:left;">';
	text += '<param name="allowScriptAccess" value="always" />';
//	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="quality" value="high" />';
	text += '<param name="allowFullScreen" value="true" />';
	text += '<param name="bgcolor" value="#FFFFFF" />';
	text += '<embed src="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" quality="high" bgcolor="#FFFFFF" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	text += '</object>';
	if(merchantid!='') {
		document.write(text);
		//document.getElementById('flashConent').innerHTML = text;
	}
	else {
		window.parent.location="http://www.planningwiz.com";
	}
}
function writeSWFNew(width,height,key,merchantid,language,admin)
{
	var text = '';
	text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle">';
	text += '<param name="allowScriptAccess" value="always" />';
	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="quality" value="high" />';
	text += '<param name="allowFullScreen" value="true" />';
	text += '<param name="wmode" value="transparent" />';
	text += '<param name="bgcolor" value="#FFFFFF" />';
	text += '<embed src="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" quality="high" bgcolor="#FFFFFF" wmode="transparent" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	text += '</object>';
	var div = document.getElementById('p');
	div.innerHTML = text;
//	document.write(text);
}
function writeSWFRumpa(width,height,key,merchantid,language,categoryId)
{
	window.parent.location="http://www.planningwiz.com";
	var text = '';
	text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="PlanningWiz" align="middle">';
	text += '<param name="allowScriptAccess" value="always" />';
	text += '<param name="movie" value="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" />';
	text += '<param name="quality" value="high" />';
	text += '<param name="allowFullScreen" value="true" />';
	text += '<param name="bgcolor" value="#FFFFFF" />'; 
	text += '<embed src="http://main.planningwiz.com/Main.swf?screenwidth='+width+'&screenheight='+height+'&key='+key+'&merchantid='+merchantid+'&language='+language+'&path=http://main.planningwiz.com/" quality="high" bgcolor="#FFFFFF" width="'+width+'" height="'+height+'" name="PlanningWiz" id="PlanningWiz_movie" align="middle" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	text += '</object>';
	if(merchantid != '') {
		document.write(text);
	}
	else {
		window.parent.location="http://www.planningwiz.com";
	}
}
function getSize() 
{
    var myWidth = 0;
    var myHeight = 0;
    if (typeof(window.innerWidth) == 'number') 
    {
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } 
    else 
    {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
        {
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } 
        else 
        {
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) 
            {
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }
        }
    }
    return [myWidth, myHeight];
}
function resize()
{
	var s = getSize();
	var width = s[0];
	var height = s[1];
	var browser=navigator.appName;
	//alert(browser);
	if(browser!='Netscape')
	{
		document.getElementById('PlanningWiz').width=width;
		document.getElementById('PlanningWiz').height=height;
	}
	else
	{
		document.getElementById('PlanningWiz_movie').width=width;
		document.getElementById('PlanningWiz').width=width;
		document.getElementById('PlanningWiz_movie').height=height;
		document.getElementById('PlanningWiz').height=height;
	}
}
function resizeV3()
{
	var s = getSize();
	var width = s[0]-135;
	var height = s[1];
	var browser=navigator.appName;
	
	document.getElementById("flashContent").style.width=width+"px";
		
	if(browser!='Netscape')
	{
		document.getElementById('PlanningWiz').width=width;
		document.getElementById('PlanningWiz').height=height;
	}
	else
	{
		document.getElementById('PlanningWiz_movie').width=width;
		document.getElementById('PlanningWiz').width=width;
		document.getElementById('PlanningWiz_movie').height=height;
		document.getElementById('PlanningWiz').height=height;
	}
}
function MaximizeW()
{
	var s = getSize();
	var width = s[0];
	var height = s[1];
	var w_temp = screen.availWidth/width;
	var h_temp = screen.availHeight/height;
	if (w_temp >= 1.29 || h_temp >= 2.08) {
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth ,screen.availHeight);
	}
}
function MaximizeWV3()
{
	var s = getSize();
	var width = s[0]-120;
	var height = s[1];
	var w_temp = screen.availWidth/width;
	var h_temp = screen.availHeight/height;
	if (w_temp >= 1.29 || h_temp >= 2.08) {
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth ,screen.availHeight);
	}
}
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
//  alert(strHref);
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 
function getURLParam1(strParamName){
	var strReturn = "";
	var strHref = window.location.href;
	var strQueryString = strHref.substr(strHref.indexOf("planningwiz.com/")).toLowerCase();
	var aQueryString = strQueryString.split("/");
	for ( var iParam = 1; iParam < aQueryString.length; iParam++ ){
		if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "_") > -1 ){
        var aParam = aQueryString[iParam].split("_");
        strReturn = aParam[1];
        break;
		}
	}	
	return unescape(strReturn);
}
function getParam(param){
	var strHref = window.location.href;
//  alert(strHref);
	if ( strHref.indexOf("?") > -1 ){
		 return getURLParam(param);
	}
	else {
		return getURLParam1(param);
	}
}

/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.4
*/
var FlashDetect = new function(){
    var self = this;
    self.installed = false;
    self.raw = "";
    self.major = -1;
    self.minor = -1;
    self.revision = -1;
    self.revisionStr = "";
    var activeXDetectRules = [
        {
            "name":"ShockwaveFlash.ShockwaveFlash.7",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash.6",
            "version":function(obj){
                var version = "6,0,21";
                try{
                    obj.AllowScriptAccess = "always";
                    version = getActiveXVersion(obj);
                }catch(err){}
                return version;
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        }
    ];
    /**
     * Extract the ActiveX version of the plugin.
     * 
     * @param {Object} The flash ActiveX object.
     * @type String
     */
    var getActiveXVersion = function(activeXObj){
        var version = -1;
        try{
            version = activeXObj.GetVariable("$version");
        }catch(err){}
        return version;
    };
    /**
     * Try and retrieve an ActiveX object having a specified name.
     * 
     * @param {String} name The ActiveX object name lookup.
     * @return One of ActiveX object or a simple object having an attribute of activeXError with a value of true.
     * @type Object
     */
    var getActiveXObject = function(name){
        var obj = -1;
        try{
            obj = new ActiveXObject(name);
        }catch(err){
            obj = {activeXError:true};
        }
        return obj;
    };
    /**
     * Parse an ActiveX $version string into an object.
     * 
     * @param {String} str The ActiveX Object GetVariable($version) return value. 
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    var parseActiveXVersion = function(str){
        var versionArray = str.split(",");//replace with regex
        return {
            "raw":str,
            "major":parseInt(versionArray[0].split(" ")[1], 10),
            "minor":parseInt(versionArray[1], 10),
            "revision":parseInt(versionArray[2], 10),
            "revisionStr":versionArray[2]
        };
    };
    /**
     * Parse a standard enabledPlugin.description into an object.
     * 
     * @param {String} str The enabledPlugin.description value.
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    var parseStandardVersion = function(str){
        var descParts = str.split(/ +/);
        var majorMinor = descParts[2].split(/\./);
        var revisionStr = descParts[3];
        return {
            "raw":str,
            "major":parseInt(majorMinor[0], 10),
            "minor":parseInt(majorMinor[1], 10), 
            "revisionStr":revisionStr,
            "revision":parseRevisionStrToInt(revisionStr)
        };
    };
    /**
     * Parse the plugin revision string into an integer.
     * 
     * @param {String} The revision in string format.
     * @type Number
     */
    var parseRevisionStrToInt = function(str){
        return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
    };
    /**
     * Is the major version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required major version.
     * @type Boolean
     */
    self.majorAtLeast = function(version){
        return self.major >= version;
    };
    /**
     * Is the minor version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required minor version.
     * @type Boolean
     */
    self.minorAtLeast = function(version){
        return self.minor >= version;
    };
    /**
     * Is the revision version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required revision version.
     * @type Boolean
     */
    self.revisionAtLeast = function(version){
        return self.revision >= version;
    };
    /**
     * Is the version greater than or equal to a specified major, minor and revision.
     * 
     * @param {Number} major The minimum required major version.
     * @param {Number} (Optional) minor The minimum required minor version.
     * @param {Number} (Optional) revision The minimum required revision version.
     * @type Boolean
     */
    self.versionAtLeast = function(major){
        var properties = [self.major, self.minor, self.revision];
        var len = Math.min(properties.length, arguments.length);
        for(i=0; i<len; i++){
            if(properties[i]>=arguments[i]){
                if(i+1<len && properties[i]==arguments[i]){
                    continue;
                }else{
                    return true;
                }
            }else{
                return false;
            }
        }
    };
    /**
     * Constructor, sets raw, major, minor, revisionStr, revision and installed public properties.
     */
    self.FlashDetect = function(){
        if(navigator.plugins && navigator.plugins.length>0){
            var type = 'application/x-shockwave-flash';
            var mimeTypes = navigator.mimeTypes;
            if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
                var version = mimeTypes[type].enabledPlugin.description;
                var versionObj = parseStandardVersion(version);
                self.raw = versionObj.raw;
                self.major = versionObj.major;
                self.minor = versionObj.minor; 
                self.revisionStr = versionObj.revisionStr;
                self.revision = versionObj.revision;
                self.installed = true;
            }
        }else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
            var version = -1;
            for(var i=0; i<activeXDetectRules.length && version==-1; i++){
                var obj = getActiveXObject(activeXDetectRules[i].name);
                if(!obj.activeXError){
                    self.installed = true;
                    version = activeXDetectRules[i].version(obj);
                    if(version!=-1){
                        var versionObj = parseActiveXVersion(version);
                        self.raw = versionObj.raw;
                        self.major = versionObj.major;
                        self.minor = versionObj.minor; 
                        self.revision = versionObj.revision;
                        self.revisionStr = versionObj.revisionStr;
                    }
                }
            }
        }
    }();
};
FlashDetect.JS_RELEASE = "1.0.4";
