/* media.1.js - write Client I-Frame for media as specified */
var adminAdjustFrameHeight
var adminShowInactive
var baseUrl

adminAdjustFrameHeight = 0
adminShowInactive = 'yes'
baseUrl = 'http://www2.smart-quotes.com/'

function sqMedia(mediaID,mediaType,frameWidth,frameHeight,affID,affCTC,affBrand,affCmpg,affWeb,passThrough){
	var targetURL
	var sCode
	var scroll
	var bInFrame = true		// in frame by default
	var XSLT 	 = false 	// is XSLT turned on for this media type - transition starting June 28 05
	
	scroll = 'yes'
	switch (mediaType){

		case "BANNER":
			/* 	GB - banners converted to XSLT Sept 2 05
				All bannes now written outside of frames */
			//targetURL = baseUrl+"banner.asp";
			XSLT = true
			bInFrame 	= false
			targetURL 	= baseUrl +'NewMedia/NewMedia.aspx?id=' +mediaID +'&src=' +affID +'&ctc=' +affCTC +'&brn=' +affBrand +'&web=' +affWeb +'&cmpg=' +affCmpg			
			break;

		case "IMAGE":
			/* 	GB - banners converted to XSLT Sept 2 05
				All bannes now written outside of frames */
			XSLT = true
			bInFrame 	= false			
			targetURL 	= baseUrl +'NewMedia/NewMedia.aspx?id=' +mediaID +'&src=' +affID +'&ctc=' +affCTC +'&brn=' +affBrand +'&web=' +affWeb +'&cmpg=' +affCmpg			
			//targetURL = baseUrl+"banner.asp";
			break;

		case "HTML":
			/* 	GB - banners converted to XSLT Sept 2 05
				All bannes now written outside of frames */
			XSLT = true
			bInFrame 	= false			
			targetURL 	= baseUrl +'NewMedia/NewMedia.aspx?id=' +mediaID +'&src=' +affID +'&ctc=' +affCTC +'&brn=' +affBrand +'&web=' +affWeb +'&cmpg=' +affCmpg
			switch(mediaID)
			{
			//This is used for Credit Plus as it as a HTML banner NOT an XSLT HTML banner
				case 1069:
					XSLT = false
					bInFrame 	= true
					targetURL = baseUrl+"banner.asp";
				break;
			}


			//targetURL = baseUrl+"banner.asp";
			break;

		case "SEARCH" :

		/*	targetURL = baseUrl+"search.asp";				
			passThrough = "&" &passThrough;
			break;
			
		*/
		
		case "SEARCH" :
			//passthough argument used to contain search keyword where needed
			/*
			 switch(mediaID){
				case 6:
				case 79:
				case 80:
				case 115:
				case 893:
				case 759:
				case 172:
				case 341:
				case 409:
				case 413:
				case 412:
				case 620:
				case 758:
				case 149:
				case 150:
				case 340:
				case 406:
				case 407:
				case 459:
				case 619:
				case 439:
				case 219:
				case 221:
				case 227:
				case 229:
				case 342:
				case 356:
				case 450:
				case 519:
				case 623:
				case 674:
				*/


			
				

					XSLT = true
					bInFrame 	= false			
					targetURL 	= baseUrl +'NewMedia/NewMedia.aspx?id=' +mediaID +'&src=' +affID +'&ctc=' +affCTC +'&brn=' +affBrand +'&web=' +affWeb +'&cmpg=' +affCmpg	

switch(mediaID)
			{
			//This is used for Freeways as it as a PAGE SEARCH NOT an XSLT Search Tool
				case 1139:
					XSLT = false
					bInFrame 	= true
					targetURL = baseUrl+"search.asp";
					break;
			}


		
					break;
		

				//default:
				
        			//targetURL = baseUrl+"search.asp";
        			//passThrough = "&" &passThrough;
        			//break;
			
			//}
			//break;


			
	
		
			
		case "BESTBUY" :
			//targetURL = baseUrl+"bestbuy.asp";

			/* 	code to be implemented with XSLT format bestbuys June 28 05 
				go straight to media.aspx with inframe=1 so that BB Is always written in frame
				using the code below
			*/
			
			XSLT 		= true
			bInFrame 	= true	// default is true but just in case that gets changed sometime
			targetURL 	= baseUrl +'NewMedia/media.aspx?inframe=1&id=' +mediaID +'&src=' +affID +'&ctc=' +affCTC +'&brn=' +affBrand +'&web=' +affWeb +'&cmpg=' +affCmpg
			
			
			break;
		default:
			targetURL = baseUrl+"banner.asp";
			break;
	}

	// during xslt transition Jun 28 05
	if(XSLT==false){
		targetURL = targetURL +"?mid=" +mediaID +"&src=" +affID +"&ctc=" +affCTC +"&brn=" +affBrand +"&cmpg=" +affCmpg +"&web=" +affWeb +"&si=" +adminShowInactive
	}
	
	// Sep 6 05 GB changed to test argument count instead of 'passThrough != 'undefined' which was apparently not working
	if(sqMedia.arguments.length > 9 ){
		targetURL = targetURL + passThrough		
	}

	if(bInFrame){
		sCode = "<iframe id='sqFrame" +mediaID +"' scrolling='no' frameborder='no' border='0' align='center' marginwidth='0' marginheight='0' src='" +targetURL +"' width=" +frameWidth +" height=" +frameHeight +">"
		frameHeight += adminAdjustFrameHeight
		document.write (sCode)
		document.write ("Sorry! your browser does not support frames.")
		document.write ("</iframe>")
	}else{
		sCode = '<script language="JavaScript" type="text/JavaScript" src="' +targetURL +'"></script>'
//		alert(sCode)
		document.write (sCode)
	}
	
	
}

function setMediaType(formName,mediaType){
	var targetURL,oForm,sQS,temp
	switch (mediaType){
		case "BANNER" :
			targetURL = baseUrl+"admin_media_banners_01.asp?FilterMediaType=BANNER";
			break;
		case "SEARCH" :
			targetURL = baseUrl+"admin_media_search_01.asp?FilterMediaType=SEARCH";
			break;
		case "BESTBUY" :
			targetURL = baseUrl+"admin_media_bestbuy_01.asp?FilterMediaType=BESTBUY";
			break;
		default:
			targetURL = baseUrl+"admin_media_banners_01.asp?FilterMediaType=BANNER";
			break;
	}
	oForm = eval("document." + formName)
	oForm.action = targetURL 
	return validateForm(oForm)

}
