
//Global Variables:

var myTextArray =
[
'<font size="-1">滚滚长江东逝水，浪花淘尽英雄。是非成败转头空。青山依旧在，几度夕阳红。</font>',
'<font size="-1">白发渔樵江渚上，惯看秋月春风。一壶浊酒喜相逢。古今多少事，都付笑谈中。</font>'
];


var intervalID = 0; // must be a global variable, mainly used in: intervalID = setInterval('chgSlide(1)', 41000); and stopSlide().
var intervalID2 = 0; // flag slides
var intervalID3 = 0; // flag slides
var currentSlide = 1;

var k = 0;  // k is global variable
var k2 = 0;  // k is global variable
var j = 0;
var f = 1;  // because in the table cell the first flag slide is already put there.
var g = 1;  // because in the table cell the first flag slide is already put there.
var m = 1;
var slideNumber = 0;
var imageNumber = 0;
var indexImageNumber = 0;
var indexImageNumber2 = 0;
var autoImageNumber = 0;
var armyImageNumber = 0;
/***********************************************
* CCTV in small new window
***********************************************/
function open_cctv4()
{

OpenWindow=window.open("", "newwin", "width=450, height=350, top=50");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>CCTV-4</TITLE>")
OpenWindow.document.write("<BODY>")
OpenWindow.document.write('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" FleName="http://www.cctv-4.com/2007/asx/cctv-4_live.asx" src="http://www.cctv-4.com/2007/asx/cctv-4_live.asx" name="nstv" ShowControls="1" ShowDisplay="0" ShowStatusBar="1" WindowlessVideo="0" ShowPositionControls="1" ShowAudioControls="1" ShowTracker="1" ShowPositionControls="1" AllowChangeDisplaySize="1" width="425" height="350"></object>');
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close();
self.name="main"
}

function open_small(x)
{

OpenWindow=window.open("", "newwin", "width=450, height=350, top=100");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>Cluntan Vid</TITLE>")
OpenWindow.document.write("<BODY>")
OpenWindow.document.write(x);
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close();
self.name="main"
}


/***********************************************
* Function to solve the RSSBOX not shown problem (entire forum posts: index07.html) 
***********************************************/
function delayer(){
var rssbox_data = document.getElementById('rssbox_cell');

//if (entire_data.innerHTML.search(/star2.gif/) == -1 || mil_data.innerHTML.search(/star2.gif/) == -1 || eco_data.innerHTML.search(/star2.gif/) == -1 || sport_data.innerHTML.search(/star2.gif/) == -1 || pic_data.innerHTML.search(/star2.gif/) == -1)
//if (entire_data.innerHTML.search(/star2.gif/) == -1)
//	window.location = "http://www.cluntan.com/index.html"
if (rssbox_data == null)
{
	//showcluntan.start(); //this will not work more, so only solution is to reload the index.html
	//this null situation rarely happens, but did happen sometimes.
	window.location.reload();
}
else
if (rssbox_data.innerHTML.search(/star2.gif/) == -1)
{
	showcluntan.start(); //this works fine if the entire_data object is not null.
}

}

/***********************************************
* Function to solve the RSSBOX not shown problem (PicNews index03.html & Military PicNews index.html) 
***********************************************/
function delayer1(){
var rssbox_data = document.getElementById('rssbox_cell');

if (rssbox_data == null)
{
	//showcluntan.start(); //this will not work more, so only solution is to reload the index.html
	//this null situation rarely happens, but did happen sometimes.
	window.location.reload();
}

}

function delayer2()
{
var entire_data = document.getElementById('entire_cell');
if (entire_data == null)
{
	//showcluntan.start(); //this will not work more, so only solution is to reload the index.html
	//this null situation rarely happens, but did happen sometimes.
	window.location.reload();
}
else
if (entire_data.innerHTML.search(/star2.gif/) == -1)
{
	showcluntan.start(); //this works fine if the entire_data object is not null.
}
}

/***********************************************
* Slide Functions
***********************************************/


//My Text Messages:
function chgMyTextMessage(x)
{
m = (m == myTextArray.length)? 0 : m;
var el = document.getElementById(x);
el.innerHTML = myTextArray[m];
m++;
}


//Flag Slides
function chgFlagSlide(x)
{
f = (f == flagSlidesArray.length)? 0 : f;
var el = document.getElementById(x);   //always this id="3" element.
el.innerHTML = flagSlidesArray[f];
f++;
}

//picNews slides in index03.html
function chgPicNewsSlide(x)
{
g = (g == picNewsSlidesArray.length)? 0 : g;
var el = document.getElementById(x);   //always this id="picNewsSlide" element.
el.innerHTML = picNewsSlidesArray[g];
g++;
}


//function using sequence slide numbers.
function chgSlide(x)
{
//alert(k);
//alert(slidesArray.length);
//first slide random
var total = slidesArray.length;
if (j == 0)
{
   k = Math.floor(Math.random()*total);
   j++;
}
else
{
   k = (k == slidesArray.length)? 0 : k;
}
var el = document.getElementById(x);   //always this id="1" element.
el.innerHTML = '<center>' + slidesArray[k] + '/<center>' ;
k++;
currentSlide = k;
//alert(k);
}

//function starting from First Slide.
function firstSlide(x)
{
k=1; //NOTE: will always use the chgSlide(x) function for playing slides
var el = document.getElementById(x);   //always this id="1" element.
el.innerHTML = '<center>' + slidesArray[0] + '/<center>' ;
}

//function: random show slide, using random numbers:
function randomSlide(x)
{
//alert(k);
clearInterval ( intervalID );  //first you must clear (stop) the normal slide showing way.
var total = slidesArray.length;
k = Math.floor(Math.random()*total);
if (k>=total)
{
  k = 0; //show last slide
}
var el = document.getElementById(x);   //always this id="1" element.
el.innerHTML = '<center>' + slidesArray[k] + '/<center>' ;
intervalID = setInterval('randomSlide(1)', 40000); // set new interval for random show
}

//function: stop showing slides
function stopSlide()
{
//alert("stop");
var el = document.getElementById(1);   //always this id="1" element.
//el.innerHTML = '<img  alt="" src="http://www.cluntan.com/image/hantang.gif"  style="width: 440px; height: 487px;text-align: center;">';
el.innerHTML = '<img src="http://www.cluntan.com/image/hantang2.gif">';
clearInterval ( intervalID );  // very important
}

//function: show previous slide
function playSlide()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.
//alert("play");
var el = document.getElementById(1);   //always this id="1" element.
el.innerHTML = '<center>' + slidesArray[k] + '/<center>' ;
intervalID = setInterval('chgSlide(1)', 40000); // good. also: the table cell id = "1"
}


//function: show previous slide
function prevSlide()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.
//alert("prev");
k--;
//alert(k);
if (k<0)
{
   k=slidesArray.length-1;
}
if (k==currentSlide)
{
   //k--;
   k=k;
}

var el = document.getElementById(1);   //always this id="1" element.
//el.innerHTML = slidesArray[k]; //MUST: it will take 40 seconds to finish, then process goes to following intervalID = setInterval('chgSlide(1)', 40000);
el.innerHTML = '<center>' + slidesArray[k] + '/<center>' ;
currentSlide = k;
//k--;
intervalID = setInterval('chgSlide(1)', 40000); // good. also: the table cell id = "1"
}


//function: show next slide
function nextSlide()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.
//alert("Next");
//k++;
//alert(k);
if (k>=slidesArray.length)
{
   k=0;
}
if (k==currentSlide)
{
   //k++;
   k=k;
}

var el = document.getElementById(1);   //always this id="1" element.
//el.innerHTML = slidesArray[k];  //MUST: it will take 40 seconds to finish, then process goes to following intervalID = setInterval('chgSlide(1)', 40000);
el.innerHTML = '<center>' + slidesArray[k] + '/<center>' ;
currentSlide = k;
k++;
intervalID = setInterval('chgSlide(1)', 40000); // MUST use this to resume the Interval.
}
  

// Video playing function for index.html:
// x is the video OBJECT code 
function playHotVideo1(x)
{
var VideoCellContent = document.getElementById("video_cell");
VideoCellContent.innerHTML = x;
}


  
// Video playing functions:
function playVideo1(x)
{
//var VidCellContent = document.getElementById("video_cell_1");
var VidCellContent = document.getElementById("video_cell_2");
//alert(videoArray1[x][1]);
VidCellContent.innerHTML = '<div style="width:425px; text-align: center;">' + videoArray1[x][1] + '</div>';
}

function playVideo2(x)
{
var VidCellContent = document.getElementById("video_cell_2");
//alert(videoArray2[x][1]);
VidCellContent.innerHTML = '<div style="width:425px; text-align: center;">' + videoArray2[x][1]+ '</div>';
}

function playVideo3(x)
{
var VidCellContent = document.getElementById("video_cell_2");
//alert(videoArray3[x][1]);
VidCellContent.innerHTML = '<div style="width:425px; text-align: center;">' + videoArray3[x][1]+ '</div>';
}

//play others:
function playVideo4(x)
{
var VidCellContent = document.getElementById("video_cell_2");
VidCellContent.innerHTML = '<div style="width:425px; text-align: center;">' + videoArray4[x][1]+ '</div>';
}


function playFlash(x)
{
var el = document.getElementById("video_cell_1");
el.innerHTML = '<div style="width:425px; text-align: center;">' + videoArray0[x][1]+ '</div>';
}

function stopFlash(x)
{
var el = document.getElementById("video_cell_1");
//el.innerHTML = '<img src="http://www.cluntan.com/image/video1b.gif">';
el.innerHTML = '<img src="http://www.cluntan.com/image/video3a.jpg">';
//el.innerHTML = '<img src="http://www.cluntan.com/image/video1.gif">';
}

//will start to play the Military slide:
function stopFlash2(x)
{
var el = document.getElementById("video_cell_1");
//el.innerHTML = '<img src="http://www.cluntan.com/image/video3a.jpg">';
//only starts playing the military slide AGAIN if it is not playing now
//if (el.innerHTML.search(/slides_flash_mil/) == -1)
//     el.innerHTML = videoArrayMilitary[0][1];
//alert(el.innerHTML);
}

//show index slides after few seconds delay, for index.html:
function start_index_slides()
{
var el = document.getElementById("index_slides");
el.innerHTML = '<div style="width:110; text-align: center;"><object width="110" height="61"><param name="movie" value="someflash.swf"><embed src="http://www.cluntan.com/image/index_pics/gif/index_slide.swf" width="110" height="61"></embed></object></div>';
}

//show index slides after few seconds delay, for index.html:
function start_index_army_slides()
{

//echo "here!!";
var el = document.getElementById("army_cell_1");
var e2 = document.getElementById("army_cell_2");

slideNumber = (slideNumber == (index_army_slides_Array.length-1))? 0 : slideNumber;

el.innerHTML = '<img src='+index_army_slides_Array[slideNumber]+'>';
e2.innerHTML = '<img src='+index_army_slides_Array[slideNumber+1]+'>';

slideNumber++;
}


//show index slides after few seconds delay, for index.html:
function start_army_slides()
{
//var el = document.getElementById("army_cell_1");
var el = document.getElementById("army_cell");
el.innerHTML = '<object text-align: left; height="188" width="450"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/army_slide1.swf" height="188" width="450"></object>';
//el.innerHTML = '<object height="188" width="450"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/army_slide1.swf" height="188" width="450"></object>';
//el.innerHTML = '<div style="width:450; text-align: center;"><object width="450" height="188"><param name="movie" value="someflash.swf"><embed src="http://www.cluntan.com/image/index_slides/index_mil_slide.swf" width="450" height="188"></embed></object></div>';
//el.innerHTML = '<object height="188" width="450"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/slides_flash1.swf" height="188" width="450"></object>';
//el.innerHTML = '<object height="335" width="420"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/slides_flash1.swf" height="335" width="420"></object>';
}

//show beauty slides for index03.html:
function start_beauty_slides()
{
var el = document.getElementById("beauty_cell");
el.innerHTML = '<object height="188" width="450"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/beauty_new.swf" height="188" width="450"></object>';
//el.innerHTML = '<object height="188" width="450"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/pic_beauty_new2.swf" height="188" width="450"></object>';
//el.innerHTML = '<object height="188" width="450"> <param name="movie" value="somefilename.swf"> <embed src="http://www.cluntan.com/flash/beauty_index.swf" height="188" width="450"></object>';
}

//change image: index.html
function change_image()
{
var el = document.getElementById("index_slides");
if (imageNumber == 0)
{   
   el.innerHTML = '<a href="http://www.cluntan.com/index.html">'+'<img src="http://www.cluntan.com/image/panda.jpg" style="border: 0px solid;">'+'</a>';
   imageNumber = 1;
}
else
{
   el.innerHTML = '<a href="http://www.cluntan.com/index.html">'+'<img src="http://www.cluntan.com/image/horsesmall.jpg" style="border: 0px solid;">'+'</a>';
   imageNumber = 0;
}

}

function refresh_military_box()
{
	showMilNews.start()
}

function refresh_general_box()
{
	showPicNews.start()
}


function setTable(what){
if(document.getElementById(what).style.display=="none"){
document.getElementById(what).style.display="block";
}
else if(document.getElementById(what).style.display=="block"){
document.getElementById(what).style.display="none";
}
}


//index.html: top right side big images random change using
function changeRightSideSlide(x)
{
//index_army_slides_Array is defined in slides.js
var total = index_army_slides_Array.length;

k = Math.floor(Math.random()*total);

var el = document.getElementById(x);   

el.innerHTML = '<img src=' +index_army_slides_Array[k] + '  style="border: 0px solid;">';
}



//index.html: top left small cluntan logo images
function changeLogo(x)
{
//index_army_slides_Array is defined in slides.js
var total = Logo_Array.length;

k = Math.floor(Math.random()*total);

var el = document.getElementById(x);   

el.innerHTML = '<img src=' +Logo_Array[k] + '  style="border: 0px solid;">';
}


//get current datetime
function set_datetime(id)
{
//alert("aaaaa");

var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();

document.getElementById(id).value = year + "-" + month + "-" + day + "  " + hours + ":" + minutes + ":" + seconds;
}

//index.html: Adertise image images 1, id="Ads_Slides1"
function changeAdsImage1(x)
{
//AdsImage1_Array is defined in slides.js
var total = AdsImage1_Array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = AdsImage1_Array[k];
}

//index.html: Adertise image images 2, id="Ads_Slides2"
function changeAdsImage2(x)
{
//AdsImage2_Array is defined in slides.js
var total = AdsImage2_Array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = AdsImage2_Array[k];
}


//index.html: animation_c, id="animation_c_slides"
function change_animation_a(x)
{
//Animation_A_Array is defined in slides.js
var total = Animation_A_Array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = Animation_A_Array[k];
}


//index.html: animation_b, id="animation_b_slides"
function change_animation_b(x)
{
//Animation_B_Array is defined in slides.js
var total = Animation_B_Array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = Animation_B_Array[k];
}


//index.html: animation_c, id="animation_c_slides"
function change_animation_c(x)
{
//Animation_C_Array is defined in slides.js
var total = Animation_C_Array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = Animation_C_Array[k];
}


//index.html:
function change_world_flags(x)
{
//world_flags_array is defined in slides.js
var total = world_flags_array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = world_flags_array[k];
}

//index.html:
function change_china_road(x)
{
//china_road_array is defined in slides.js
var total = china_road_array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = china_road_array[k];
}


//index.html:
function change_china_weapons(x)
{
//china_weapons_array is defined in slides.js
var total = china_weapons_array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = china_weapons_array[k];
}

//index.html:
function change_china_cars(x)
{
//china_cars_array is defined in slides.js
var total = china_cars_array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = china_cars_array[k];
}

//index.html:
function change_china_music(x)
{
//china_music_array is defined in slides.js
var total = china_music_array.length;
k = Math.floor(Math.random()*total);
var el = document.getElementById(x);
el.innerHTML = china_music_array[k];
}


// -- BEING: Dropdown Menu (open links)
// borrowed from here: 
// http://www.echoecho.com/htmlforms11.htm
// http://www.echoecho.com/tooldropdown.htm

function land(ref, target)
{
lowtarget=target.toLowerCase();
if (lowtarget=="_self") {window.location=loc;}
else {if (lowtarget=="_top") {top.location=loc;}
else {if (lowtarget=="_blank") {window.open(loc);}
else {if (lowtarget=="_parent") {parent.location=loc;}
else {parent.frames[target].location=loc;};
}}}
}

function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
splitc=ref.lastIndexOf("*");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000);}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}

/////////////////////////////////////////////////////////////////////
// China Military Pictures:

//[1] For the new index.htm: display a random image from index_images.js
//used in:   <body onload='getRandomImage11("ImageCell")'>
function getRandomImageArmy1(x)
{
//china_army_image_array is defined in china_army_images.js
var total = china_army_image_array.length;

k = Math.floor(Math.random()*total);

var el = document.getElementById(x);   

el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_army_image_array[k] + '  style="border: 0px solid; width: 600px; height: 320px;">' + '</a>';

//china_army_image_array is a Global variable defined in index_images.js.
//it is now randomly sorted, the result random ordered array will be used in getRandomImage().
china_army_image_array.sort(function() {return 0.5 - Math.random()});

}


//[2] For the new index.htm: display a random image from index_images.js
function getRandomImageArmy2(x)
{
//china_army_image_array is defined in index_images.js

//china_army_image_array.sort(Math.round(Math.random())-0.5));

var total = china_army_image_array.length;

//indexImageNumber is a GLOBAL variable
indexImageNumber = (indexImageNumber == total)? 0 : indexImageNumber

var el = document.getElementById(x);   

//Important note: the array china_army_image_array is already randomly sorted in getRandomImage11():
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_army_image_array[indexImageNumber] + '  style="border: 0px solid; width: 600px; height: 320px;">' + '</a>';

indexImageNumber++;

}


/////////////////////////////////////////////////////////////////////
// China Auto Pictures:

//[1] For the new index.htm: display a random image from china_auto_images.js
//used in:   <body onload='getRandomImage11("ImageCell")'>
function getRandomImageAuto1(x)
{
//china_auto_image_array is defined in index_images.js
var total = china_auto_image_array.length;

k = Math.floor(Math.random()*total);

var el = document.getElementById(x);   

el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_auto_image_array[k] + '  style="border: 0px solid; width: 600px; height: 320px;">' + '</a>';

//china_auto_image_array is a Global variable defined in index_images.js.
//it is now randomly sorted, the result random ordered array will be used in getRandomImage().
china_auto_image_array.sort(function() {return 0.5 - Math.random()});

}


//[2] For the new index.htm: display a random image from index_images.js
function getRandomImageAuto2(x)
{
//china_auto_image_array is defined in index_images.js

var total = china_auto_image_array.length;

//autoImageNumber is a GLOBAL variable
autoImageNumber = (autoImageNumber == total)? 0 : autoImageNumber;

var el = document.getElementById(x);   

//Important note: the array china_auto_image_array is already randomly sorted in getRandomImage11():
el.innerHTML = '<a href="http://www.cluntan.com/chinaauto.html"> ' + ' <img ' + 'title=' +  '"' + china_auto_image_array[autoImageNumber] +  '"'  +  'src=' + china_auto_image_array[autoImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

autoImageNumber++;

}


/////////////////////////////////////////////////////////////////////
// Index.html Pictures: Mixed Images

//[1] For the new index.htm: display a random image from china_auto_images.js
//used in:   <body onload='getRandomImage11("ImageCell")'>
function getRandomImageMixed1(x)
{
//china_mixed_image_array is defined in index_images.js
var total = china_mixed_image_array.length;

k = Math.floor(Math.random()*total);

var el = document.getElementById(x);   

el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_mixed_image_array[k] + '  style="border: 0px solid;  height: 320px;">' + '</a>';

//china_mixed_image_array is a Global variable defined in index_images.js.
//it is now randomly sorted, the result random ordered array will be used in getRandomImage().
china_mixed_image_array.sort(function() {return 0.5 - Math.random()});

}

//[1] For the new index.htm: display a random image from china_auto_images.js
//used in:   <body onload='getRandomImage11("ImageCell")'>
function getRandomImageMilitary(x)
{
//china_mixed_image_array is defined in index_images.js
var total = china_military_array.length;

k = Math.floor(Math.random()*total);

var el = document.getElementById(x);   

el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_military_array[k] + '  style="border: 0px solid;  height: 280px;">' + '</a>';

//china_mixed_image_array is a Global variable defined in index_images.js.
//it is now randomly sorted, the result random ordered array will be used in getRandomImage().
china_military_array.sort(function() {return 0.5 - Math.random()});

}





//[2] For the new index.htm: display a random image from index_images.js
function getRandomImageMixed2(x)
{
//china_mixed_image_array is defined in index_images.js

//china_mixed_image_array.sort(Math.round(Math.random())-0.5));

var total = china_mixed_image_array.length;

//indexImageNumber is a GLOBAL variable
indexImageNumber = (indexImageNumber == total)? 0 : indexImageNumber;

var el = document.getElementById(x);   

//Important note: the array china_mixed_image_array is already randomly sorted in getRandomImage11():
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_mixed_image_array[indexImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

indexImageNumber++;

}

//[2] For the new index.htm: display a random image from index_images.js
function getRandomImageMilitary2(x)
{
//china_mixed_image_array is defined in index_images.js

//china_mixed_image_array.sort(Math.round(Math.random())-0.5));

var total = china_military_array.length;

//indexImageNumber is a GLOBAL variable
indexImageNumber = (indexImageNumber == total)? 0 : indexImageNumber;

var el = document.getElementById(x);   

//Important note: the array china_mixed_image_array is already randomly sorted in getRandomImage11():
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_military_array[indexImageNumber] + '  style="border: 0px solid; height: 280px;">' + '</a>';

indexImageNumber++;

}

//[2] For the new index.htm: display a random image from index_images.js
function getRandomImageAuto2(x)
{
//china_mixed_image_array is defined in index_images.js

//china_mixed_image_array.sort(Math.round(Math.random())-0.5));

var total = china_auto_array.length;

//indexImageNumber is a GLOBAL variable
indexImageNumber2 = (indexImageNumber2 == total)? 0 : indexImageNumber2;

var el = document.getElementById(x);   

//Important note: the array china_mixed_image_array is already randomly sorted in getRandomImage11():
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img src=' +china_auto_array[indexImageNumber2] + '  style="border: 0px solid; height: 280px;">' + '</a>';

indexImageNumber2++;

}


//////////////////////////////////////

// AUTO Image Slides Functions:

//function: show previous imsage
function prevAutoImage()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.

//-2: because it was already increased to the NEXT image number in function getRandomImageAuto2()
autoImageNumber = autoImageNumber - 2;
//alert(autoImageNumber);
if (autoImageNumber<0)
{
   autoImageNumber=0;
}


var el = document.getElementById('ImageCell');   
el.innerHTML = '<a href="http://www.cluntan.com/chinaauto.html"> ' + ' <img ' + 'title=' +  '"' + china_auto_image_array[autoImageNumber] +  '"'  +  'src=' + china_auto_image_array[autoImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

autoImageNumber++;

intervalID = setInterval('getRandomImageAuto2("ImageCell")', 6000); // 6 seconds
}


//Stop playing:
function stopAutoImage()
{
//alert("stop");
clearInterval ( intervalID );  // very important
}

//Re-start playing:
function playAutoImage()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.
//alert("play");

var el = document.getElementById('ImageCell');   
el.innerHTML = '<a href="http://www.cluntan.com/chinaauto.html"> ' + ' <img ' + 'title=' +  '"' + china_auto_image_array[autoImageNumber] +  '"'  +  'src=' + china_auto_image_array[autoImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

//Must increase 1, otherwise twice time playing same next image:
autoImageNumber++;
intervalID = setInterval('getRandomImageAuto2("ImageCell")', 6000); // 6 seconds
}


//function: show next image
function nextAutoImage()
{

clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.

//autoImageNumber++;
//alert(autoImageNumber);

if (autoImageNumber>=china_auto_image_array.length)
{
   autoImageNumber=0;
}

var el = document.getElementById('ImageCell');   
el.innerHTML = '<a href="http://www.cluntan.com/chinaauto.html"> ' + ' <img ' + 'title=' +  '"' + china_auto_image_array[autoImageNumber] +  '"'  +  'src=' + china_auto_image_array[autoImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

autoImageNumber++;

intervalID = setInterval('getRandomImageAuto2("ImageCell")', 6000); // 6 seconds
}


///////////////////////////////////////

//////////////////////////////////////

// AUTO Image Slides Functions:

//function: show previous imsage
function prevArmyImage()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.
//-2: because it was already increased to the NEXT image number in function getRandomImageArmy2()
armyImageNumber = armyImageNumber - 2;
//alert(armyImageNumber);
if (armyImageNumber<0)
{
   armyImageNumber=0;
}


var el = document.getElementById('ImageCell');   
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img ' + 'title=' +  '"' + china_army_image_array[armyImageNumber] +  '"'  +  'src=' + china_army_image_array[armyImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

armyImageNumber++;

intervalID = setInterval('getRandomImageArmy2("ImageCell")', 6000); // 6 seconds
}


//Stop playing:
function stopArmyImage()
{
//alert("stop");
clearInterval ( intervalID );  // very important
}

//Re-start playing:
function playArmyImage()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.
//alert("play");

var el = document.getElementById('ImageCell');   
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img ' +  'src=' + china_army_image_array[armyImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

//Must increase 1, otherwise twice time playing same next image:
armyImageNumber++;
intervalID = setInterval('getRandomImageArmy2("ImageCell")', 6000); // 6 seconds
}


//function: show next image
function nextArmyImage()
{
clearInterval ( intervalID );  // very important, user can click several times Next Button, then timeout messed up.

//armyImageNumber++;
//alert(armyImageNumber);

if (armyImageNumber>=china_army_image_array.length)
{
   armyImageNumber=0;
}

var el = document.getElementById('ImageCell');   
el.innerHTML = '<a href="http://www.cluntan.com/auto.html"> ' + ' <img ' +  'src=' + china_army_image_array[armyImageNumber] + '  style="border: 0px solid; height: 320px;">' + '</a>';

armyImageNumber++;

intervalID = setInterval('getRandomImageArmy2("ImageCell")', 6000); // 6 seconds

}


///////////////////////////////////////


// -- END



