// Banner utilities
//   requires utilities.js

function writeSingleImage(){

    var sPut = '<a href="'+sUrl+'" alt="'+sAlt+'"';

    if (sTitle != ''){
	sPut += ' title="'+sTitle+'"';
    }

    sPut +=' target="'+sTarg+'" ><img src="'+sImage_file+'" height="'+iHeight+'" width="'+iWidth+'" /></a>';
    
    document.write(sPut);
}

function writeRolloverImage(){

        MM_preloadImages(sImage_rollover_file);

    var sPut = '<a href="'+sUrl+'" alt="'+sAlt+'"';
    
    if (sTitle != ''){
	sPut += ' title="'+sTitle+'"';
    }
    
    sPut += ' target="'+sTarg+'" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'tactical\' ,\'\',\''+sImage_rollover_file+'\', 1)">';
    sPut += '<img src="'+sImage_file+'" alt="" height="'+iHeight+'" width="'+iWidth+'" name="tactical">';
    sPut += '</a>';

    document.write(sPut);
    
}

function writeFlashObject(){

    var sPut = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+iWidth+'" height="'+iHeight+'" id="FS_2_21_8_2003"><param name="movie" value="'+ sFlash_file +'"><param name="quality" value="high"><param name="bgcolor" value="#000000"><embed src="'+ sFlash_file +'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+iWidth+'" height="'+iHeight+'" bgcolor="#000000" name="Tactical Banner"><\/embed><\/object>';

    document.write(sPut);
}

function writeVersion(){
    
    if (iVersion < 9 && iVersion >4){
	document.write("Javascript detects browser Flash version: " + iVersion + ".<br />");
    }else{
	document.write("You do not have a version of Flash between 5 and 8 inclusive. In the UEW this would mean you will be delivered the single image instead.<br />");
    }
}    



function eawViewBanner(){

    if (sAlt == ''){
	sAlt = "*";
    }
    
    if (sUrl == ''){
	alert ("There is no supplied URL, the link will be broken.");
    }
    
    if (sTarg == ''){
	alert ("There is no supplied Target, defaulting to _self.");
	sTarg = "_self";
    }
    
    
    switch (sBanner_type){

	//                   SINGLE IMAGE
    case "single_image":

	if (!isImage_file){
	    alert ("There is no image file uploaded, this will look broken.");
	}
	writeSingleImage();
	break;

	//                   ROLLOVER IMAGE
    case "rollover_image":

	if (!isImage_file){
	    alert ("There is no image file uploaded, this will look broken.");
	}
	if (!isImage_rollover_file){
	    alert ("There is no image rollover file uploaded, the rollover may look broken.");
	}
	//	MM_preloadImages(sImage_rollover_file);

	writeRolloverImage();
	break;
	//                   FLASH ONLY

    case "flash":

	if (!isFlash_file){
	    alert ("There is no flash file uploaded, this will look broken.");
	}
	writeVersion();
	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}else{
	    document.write("You do not have a sufficient version of Flash. It will not display.");
	}
	break;

	//                        SINGLE IMAGE + FLASH
    case "single_image_and_flash":

	if (!isFlash_file){
	    alert ("There is no flash file uploaded, this will look broken.");
	}
	writeVersion();
	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}
	document.write('<br /><br />Alternative image banner: (only displays in the UEW if browser not capable of displaying the Flash).<br /><br />');
	if (!isImage_file){
	    alert("There is no image file uploaded, this will look broken.");
	}
	writeSingleImage();
	break;

	//                    FLASH + ROLLOVER
    case "rollover_image_and_flash":

	if (!isFlash_file){
	    alert ("There is no flash file uploaded, this will look broken.");
	}
		writeVersion();
	if (iVersion >= iNeededVersion) { 
	        writeFlashObject();
	}
		document.write('<br /><br />Alternative image banner: (only displays in the UEW if browser not capable of displaying the Flash).<br /><br />');

	if (!isImage_file){
	    alert ("There is no image file uploaded, this will look broken.");
	}
	if (!isImage_rollover_file){
	    alert ("There is no image rollover file uploaded, the rollover may look broken.");
	}
       	//MM_preloadImages(sImage_rollover_file);
	writeRolloverImage();
	break;

	//                SINGLE IMAGE + FLASH VIDEO
    case "single_image_and_flash_video":

	if (!isFlash_file){
	    alert ("There is no flash file uploaded, this will look broken.");
	}

	if (!isFlash_video_file){
	    alert ("There is no flash video file uploaded, this will look broken.");
	}
	writeVersion();
	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}
	document.write('<br /><br />Alternative image banner: (only displays in the UEW if browser not capable of displaying the Flash).<br /><br />');
	if (!isImage_file){
	    alert("There is no image file uploaded, this will look broken.");
	}
	writeSingleImage();

	break;

	//                        ROLLOVER IMAGE + FLASH VIDEO
    case "rollover_image_and_flash_video":

	if (!isFlash_file){
	    alert ("There is no flash file uploaded, this will look broken.");
	}
	if (!isFlash_video_file){
	    alert ("There is no flash video file uploaded, this will look broken.");
	}
	writeVersion();
	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}
	document.write('<br /><br />Alternative image banner: (only displays in the UEW if browser not capable of displaying the Flash).<br /><br />');
	if (!isImage_file){
	    alert ("There is no image file uploaded, this will look broken.");
	}
	if (!isImage_rollover_file){
	    alert ("There is no image rollover file uploaded, the rollover may look broken.");
	}
	MM_preloadImages(sImage_rollover_file);
	writeRolloverImage();
 	break;

    default : 
	alert("incorrect banner type");
    }
}



function dawViewBanner(){

    if (sAlt == ''){
	sAlt = "*";
    }
    
    if (sTarg == ''){
	sTarg = "_self";
    }
    
    switch (sBanner_type){

	//                   SINGLE IMAGE
    case "single_image":

	writeSingleImage();
	break;

	//                   ROLLOVER IMAGE
    case "rollover_image":
	writeRolloverImage();
	break;

	//                   FLASH ONLY
    case "flash":

	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}else{
	    document.write("You do not have a sufficient version of Flash. It will not display.");
	}
       	break;

	//                        SINGLE IMAGE + FLASH
    case "single_image_and_flash":

	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}else{   
	    writeSingleImage();  
	}
	break;

	//                    FLASH + ROLLOVER
    case "rollover_image_and_flash":

	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}else{
	    MM_preloadImages(sImage_rollover_file);
	    writeRolloverImage();
	}    
	break;
	
	//                        SINGLE IMAGE + FLASH VIDEO
    case "single_image_and_flash_video":

	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}else{
	    writeSingleImage();
	}
	break;

	//                        ROLLOVER IMAGE + FLASH VIDEO
    case "rollover_image_and_flash_video":
    
	if (iVersion >= iNeededVersion) { 
	    writeFlashObject();
	}else{
	MM_preloadImages(sImage_rollover_file);
	writeRolloverImage();
	}
	break;

    default : 
	return false;
    }
}

