﻿var AllImages = new Object;
var myShow;
var IsInShowMode;

function SetArrayValues(ImageURL,Description,Date,Title)
{
            var MyImage = new Object;
            MyImage.caption = Description+'|'+Date+"|"+Title; 
 
            AllImages[ImageURL] = MyImage; 
}
////////////////////////////////////////////////////
function ShowImage(Image,Discription,Date)
{

if (IsInShowMode)
	StartSlideShow();
	
//<![CDATA[
var data= new Object;
var MyImage= new Object;
MyImage.caption= Discription+'|'+Date;

data[Image]= MyImage;

	    if (myShow!=null)
			myShow.destroy()
	    myShow = new Slideshow('player', data, {controller: false, height: 300, hu: '', thumbnails: false, width: 440, paused:true});

	//]]>
}
////////////////////////////////////////////
function StartSlideShow(){

var CurrentPicture= document.getElementById('hidCurrent').value;
var Site=GetCurrentSite();

//if the player is already playing:
if(IsInShowMode)
{

//to return the undimming;
IsInShowMode=false;
if (myShow!=null)
myShow.pause();
if(Site=="English")
document.getElementById('btnSlideShow').value="Start Slide Show";
else
document.getElementById('btnSlideShow').value="ابدأ عرض مستمر";	
}
else if (AllImages!=null)
		{
		IsInShowMode=true;
		document.getElementById(CurrentPicture).className='news_img_brdr_opc';
		if(Site=="English")
		document.getElementById('btnSlideShow').value="Stop Slide Show";
		else
		document.getElementById('btnSlideShow').value="إيقاف العرض المستمر";
		var data=AllImages ;
		 if (myShow!=null)
			myShow.destroy();
		myShow = new Slideshow('player', data, {controller: false, height: 300, hu: '', thumbnails: true, width: 440});

		}

}
//////////////////////////////////////////////
function ShowNext(){
var NextVideoData= document.getElementById('hidNext').value;
var Site=GetCurrentSite();

if(IsInShowMode)
 myShow.next();
 
 else
	 {
		if(NextVideoData==-1)
		if(Site=="English")
		alert('No more photos to display in this page');
		else
		alert('لا توجد صور أخرى للعرص فى الصفحة الحالية');
		else if(NextVideoData!="")
		{
	
		var CurrentPosition= document.getElementById('hidCurrent').value;
		
		
		var description= NextVideoData.split('*')[0];
		var img= NextVideoData.split('*')[2];
		var file= NextVideoData.split('*')[3];
		var date= NextVideoData.split('*')[4];
		var GUID= NextVideoData.split('*')[5];
		var OtherTags= NextVideoData.split('*')[6];

		ShowImage(img,description,date);
		SetCurrentVideo(parseInt(CurrentPosition) + 1);
		ShowRelatedItems(GUID);
		FillOtherTagsDiv(OtherTags);

		
		}
	}
}
//////////////////////////////////////////////////
function ShowPrevious(){
var PreviousVideoData= document.getElementById('hidPrevious').value;
var Site=GetCurrentSite();
if(IsInShowMode)
 myShow.prev();
 
 else
	 {

		if(PreviousVideoData==-1)
		if(Site=="English")
		alert('No more photos to display in this page');
		else
		alert('لا توجد صور أخرى للعرض فى الصفحة الحالية');
		
		else if(PreviousVideoData!="")
		{
		var CurrentPosition= document.getElementById('hidCurrent').value;
		
		
		var description= PreviousVideoData.split('*')[0];
		var img= PreviousVideoData.split('*')[2];
		var file= PreviousVideoData.split('*')[3];
		var date= PreviousVideoData.split('*')[4];
		var GUID= PreviousVideoData.split('*')[5];
		var OtherTags= PreviousVideoData.split('*')[6];

		ShowImage(img,description,date);
		SetCurrentVideo(CurrentPosition-1);
		ShowRelatedItems(GUID);
		FillOtherTagsDiv(OtherTags);

		}
	}
}

function ShowFirstImage(){
var Photos= document.getElementById('Videos').value.split('|');
if(Photos[0]=="")
	ShowErrorMessage();
	
	else
	{
	var description= Photos[0].split('*')[0];
var img= Photos[0].split('*')[2];
var file= Photos[0].split('*')[3];
var date= Photos[0].split('*')[4];
var GUID= Photos[0].split('*')[5];
var OtherTags= Photos[0].split('*')[6];

	ShowImage(img,description,date);
	SetCurrentVideo('1');
	ShowRelatedItems(GUID);
	FillOtherTagsDiv(OtherTags);

	}

}
