﻿var oldThumb="";
 var elem="";
 var tgs="";
 var state = 0;
 
function slideShow(s)
 {
	if ( oldThumb && !state ) {
		for ( var i = 0; i < thumbs.length; i++ ) {
			 
			if ( thumbs[i] == oldThumb ) {
				state = 1;
				thumbIndex = i;
			}
		}
	}
   	if(intervalId==null)
 	{
 		intervalId=setInterval('slideShow("1")',3000);
 		thumbs[thumbIndex].parentNode.parentNode.className="";
 		thumbIndex=(thumbIndex+1)%thumbsCount
 	 	disableThumbBorder(thumbs[thumbIndex])
 	  
 		 slideAdveritesiItem(thumbs[thumbIndex],'thumbBig')
 		  
 		 thumbs[thumbIndex].parentNode.parentNode.className="red";
 		 return
 	}
 	
 	if(s=="1")
 	{
 		 
 		  thumbs[thumbIndex].parentNode.parentNode.className=""
 		thumbIndex=(thumbIndex+1)%thumbsCount
 	 
 		 slideAdveritesiItem(thumbs[thumbIndex],'thumbBig')
 		 thumbs[thumbIndex].parentNode.parentNode.className="red";
 	}
 	else
 	{
 		document.getElementById(slideShowCheckBox).checked=false
 		   thumbs[thumbIndex].parentNode.parentNode.className=""
 		window.clearInterval(intervalId)
 		intervalId=null
 	}
 }

function slideAdveritesiItem(tg,targetID,isThumbControll,thumbItem)
{
	 
	
//	if (isset('tempThumb')) {
//		if (tempThumb != '') {
//			document.getElementById(targetID).innerHTML = tempThumb;	
//			tempThumb = false;		
//		}									
//	}
	
	
	elem=document.getElementById(targetID);
	tgs=tg;
	setTimeout('elem.src=tgs',10)
 
	if(isThumbControll)
	{
		 
		state = 0;
		 
		//thumbItem.parentNode.parentNode.className="red"
		disableThumbBorder(thumbItem)
		oldThumb=thumbItem
//		if(intervalId!=null)
//			
//			slideShow(0)
	}
	 

	//disableThumbBorder(thumbItem);
	 
	 
}
function disableThumbBorder(thumbItem)
{
//	if(oldThumb!=""&&oldThumb!=thumbItem)
//		{
//			oldThumb.parentNode.parentNode.className="";
//		}
  
var allThumb = document.getElementsByName("thumbLink");
for ( var i = 0; i < allThumb.length; i++ ) {
	allThumb[i].className="";		 
		}
thumbItem.className="current";
}

function playAddvideo()
{
	var myFrame = window.document.createElement('IFRAME');
	
	myFrame.id = 'myFrame_';
	myFrame.name = 'myFrame_';
	myFrame.frameBorder = 0;
	myFrame.scrolling = "no";
	
	myFrame.width = 400;
	myFrame.height = 330;

	myFrame.style.margin = "0";
	myFrame.style.marginwidth = "0px";
	myFrame.style.marginheight = "0px";
	myFrame.style.padding = "0px";
	
	tempThumb = window.document.getElementById("thumbBig");
	tempThumb.childNodes[0].src = '';
	
	tempThumb = tempThumb.innerHTML;

	window.document.getElementById("thumbBig").innerHTML = '';
	qs="";
	for(i=0;i<mediaPath.length;i++)
	{
 
		qs+='videoTypeIndex='+videoTypeIndex+'&mediaPath'+i+'='+mediaPath[i]+'&duration'+i+'='+duration[i]+'&'+"mediaID"+i+"="+mediaID[i]+'&'+"media_ad_id"+i+"="+media_ad_id[i];
	}
	 
	
	
	
	
	myFrame.src = '/real_estate/flvPlayer.php?'+qs;
	window.document.getElementById("thumbBig").appendChild(myFrame);
}


