<!--


/**********************************
        UTILITY FUNCTIONS
***********************************/

function gateway(path) {
// Hidden redirect

	var s1 = "win";
	var s2 = "dow";
	var s3 = "loc";
	var s4 = "at";
	var s5 = "ion";
	var s6 = "hr";
	var s7 = "ef";
	
	eval( s1 + s2 + "." + s3 + s4 + s5 + "." + s6 + s7 + "= path" );
}

function domainDispatch() {
	// redirect to appropriate sublevel based on domain of entry
	
	var path = new String( location.href );
	var pathArray = path.split( '/' );
	var fileName = pathArray[ pathArray.length - 1 ];
	
	if ( fileName == "" ) {
	// top level domain entry
	// check to see if it's Quipples.com or Telebites.com
	
		var whichHost = location.host.toUpperCase();
	
		if ( whichHost.indexOf( "QUIPPLES" ) >= 0 ) window.location.href = "quipples/";
		else if ( whichHost.indexOf( "TELEBITES" ) >=0 ) {
			window.location.href = "telebites/welcome.html";
		}
		else if ( whichHost.indexOf( "AUTITONS" ) < 0) window.location.host = "Autitons.com";
	}
	else if ( whichHost.indexOf( "AUTITONS" ) < 0) window.location.host = "Autitons.com";
	
}

function selectValueInMenu( whichMenu, whichValue ) {
	// given a value and a menu, select the menu's item with the value
	// or reset menu to the first item if not found...
	
	var theIndex = 0;
	var found = false;
	for ( n = 0; (n <= (whichMenu.length - 1)) && (found != true); n++) {
		if ( whichMenu[n].value == whichValue ) {
			theIndex = n;
			found = true;
		}
	}
	
	whichMenu.selectedIndex = theIndex;
}

function selectValueInRadio( whichRadio, whichValue ) {
	// given a value and a radio set, select the radio's item with the value
	// or reset radio to the first button if not found...
	
	
	var theIndex = 0;
	var found = false;
	for ( n = 0; (n <= (whichRadio.length - 1)) && (found != true); n++) {
		if ( whichRadio[n].value == whichValue ) {
			theIndex = n;
			found = true;
		}
	}
	
	whichRadio[theIndex].checked = true;
	
}

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v3.0
  var ok=false; document.MM_returnValue = false;
    
  with (navigator) if (appName.indexOf('Microsoft')==-1) ok=(plugins && plugins[plgIn]);
  else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}

var haveqt = false;
// top level JavaScript variable that is used in the VBScript
// to determine if QT 4.11 or later is installed in IE Win...

function plugInAvailable( whichPlugIn ) {
// Return 1 plug in available, 0 not known, -1 not available

	var available = 0;
	
	//alert( navigator.plugins.length );
	
	with (navigator) if ( plugins ) { 
		if ( plugins.length > 0 ) {
			available = -1;
			for ( n = 0; n < plugins.length ; n++ ) {
				if ( plugins[n].name.indexOf( whichPlugIn ) >= 0 ) available = 1;
			}
		}
	}

	if (haveqt) available = 1;
	
	// haveqt is a javascript variable that is set through a VB script
	// which can detect QT 4.1.1 or later in IE/Win
	// will not detect any QT that may be older than 4.1.1
	// That VB script from Apple technote 1197 must be included on the page
	// and run before this routine is called inorder to work...
	
	//alert ( "haveqt = " + haveqt + " available = " + available );
	return available;
}

function mac() {
// returns true if on a mac, false otherwise

	return navigator.appVersion.indexOf( "Mac" ) > -1;
}

function setCookie(name, value, expire) {
// Sets cookie values. Expiration date is optional and a date object
// sets the current domain and sets path to the most generic...
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
   + "; path=" + escape("/");
   
   //alert( document.cookie );
}

function getCookie(Name) {
// Gets a cookie given it's name

	//alert( document.cookie );
	
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      } 
   }
}


function PlayQT(videoViewerURL, width, height) {

	if ( arguments.length < 3 ) {
		// if no width or height passed, defaults to 320 x 240
		var width = 320;
		var height = 240;
	}

	var width = width + 48; //  + margins
	var height = height + 16 + 10 + 48; // + controller + text + margins
	
	videoViewer = window.open( videoViewerURL, "videoViewer", 
	                           "width="+ width + ",height=" + height 
	                           + ",status=yes,resizable=yes,scrollbars=no" );
	                          
	videoViewer.document.close();		                           
 }

/**********************************
 telebite object, primarily used to locate telebite files 
 in the telebite section of autitons.com
***********************************/

function telebite() {
// telebite object constructor
// gets the filePath of the current telebite html file directly
// it then breaks down the path into appropriate components

	// OBJECT PROPERTIES

	this.path = new String( location.href );
	this.pathArray = this.path.split( '/' );
	
	// first set the defaults...
	this.type = "gags";
	this.format = "qt"; // FOR NOW
	this.content = this.pathArray[ this.pathArray.length - 1 ]; // HTML FILE NAME
	
	// Then set them based on the html file's path
	this.telebiteRoot = "";
	for ( n = 0; n < this.pathArray.length - 3; n++ ) {
		this.telebiteRoot += this.pathArray[ n ] + "/";
	}
		
	this.type = this.pathArray[ this.pathArray.length - 3 ];
	this.format = this.pathArray[ this.pathArray.length - 2 ];
	setCookie( "videoFormat", this.format );
	
	//DEBUG	
	//alert( this.telebiteRoot );
	//alert( this.type + " " + this.format + " " + this.content );
	
	// OBJECT SERVICES
	
	this.jumpMenu = telebiteJumpMenu;
	this.send = sendTelebite;
	this.setVideoFormat = setVideoFormat;
	this.makePath = makeTelebitePath;
	this.jumpTo = jumpToTelebite;
	
	// DISABLED SINCE EXPLORER 6 WIN XP WASN'T WORKING PROPERLY
	//if (this.format == "qt") {
	// If QT, check for QT plug in...
			
		//if ( ! mac() && plugInAvailable( "QuickTime" ) <= 0 ) {
		// if not on a Mac AND QuickTime 4.11 not detected
		// then switch to the windows media player version
			//this.format = "mp"; // to build alternate file path...
			//this.jumpTo();
		//}
	//}
}

function telebiteJumpMenu( menu ){
// a telebite specific jumpMenu

	newValue = menu.options[menu.selectedIndex].value;
	if (newValue != "") {
		this.type = menu.name;
		this.content = newValue;		
		this.jumpTo();
	}
	else selectValueInMenu( menu, this.content );
}

function sendTelebite() {
// Jump to v-Mail page if it's a gag or to webShop if it's a greeting
	if ( this.type == "greetings" ) {
		window.location = "http://dreamlight.com/webshop/welcome.html";
	} else window.location = this.telebiteRoot + "vmail.html";
}

function setVideoFormat( radioButton ) {
// User clicked on a radio button, set the video format
	
	this.format = radioButton.value;
	this.jumpTo();
	
}

function makeTelebitePath() {
	return this.telebiteRoot + this.type + "/" + this.format + "/" + this.content;
}

function jumpToTelebite() {
	eval( "location='" + this.makePath() + "'" );
}


//-->

