//Bikini.com Homepage Javascript functions
//Flash Rotation System
var images = new Array(6);
images[1] = "supermodelparty.swf";
images[2] = "hoots.swf";
images[3] = "blouin.swf";
images[4] = "england.swf";
images[5] = "waterson.swf";
images[6] = "allstars.swf";
function layerWrite(id,text) {
  if(document.getElementById){
                  document.getElementById(id).innerHTML=text;
            }else if(document.all){
                  document.all[id].innerHTML=text;
            }else if(document.layers){
                  with(document.layers[id].document){
                        open();
                        write(text);
                        close();
                  }
            }
}

function displayText(text,fieldName){
 if (navigator.appName == "Netscape") {layerWrite('swfbox1Layer',text);}
 else {document.all[fieldName].innerHTML=text;}
} 

function changeLayer(chg){
 if (navigator.appName == "Netscape") {document.layers["swfbox1Layer"].left=chg;}
 else {document.all.swfbox1Layer.style.left=chg+"px";}
}

function resize1(){
 if (navigator.appName == "Netscape") {width = window.innerWidth;}
 else {width = document.body.offsetWidth;}
 var wide2 = width - 590;
 var wide3 = wide2 / 2;
 var wide4 = wide3 - 108;
 if (wide4 < 228) {wide4 = 228;}
 changeLayer(wide4);
}

function swf_text1(img){
 var img_txt = '<OBJECT CLASSID="clsid:clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
 + 'WIDTH="362" HEIGHT="323" '
 + 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0">'
 + '<PARAM NAME="MOVIE" VALUE="http://www.bikini.com/flash/rotate/'
 + images[img]
 + '">'
 + '<PARAM NAME="PLAY" VALUE="true">'
 + '<PARAM NAME="wmode" VALUE="transparent">' 
 + '<PARAM NAME="LOOP" VALUE="false">'
 + '<PARAM NAME="QUALITY" VALUE="high">'
 + '<PARAM NAME="MENU" VALUE="false">'
 + '<EMBED SRC="http://www.bikini.com/flash/rotate/'
 + images[img]
 + '" '
 + 'WIDTH="362" HEIGHT="323" '
 + 'PLAY="true" '
 + 'LOOP="false" '
 + 'QUALITY="high" '
 + 'MENU="false" '
 + 'TYPE="application/x-shockwave-flash" '
 + 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
 + '</EMBED></OBJECT>';
 return img_txt;
}

function writeFlash() {

// write vbscript detection if we're on ie win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;	// true if we're on ie
var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false; // true if we're on mac
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows
jsVersion = 1.1;
 if ((navigator.userAgent.indexOf('MSIE') != -1)
  && (navigator.userAgent.indexOf('Win') != -1)) {
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

// do our javascript detection if the navigator object is fully supported
  // If navigator.plugins exists...
  if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {

      // Some version of Flash was found. Time to figure out which.
      
      // Set convenient references to flash 2 and the plugin description.
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      // DEBUGGING: uncomment next line to see the actual description.
      // alert("Flash plugin description: " + flashDescription);
      
      // A flash plugin-description looks like this: Shockwave Flash 4.0 r5
      // We can get the major version by grabbing the character before the period
      // note that we don't bother with minor version detection. 
      // Do that in your movie with $version or getVersion().
      var flashVersion = parseInt(flashDescription.substring(16));

      // We found the version, now set appropriate version flags. Make sure
      // to use >= on the highest version so we don't prevent future version
      // users from entering the site.
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
      flash8Installed = flashVersion == 8;
      flash9Installed = flashVersion >= 9;
    }
  }
  
  // Loop through all versions we're checking, and
  // set actualVersion to highest detected version.
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  
  // If we're on msntv (formerly webtv), the version supported is 4 (as of
  // January 1, 2004). Note that we don't bother sniffing varieties
  // of msntv. You could if you were sadistic...
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  
  // DEBUGGING: uncomment next line to display flash version
  // We're finished getting the version on all browsers that support detection.
  // Time to take the appropriate action.
if ((navigator.userAgent.indexOf('MSIE') != -1)
  && (navigator.userAgent.indexOf('Mac') != -1)) actualVersion = 3;
  // If the user has a new enough version...

  if (actualVersion >= requiredVersion) {
        hasRightVersion = true;                
  } 
// customize movie tags and alternate html content below
if (navigator.appName == "Netscape") {width = window.innerWidth;}
else {width = document.body.offsetWidth;}
var wide2 = width - 585;
var wide3 = wide2 / 2;
var wide4 = wide3 - 108;
if (wide4 < 228) {wide4 = 228;}
if(hasRightVersion) // if we've detected an acceptable version
		{
  if (navigator.appName == "Netscape") {
    var zidx = '';
  }else{
    var zidx = ' z-index:1;';
  }

  
var oeTags = '<DIV id="swfbox1Layer" style="position:relative; visibility:visible;"></DIV>';
 
		document.write(oeTags); 	// embed the flash movie
		}
	else // flash is too old or we can't detect the plugin
		{
  if (navigator.appName == "Netscape") {
   var zidx = '';
  }else{
    var zidx = ' z-index:1;';
  }

		var alternateContent = '<DIV id="swfbox1Layer" style="style="position:relative; visibility:visible;"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" border="0" target="blank"><IMG SRC="http://www.bikini.com/images/homepage/07/main_area_02.gif" border="0" alt=""></a>'
		+ '</DIV>';

		document.write(alternateContent);	// insert non-flash content
		}
}

 //---------------CREATING ANIMATED OBJECTS------------------------------------
 
 //ANIMATED OBJECT
 //This constructor function defines a new type of object called animatedObject
 //The properties are as follows:
 //objectName = any string 
 //layerName = the name of the layer that will be animated
 //loop = set to "yes" if the animation should loop
 //speed = an integer in milliseconds that specifies the time between movements
 //endRoutines= a set of function calls that the object should perform at the  
 // end of its route. Put a 0 here if there are no functions to execute.
 //selectedIndex = the position in the route
 //route = an array of x,y pairs in the form (x,y, x,y, x,y,...) that represent
 //	 the coordinates in the order in which the animated object will move.
function animatedObject (objectName,layerName,loop,speed,selectedIndex,endRoutines,route){
 	this.objectName=objectName;
 	this.layerName=layerName;
 	this.loop=loop;
 	this.speed=speed;
 	this.selectedIndex=selectedIndex;
 	this.endRoutines=endRoutines;
 	this.route=route;
  }
 
 //ANIMATED OBJECTS ARRAY
 //Keep track of all the animated objects by putting their names in an array
 //This array will be used later to stop and start the animations on command
    animObjectArray= new Array ("swfbox1");
 
 //CREATION OF ANIMATED OBJECTS
 //Define an animated object called "swfbox1"
 swfbox1Array=new Array (250);
 var coords="6,221, 8,221, 12,223, 18,226, 29,230, 35,233, 41,235, 45,237, 50,238, 56,240, 61,241, 68,244, 75,245, 83,247, 94,249, 107,253, 119,256, 133,258, 144,261, 162,264, 174,266, 185,269, 196,271, 209,274, 222,276, 240,279, 254,280, 279,285, 299,287, 312,289, 332,292, 358,294, 386,298, 414,299, 435,302, 456,302, 474,302, 492,302, 510,302, 523,302, 535,301, 546,300, 554,300, 562,299, 570,299, 577,298, 585,297, 593,296, 600,295, 613,294, 624,291, 637,289, 648,286, 655,285, 659,284, 661,283, 663,282, 664,282, 665,282, 665,281, 666,281, 667,281, 669,281, 671,280";
 swfbox1Array=coords.split(",");
 swfbox1 = new animatedObject(
 	'swfbox1',
 	'swfbox1Layer',
 	'no',
 	20,
 	0,
 	'0',
 	swfbox1Array
 );
 
//---------------TIMELINE FUNCTIONS------------------------------------------
 //TIMELINE
 //This timeline is an array. Some array elements hold function calls
 //Another function (timelineController()) will loop through this array
 //and execute the functions at the designated time. Note that currTime
 //may also be set in the startTimeline() and stopTimeline() functions.
 	var totalTime=7;
 	var currTime=0;
	var img_txt1 = swf_text1("1");
    var img_txt2 = swf_text1("2");
	var img_txt3 = swf_text1("3");
	var img_txt4 = swf_text1("4");
	var img_txt5 = swf_text1("5");
	var img_txt6 = swf_text1("6");    
	
 	var timeline=new Array(5);
	timeline[1]='displayText(img_txt1,"swfbox1Layer")';
	timeline[2]='displayText(img_txt2,"swfbox1Layer")';
	timeline[3]='displayText(img_txt3,"swfbox1Layer")';
	timeline[4]='displayText(img_txt4,"swfbox1Layer")';
	timeline[5]='displayText(img_txt5,"swfbox1Layer")';
	timeline[6]='displayText(img_txt6,"swfbox1Layer")';
	timeline[7]='displayText(img_txt1,"swfbox1Layer");currTime=1';
	
 //STOP TIMELINE
 //This function stops the timeline by setting currTime to totalTime
 function stopTimeline(){
 	currTime=totalTime+1;
 }
 
 //START TIMELINE
 //This function sets the timeline to its starting point and then calls the 
 //animation controller which starts the timeline.
 function startTimeline(){
 	currTime=0;
	if(hasRightVersion) // if we've detected an acceptable version
	{
 	timelineController();
	}
 }
 
 //TIMELINE CONTROLLER
 //This function loops through each element of the timeline. 
 //It loops at the rate of one element per second.
 //If the element contains function calls, this function executes them
 function timelineController(){ 
 	if (currTime <= totalTime){
 		currTime++;
 		if (timeline[currTime] != null){eval(timeline[currTime]);}
 		if (currTime == "1") {
		  if (navigator.appName != "Netscape") {setTimeout("timelineController()",10000);}
		  else {setTimeout("timelineController()",13000);}
		}
 		else {setTimeout("timelineController()",12000);}
 	}
 }
 
//Flying Airplane
 function movement() {
 if (navigator.appName == "Netscape") {width = window.innerWidth;}
else {width = document.body.offsetWidth;}

var startX = width;
startX = startX - 150;
var startY = 225;

 if(currentX <= -1000) {
  currentX = startX;
  currentY = startY;
  } else {
  currentX += deltaX;
  ycoor = .030 * currentX;
  currentY += 2 * Math.sin(ycoor);
  }
 }

function setPosition(x,y) {
 divStyle.left = currentX;
 divStyle.top = currentY;
 }

function moveDiv() {
 movement();
 setPosition();
 }

function moveImage() {
if (navigator.appName == "Netscape") {
width = window.innerWidth;

var startX = width;
startX = startX - 150;
var startY = 225;
}
else {
width = document.body.offsetWidth;

var startX = width;
startX = startX - 150;
var startY = 225;
if (navigator.appName == "Netscape") {
  var mi = document.layers["mi"];
  var swfbox1Layer = document.layers["swfbox1Layer"];
}

 //if(!document.all) document.all = document;
 //if(!document.all.mi.style) document.all.mi.style = document.all.mi;
 if (navigator.appName == "Netscape") {
  divStyle = document.mi;
 }else{
  divStyle = document.all.mi.style;
 }
 currentX = startX;
 currentY = startY;
 setPosition(currentX, currentY);
 if (navigator.appName == "Netscape") {
   divStyle.visibility = "show";
   divStyle.moveAbove(swfbox1Layer);
 }else{
   divStyle.visibility = "visible";
 }
 setInterval("moveDiv()",movePeriod);
 }
}

 function openWindow(url, name, rs, w, h) {
  var resize = "";
  if (rs) {
    resize = "resizable,";
  }
  popupWin = window.open(url, name, 'scrollbars,menubar,' + resize +
'width=' + w + ',height=' + h);
  window.name = 'opener';
}

if (location.search && window.focus) { // for NN2
 if (location.search.indexOf("buFocus") >= 0) {top.focus();}
}

function writePlane1() {
  //var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false; // true if we're on mac
  if (navigator.appName == "Netscape") {
    var zidx = '';
  }else{
    var zidx = ' z-index:2;';
  }
  var plane_text_hold = '<DIV ID="mi" STYLE="position:absolute; visibility:hidden;'
  + zidx
  + '">'
  + '<A href="http://www.bikini.com/tikiguy/"><IMG SRC="http://www.bikini.com/images/homepage/tiki_homeplane.gif" border=0 width="288" height="60"></a>'
  + '</DIV>';
  var plane_text = '<DIV ID="mi" STYLE="position:absolute; visibility:hidden;'
  + zidx
  + '">'
  + '<IMG SRC="http://www.bikini.com/images/homepage/tiki_homeplane.gif" border=0 width="288" height="60"></a>'
  + '</DIV>';

  if (navigator.appName == "Netscape") {
    //document.write(plane_text);	// insert content
  }else{
    document.write(plane_text);	// insert content
  }
}

function movePlane() {
  if (navigator.appName == "Netscape") {
    var mi = document.layers["mi"];
    var swfbox1Layer = document.layers["swfbox1Layer"];
    mi.moveAbove(swfbox1Layer);
	//return;
  }
}

// FOR top of HTML file
//// initialize the value of "browser"
//var browser = "oldAndInTheWay";
//var bName = navigator.appName;
//var bVersion = parseInt(navigator.appVersion);
//var divStyle = "";
//var startX = 800;
//var startY = 225;
//var deltaX = 0 - 4;
//var movePeriod = 50;

//// check for Netscape
//if (bName == "Netscape") {
//  browser = "ns" + bVersion;
//} else {
//  // check for MSIE
//  if (bName == "Microsoft Internet Explorer") {
//    if (bVersion >= 4) {browser = "ie" + bVersion;} 
//	else {browser = "ie3";}
//  }
//}

//For BODY tag  -  onLoad="moveImage();return false;"

//For BODY --
//<DIV ID="mi" STYLE="position:absolute;visibility:hidden">
//<A href="#" onclick="window.open('http://www.bikini.com/tiki_cartoon.html','tiki_cartoon','width=550,height=400');"><IMG SRC="http://www.bikini.com/images/homepage/tiki_homeplane.gif" border=0 width="300" height="60"></a>
//</DIV>
function writePlanel1() {
  var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false; // true if we're on mac

  if (navigator.appName == "Netscape") {
    var zidx = '';
  }else{
    var zidx = ' z-index:2;';
  }
  var plane_text_hold = '<DIV ID="mi" STYLE="position:absolute; visibility:hidden;'
  + zidx
  + '">'
  + '<A href="http://www.bikini.com/tikiguy/"><IMG SRC="http://www.bikini.com/images/homepage/tiki_homeplane.gif" border=0 width="288" height="60"></a>'
  + '</DIV>';
  var plane_text = '<DIV ID="mi" STYLE="position:absolute; visibility:hidden;'
  + zidx
  + '">'
  + '<IMG SRC="http://www.bikini.com/images/homepage/tiki_homeplane.gif" border=0 width="288" height="60"></a>'
  + '</DIV>';
  
  if (navigator.appName == "Netscape" || isMac) {
    //document.write(plane_text);	// insert content
  }else{
    document.write(plane_text);	// insert content
  }
}

