var requiredVersion = 11.0;


function getShockwave() {
	

	var shockwave = new Object();
	shockwave.version='0.0';
	var tShockwaveFound = 0;
	
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-director"]&& navigator.mimeTypes["application/x-director"].enabledPlugin) {
		
		if (navigator.plugins && navigator.plugins["Shockwave for Director"]&& (tVersionIndex = navigator.plugins["Shockwave for Director"].description.indexOf(".")) != - 1) {
			
			tShockwaveFound = 1;
			
			var tMajorVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex-2, tVersionIndex);
			var tMinorVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex+1, tVersionIndex+2);

		}
		
	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
			 && (navigator.userAgent.indexOf("Windows 95")>=0 
					 || navigator.userAgent.indexOf("Windows 98")>=0 
					 || navigator.userAgent.indexOf("Windows NT")>=0 )
				) {
		var tVersionString = "";
	  
		setVersionString = function(v) {
			tVersionString = v;
		}
	  
		document.write('<script type="text/vbscript" language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('set tSWControl = CreateObject("SWCtl.SWCtl") \n');
		document.write('if IsObject(tSWControl) then \n');
		document.write('setVersionString(tSWControl.ShockwaveVersion("")) \n');
		document.write('end if \n');
		document.write('</script\> \n');

		if (tVersionString != "") {
		  
			tShockwaveFound = 1;
		  
			tVersionIndex = tVersionString.indexOf(".")
			var tMajorVersionString = tVersionString.substring(tVersionIndex-2, tVersionIndex);
			var tMinorVersionString = tVersionString.substring(tVersionIndex+1, tVersionIndex+2);

		}
	}

	if (tShockwaveFound == 1) {
		
		shockwave.version = tMajorVersionString+'.'+tMinorVersionString;
		createCookie('cDCR', escape(shockwave.version), 7);

	} else {
		
		createCookie('cDCR', 'null', 7);
	}
	
	shockwave.found = tShockwaveFound;
	
	return shockwave;

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function call_dcr(pDCR, pURL, pID, pVersion, w3dURL, dataURL, dcrWidth, dcrHeight) {
	
	var shockwave = getShockwave();
	
	if (shockwave.found == 0) {
		
		document.write(error_str_no_player());
		
		return; 
		
	} else if (shockwave.version < requiredVersion) {
		
		document.write(error_str_wrong_version(shockwave.version));
		
		return; 
		
	} else {
	
	document.write('<OBJECT classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" '
	  + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=11,0,0,0" '
	  + ' ID=3style_2_1 WIDTH='+dcrWidth+' HEIGHT='+dcrHeight+' VIEWASTEXT>'
	  + ' <PARAM NAME=progress VALUE=\'true\'>'
	  + ' <param name=src value="'+pURL+'/3D_progbar.dcr">'
	  + ' <param name=sw1 value="'+pDCR+'">'
	  + ' <param name=sw2 value="'+w3dURL+'">'
	  + ' <param name=sw3 value="'+dataURL+'">'
	  + ' <param name=sw4 value="'+pVersion+'">'
	  + ' <param name=sw5 value="'+pID+'">'
	  + ' <param name=swStretchStyle value="fill">'
	  + ' <param name=bgColor value=#EEEEEE>  '
	  + ' <param name=swRemote '
	  + ' value="swSaveEnabled=\'true\' '
	  + ' swVolume=\'true\' '
	  + ' swRestart=\'true\' '
	  + ' swPausePlay=\'true\' '
	  + ' swFastForward=\'true\' '
	  + ' swContextMenu=\'true\' ">'
	  + ' <param name=PlayerVersion value=11>'
	  
	  + ' <EMBED SRC="'+pURL+'/3D_progbar.dcr" '
	  + ' sw1="'+pDCR+'" sw2="'+w3dURL+'" sw3="'+dataURL+'" sw4="'+pVersion+'" sw5="'+pID+'" '
	  + ' bgColor=#EEEEEE '
	  + ' WIDTH='+dcrWidth+' '
	  + ' HEIGHT='+dcrHeight+' '
	  + ' swRemote="swSaveEnabled=\'true\' '
	  + ' swVolume=\'true\' swRestart=\'true\' '
	  + ' swPausePlay=\'true\' '
	  + ' swFastForward=\'true\' '
	  + ' swContextMenu=\'true\' " '
	  + ' swStretchStyle=fill '
	  + ' progress=TRUE logo=FALSE '
	  + ' TYPE="application/x-director" '
	  + ' PlayerVersion=11 '
	  + ' PLUGINSPAGE="http://get.adobe.com/shockwave/">'
	  + ' </EMBED>' 
	  + ' </OBJECT></div>'
	  + ' <div>Click and drag your mouse to move up, down and around.<br />'
	  + ' Press up/down arrow keys to zoom, left/right arrow keys to pan.');

	}
 }


function error_str_wrong_version(version) {

	var str = '<div style="height:300px;padding-top:80px;background-image:url(/images/layout/shockwave_error_720.jpg)">'
		+ '<b>Please update your Shockwave player.</b>'
		+ '<br /><br />To sucessfully use our DesignPartner:3D application,<br />'
		+ ' you will need to upgrade your Shockwave player<br />'
		+ ' to version ' + requiredVersion + ' or higher.<br />'
		+ ' (you currently have version ' + version + ' installed)<br /><br />'
		+ ' Click here to download and install the free current version:<br />'
		+ ' <a href="http://get.adobe.com/shockwave/" target="_blank" class="dark">'
		+ 'http://get.adobe.com/shockwave</a></div>';
		
	return str;
}

function error_str_no_player() {

	var str = '<div style="height:280px;padding-top:100px;background-image:url(/images/layout/shockwave_error_720.jpg)">'
		+ '<b>Shockwave player not installed.</b>'
		+ '<br /><br />To sucessfully use our DesignPartner:3D application,<br />'
		+ ' you will need to install the free Shockwave player.<br /><br />'
		+ ' Click here to download and install the current version:<br />'
		+ ' <a href="http://get.adobe.com/shockwave/" target="_blank" class="dark">'
		+ 'http://get.adobe.com/shockwave</a></div>';
		
	return str;
}

