﻿var plugin
var main
var checkMouseInt
var btnNum = 4;
var opacitySpeed =0.04;
var directory="./silverlight/"
var numOfImages=4;
var imgIntArr=new Array() //intervals for checking dims

var num_images_loaded=0

var tilesHolder_left=0;
var tile_img_width=572;
var tile_img_height=292
var tile_spacing=42;
var tile_top=0
var tile_scale=1
var time_to_move=0.6
var pressed=false
var screen_cnt=1
var msg1 ="Uzman eğitmenlerin, konuları derinlemesine ele aldığı Web Seminerlerine, bir bağlantıya tıklayarak Internet üzerinden katılabilirsiniz."
var msg2 ="İş Ortaklarımızın gelişimine en iyi şekilde katkıda bulunabilmek için yıl boyunca sürdürdüğümüz sınıf     eğitimleri hakkında bilgi edinin."
var msg3 ="Teknolojilerin Kullanımı ve verimliliği artırma yönünde çeşitli çözümler ile tanışabilir, daha üretken olmanın yollarını keşfedebilirsiniz."
var msg4 =""
//var msg5 =""
var titlesArr = new Array("a","Web Seminerleri1","Eğitimler","Seminerler","Ağustos'08 Kampı Videoları");
var contensArr = new Array("a", new Array(msg1),new Array(msg2),new Array(msg3), new Array(msg4))
//var Item = new Array();

var objsArr = new Array()
objsArr["Bar1"]=new Object();
objsArr["Bar2"]=new Object();
objsArr["Bar3"]=new Object();
objsArr["Bar4"]=new Object();
//objsArr["Bar5"]=new Object();
objsArr["img_1"]=0;
objsArr["img_2"]=0;
objsArr["img_3"]=0;
objsArr["img_4"]=0;
//objsArr["img_5"]=0;
var fontLoaded=0;

//---------------------------------------------------------------------------------
function mainCanvasLoaded(s) 
{			
	main=s.findName("mainCanvas")
	plugin = s.getHost();
	
	GetList();
	
	main.findName("LoadingBar1").width=0;
	main.findName("LoadingBar2").width=0;
	
}

//---------------------------------------------------------------------------------

function GetList()
{
    PageMethods.GetList( OnCallComplete, OnCallError);
}

function OnCallComplete(result, userContext, methodName) {
	
    
 	var i;
 	for(i=0; i<result.length; i++){
        var editItem = result[i];
        
		if( !editItem )
         continue;
		titlesArr[i+1] = editItem.Title;
	
		var j;
		//contensArr[i+1] = new Array();
		
       	for (j=0; j < editItem.Items.length ; j++)
    	{
      		contensArr[i+1][j+1] = editItem.Items[j].Title;
    	}
    	
//    	for (j=0; j < editItem.Items.length ; j++)
//    	{
//    	    alert(contensArr[i+1][j]);
//    	}
    	
    	
	}
	
	DownloadFont();
}

function OnCallError(error, userContext, methodName) {
    if(error !== null) {
        alert(error.get_message());
    }
}
	
//---------------------------------------------------------------------------------            
       
function DownloadFont(){
	// Create a Downloader object.
    var downloader = plugin.createObject("downloader");
	
    // Add Completed event.
    downloader.addEventListener("Completed", onCompleted);
	downloader.addEventListener("DownloadProgressChanged", onDownloadProgressChanged); 

    // Initialize the Downloader request.
   downloader.open("GET", "silverlight/SEGOEUI.TTF");
   
   // Execute the Downloader request.
    // NOTE: downloader APIs disallow file:\\ scheme
    // you must run this sample over localhost: or off a server or the following call will fail
    downloader.send();
}

function onDownloadProgressChanged(s){
	
	var per=s.downloadProgress;
	fontLoaded =per;
	s.findName("LoadingBar1").width=per*120;
}

function onCompleted(sender, eventArgs) {
	BT1 = main.findName("Bar1Text")
	BT1.setFontSource(sender);
	BT1.fontFamily = "Segoe UI";
	BT1.text=titlesArr[1]
	
	BT2 = main.findName("Bar2Text");
	BT2.setFontSource(sender);
	BT2.fontFamily = "Segoe UI";
	BT2.text=titlesArr[2]
	
	BT3 = main.findName("Bar3Text");
	BT3.setFontSource(sender);
	BT3.fontFamily = "Segoe UI";
	BT3.text=titlesArr[3];

	BT4 = main.findName("Bar4Text");
	BT4.setFontSource(sender);
	BT4.fontFamily = "Segoe UI";
	BT4.text=titlesArr[4];

/*	BT5 = main.findName("Bar5Text");
	BT5.setFontSource(sender);
	BT5.fontFamily = "Segoe UI";
	BT5.text=titlesArr[5];
*/	
	buildImages();		
}
var arrLink = new Array();

function buildImages() {
	
	var tileHolder_str = '<Canvas Name="tilesHolder" Canvas.Left="'+tilesHolder_left+'" Canvas.Top="0" Canvas.ZIndex="10">';	
	
	for(i=1;i<numOfImages+1;i++) {		

		tileHolder_left=(i-1)*tile_spacing  
				
		tileHolder_str +='<Canvas Name="Bar'+i+'_tileHolder" Canvas.Left="'+tileHolder_left+'" Canvas.Top="'+tile_top+'" Visibility="Visible">'
		tileHolder_str +='	<Canvas Name="imgHolder_'+i+'"  >'
		tileHolder_str +='		<Image Loaded="imgLoaded" DownloadProgressChanged="imageProgressChanged" Opacity="0" Name="img_'+i+'" Stretch="Fill" MouseEnter="tileEnter" MouseLeave="tileLeaveX" Source="'+directory+"screen"+i+'.jpg" />'
        if(i==1){
		    tileHolder_str += '       <Rectangle Name="imgREC1_1" Width="600" Height="292" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="0" Canvas.Top="0" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT1_1" Width="300" Height="139" Canvas.Left="20" Canvas.Top="10" FontFamily="Segoe UI" FontSize="30" Foreground="#FFBA131A" Text="'+titlesArr[i]+'" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT1_0" Width="300" Height="100" Canvas.Left="20" Canvas.Top="50" FontFamily="Segoe UI" FontSize="10" Foreground="#FF000000" Text="'+contensArr[i][0]+'" TextWrapping="Wrap"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT1_2" Width="150" Height="20" Canvas.Left="20" Canvas.Top="100" FontFamily="Segoe UI" FontSize="10" Foreground="#FFBC121B" FontWeight="Bold" Text= "Arşiv için tıklayınız" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    arrLink[1] = "List.aspx?type=1";
		    arrLink[2] = "default.aspx?p=WebSeminerleri";
		}
        if(i==2){
            tileHolder_str += '       <Rectangle Name="imgREC2_3" Width="600" Height="292" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="0" Canvas.Top="0" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT2_3" Width="300" Height="139" Canvas.Left="20" Canvas.Top="10" FontFamily="Segoe UI" FontSize="30" Foreground="#FFBA131A" Text="'+titlesArr[i]+'" TextWrapping="Wrap"  MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT2_0" Width="300" Height="100" Canvas.Left="20" Canvas.Top="'+50+'" FontFamily="Segoe UI" FontSize="10" Foreground="#FF000000" Text="'+contensArr[i][0]+'" TextWrapping="Wrap"/>'
			tileHolder_str += '       <TextBlock Name="imgTXT21_3" Width="300" Height="24" Canvas.Left="20" Canvas.Top="'+(85 +(1*15))+'" FontFamily="Segoe UI" FontSize="10" Foreground="#FFBC121B" FontWeight="Bold" Text= "Sınıf Eğitimleri için tıklayınız" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
			tileHolder_str += '       <TextBlock Name="imgTXT2_4" Width="300" Height="20" Canvas.Left="20" Canvas.Top="'+(85 +(2*15))+'" FontFamily="Segoe UI" FontSize="10" Foreground="#FFBC121B" FontWeight="Bold" Text= "Kişisel Beceri Eğitimleri için tıklayınız" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
			tileHolder_str += '       <TextBlock Name="imgTXT2_5" Width="300" Height="20" Canvas.Left="20" Canvas.Top="'+(85 +(3*15))+'" FontFamily="Segoe UI" FontSize="10" Foreground="#FFBC121B" FontWeight="Bold" Text= "Arşiv için tıklayınız" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    arrLink[3] = "List.aspx?type=2";
		    arrLink[4] = "List.aspx?type=3";
		    arrLink[5] = "default.aspx?p=SinifEgitimleri";
        }
        if(i==3){
		    tileHolder_str += '       <Rectangle Name="imgREC3_6" Width="600" Height="292" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="0" Canvas.Top="0" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT3_6" Width="300" Height="139" Canvas.Left="20" Canvas.Top="10" FontFamily="Segoe UI" FontSize="30" Foreground="#FFBA131A" Text="'+titlesArr[i]+'" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
            tileHolder_str += '       <TextBlock Name="imgTXT3_0" Width="300" Height="100" Canvas.Left="20" Canvas.Top="'+50+'" FontFamily="Segoe UI" FontSize="10" Foreground="#FF000000" Text="'+contensArr[i][0]+'" TextWrapping="Wrap"/>'
            tileHolder_str += '       <TextBlock Name="imgTXT3_7" Width="150" Height="20" Canvas.Left="20" Canvas.Top="100" FontFamily="Segoe UI" FontSize="10" Foreground="#FFBC121B" FontWeight="Bold" Text= "Arşiv için tıklayınız" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
            arrLink[6] = "List.aspx?type=4";
            arrLink[7] = "default.aspx?p=Seminerler";
        }

        if(i==4){
            arrLink[8] = "http://silverlight.services.live.com/19934/Analitik CRM - Cavit Yanta%c3%a7/video.wmv";
            arrLink[9] = "http://silverlight.services.live.com/19934/Core IO'ya Giri%c5%9f ve WS 2008 - Selma Karaca, Murat Song%c3%bcr/video.wmv";
            arrLink[10] = "http://silverlight.services.live.com/19934/Dynamics CRM, Bizofiz - Tarkan G%c3%bcy%c3%bck/video.wmv";
            arrLink[11] = "http://silverlight.services.live.com/19934/Sanalla%c5%9ft%c4%b1rma - K%c3%bcr%c5%9fat G%c3%b6k/video.wmv";
            
            tileHolder_str += '       <Rectangle Name="imgREC4_8" Width="110" Height="134" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="32" Canvas.Top="100" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
            tileHolder_str += '       <Rectangle Name="imgREC4_9" Width="110" Height="134" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="160" Canvas.Top="100" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
            tileHolder_str += '       <Rectangle Name="imgREC4_10" Width="110" Height="134" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="286" Canvas.Top="100" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
            tileHolder_str += '       <Rectangle Name="imgREC4_11" Width="110" Height="134" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="414" Canvas.Top="100" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_0" Width="500" Height="100" Canvas.Left="30" Canvas.Top="10" FontFamily="Segoe UI" FontSize="28" Foreground="#FFBA131A" Text="MS Gelişim Atölyesi Kampı-Videolar" TextWrapping="Wrap"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_8" Width="110" Height="40" Canvas.Left="55" Canvas.Top="81" FontFamily="Segoe UI" FontSize="11" Foreground="#FFB92834" Text="Analitik CRM" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_00" Width="110" Height="40" Canvas.Left="58" Canvas.Top="245" FontFamily="Segoe UI" FontSize="11" Foreground="#FF0E396C" Text="Cavit Yantaç" TextWrapping="Wrap" Opacity="10"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_9" Width="110" Height="20" Canvas.Left="165" Canvas.Top="68" FontFamily="Segoe UI" FontSize="11" Foreground="#FFB92834" Text="Core IO\'ya Giriş ve" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT41_9" Width="70" Height="20" Canvas.Left="190" Canvas.Top="81" FontFamily="Segoe UI" FontSize="11" Foreground="#FFB92834" Text="WS 2008" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_000" Width="80" Height="40" Canvas.Left="178" Canvas.Top="245" FontFamily="Segoe UI" FontSize="11" Foreground="#FF0E396C" Text="Selma Karaca, Murat Songür" TextWrapping="Wrap" Opacity="80"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_10" Width="110" Height="20" Canvas.Left="300" Canvas.Top="68" FontFamily="Segoe UI" FontSize="11" Foreground="#FFB92834" Text="Dynamics CRM," TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT41_10" Width="70" Height="20" Canvas.Left="320" Canvas.Top="81" FontFamily="Segoe UI" FontSize="11" Foreground="#FFB92834" Text="Bizofiz" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_0000" Width="110" Height="40" Canvas.Left="305" Canvas.Top="245" FontFamily="Segoe UI" FontSize="11" Foreground="#FF0E396C" Text="Tarkan Güyük" TextWrapping="Wrap" Opacity="80"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_11" Width="110" Height="40" Canvas.Left="432" Canvas.Top="81" FontFamily="Segoe UI" FontSize="11" Foreground="#FFB92834" Text="Sanallaştırma" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT4_00000" Width="110" Height="40" Canvas.Left="440" Canvas.Top="245" FontFamily="Segoe UI" FontSize="11" Foreground="#FF0E396C" Text="Kürşat Gök" TextWrapping="Wrap" Opacity="80"/>'
        }
/*
        if(i==5){
		    tileHolder_str += '       <Rectangle Name="imgREC5_12" Width="600" Height="292" Fill="#FFFFFFFF" Opacity="0" Canvas.Left="0" Canvas.Top="0" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown" Cursor="Hand"/>'
		    tileHolder_str += '       <TextBlock Name="imgTXT5_12" Width="400" Height="139" Canvas.Left="135" Canvas.Top="10" FontFamily="Segoe UI" FontSize="30" Foreground="#FFBA131A" Text="'+titlesArr[i]+'" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
            tileHolder_str += '       <TextBlock Name="imgTXT5_0" Width="300" Height="100" Canvas.Left="20" Canvas.Top="'+50+'" FontFamily="Segoe UI" FontSize="10" Foreground="#FF000000" Text="'+contensArr[i][0]+'" TextWrapping="Wrap"/>'
            //tileHolder_str += '       <TextBlock Name="imgTXT5_7" Width="150" Height="20" Canvas.Left="20" Canvas.Top="100" FontFamily="Segoe UI" FontSize="10" Foreground="#FFBC121B" FontWeight="Bold" Text= "Arşiv için tıklayınız" TextWrapping="Wrap" MouseLeftButtonDown="hyperlink_MouseLeftButtonDown"  MouseEnter="hyperlink_MouseEnter" MouseLeave="hyperlink_MouseLeave" Cursor="Hand"/>'
            arrLink[12] = "/GelisimAtolyesiKampi";
        }
  */      
		tileHolder_str +=		'	</Canvas>'
		
		tileHolder_str +=		'</Canvas>'	
	
	}

	tileHolder_str += '</Canvas>';	   
	        //document.write(tileHolder_str);
	tileHolderTag=plugin.content.createFromXaml(tileHolder_str)
	main.children.add(tileHolderTag)

}


function hyperlink_MouseLeftButtonDown(s) {
	var index = s.name.split("_")[1];
	//var index = s.name.split("_")[2];
	//alert(index);
	window.location = arrLink[index];
    /*if(index==1){
        window.location = "List.aspx?type=1";}
        //window.location = "default.aspx?p=WebSeminerleri";}
	else if(index==2){
	    window.location = "default.aspx?p=WebSeminerleri";}
        //window.location = "default.aspx?p=SinifEgitimleri";}
	else if(index==3){
	    window.location = "List.aspx?type=2";}
        //window.location = "default.aspx?p=KisiselBeceriEgitimleri";}
	else if(index==4){
	    window.location = "default.aspx?p=Seminerler";}
	else if(index==5){
	    window.location = "http://silverlight.services.live.com/19934/Analitik CRM - Cavit Yanta%c3%a7/video.wmv";}
	else if(index==6){
	    window.location = "http://silverlight.services.live.com/19934/Core IO'ya Giri%c5%9f ve WS 2008 - Selma Karaca, Murat Song%c3%bcr/video.wmv";}
	else if(index==7){
	    window.location = "http://silverlight.services.live.com/19934/Dynamics CRM, Bizofiz - Tarkan G%c3%bcy%c3%bck/video.wmv";}
	else if(index==8){
	    window.location = "http://silverlight.services.live.com/19934/Sanalla%c5%9ft%c4%b1rma - K%c3%bcr%c5%9fat G%c3%b6k/video.wmv";}
	else{window.location = "List.aspx?type="+index;}
	*/
}

function imageProgressChanged(s, eventArgs){
	var per=s.downloadProgress;
	objsArr[s.name] = per;
	getProgress();
}

function getProgress(){
	var totalper=(objsArr["img_1"]+objsArr["img_2"]+objsArr["img_3"]+objsArr["img_4"])/(numOfImages);
	main.findName("LoadingBar2").width=totalper*80;
	if(totalper==1) {
		//initiliaze();	
	}
}

function imgLoaded(s) {

	var tempName;
	tempName=""+s.name;
	s.opacity=0;	
	imgIntArr["int"+s.name]=setInterval("checkImgDims('"+tempName+"')",10)	
}


function checkImgDims(nstr) {

	imgRef=main.findName(nstr)
	
	if(imgRef.width>0 && imgRef.height>0) {
		if(num_images_loaded<numOfImages){
			num_images_loaded++
		}
		imgRef.width=tile_img_width;
		imgRef.height=tile_img_height
		imgRef.opacity=1;
		
		if(num_images_loaded==3){
			initiliaze();			
		}
		
		clearInterval(imgIntArr["int"+nstr]);

	}
	
}

function initiliaze(){
 	loadRef=main.findName("Loading")
	loadRef.opacity=0;
	loadRef.visibility="Collapsed"
	animatePress()
	checkMouseInt=setInterval("animatePress()",5000)
}


function buttonEnter(s) {
	//s.opacity=0.7
}

function buttonLeave(s) {
		//s.opacity=0.15
}

function hyperlink_MouseEnter(sender,args)
{
   sender.opacity = 0.7;
}

function hyperlink_MouseLeave(sender,args)
{
   sender.opacity = 1;
}

function animatePress(){
	handleButtonPress(btnNum);
	btnNum++;
	if(btnNum==numOfImages+1){
		btnNum = 1
	}
	
}
function buttonPress(s,e) {
	var index = s.name.split("r")[1];
	handleButtonPress(index);	
	btnNum = parseFloat(index)+1;
	if(btnNum==numOfImages+1){
		btnNum = 1
	}
	clearInterval(checkMouseInt);
	checkMouseInt=setInterval("animatePress()",5000)
	//alert(btnNum);
}
function handleButtonPress(ind) {
	    var index = ind;
	    
		for(i=1;i<numOfImages+1;i++) {
			bars=main.findName("Bar"+i+"Grup");
			bars.opacity=1;	
			bars.visibility="Visible";
		}

		var numsPosX = new Array([0,0],[0,-tile_spacing],[0,0],[0,0],[0,0],[0,0],[0,0])
	
		for(i=1;i<numOfImages+1;i++) {

			bar=main.findName("Bar"+i+"Grup");
			numsPosX[i][0] = bar["Canvas.Left"];
			numsPosX[i][1] += numsPosX[i-1][1]+tile_spacing;
			if(i==2){
				numsPosX[i][1]=numsPosX[i][1]-2;
			}
			if((i).toString()==index){
				numsPosX[i+1][1] = tile_img_width-tile_spacing
	 		}	
			
			
		}

            	
		holder1 = objsArr["Bar1"];
		barG1 = main.findName("Bar1Grup");
		barTH1 = main.findName("Bar1_tileHolder");
		
		holder1.tweenX = new Tween(new Object(),'x',Tween.regularEaseOut, numsPosX[1][0], numsPosX[1][1] ,time_to_move)
		
		holder1.tweenX.onMotionChanged = function(event){	
			
			barG1["Canvas.Left"] = event.target._pos;
			barTH1["Canvas.Left"] = event.target._pos;
			
			if(index==1){
				barG1.opacity-=opacitySpeed;
			}
		}
		holder1.tweenX.onMotionFinished = function(event){
			showContent(index)
		}
			
		holder1.tweenX.start()	
		//---------------------------------------------//
		holder2 = objsArr["Bar2"];
		barG2 = main.findName("Bar2Grup");
		barTH2 = main.findName("Bar2_tileHolder");
		holder2.tweenX = new Tween(new Object(),'x',Tween.regularEaseOut, numsPosX[2][0], numsPosX[2][1] ,time_to_move)
		
		holder2.tweenX.onMotionChanged = function(event){	
			
			barG2["Canvas.Left"] = event.target._pos
			barTH2["Canvas.Left"] = event.target._pos;
			if(index==2){
				barG2.opacity-=opacitySpeed;
			}
		}
		holder2.tweenX.onMotionFinished = function(event){
			showContent(index)
		}

		holder2.tweenX.start()	
		//---------------------------------------------//
		holder3 = objsArr["Bar3"];
		barG3 = main.findName("Bar3Grup");
		barTH3 = main.findName("Bar3_tileHolder");
		holder3.tweenX = new Tween(new Object(),'x',Tween.regularEaseOut, numsPosX[3][0], numsPosX[3][1] ,time_to_move)
		
		holder3.tweenX.onMotionChanged = function(event){	
			
			barG3["Canvas.Left"] = event.target._pos
			barTH3["Canvas.Left"] = event.target._pos;
			if(index==3){
				barG3.opacity-=opacitySpeed;
			}
		}
		holder3.tweenX.onMotionFinished = function(event){
			showContent(index)
		}

		holder3.tweenX.start();		
		
		//---------------------------------------------//
		holder4 = objsArr["Bar4"];
		barG4 = main.findName("Bar4Grup");
		barTH4 = main.findName("Bar4_tileHolder");
		holder4.tweenX = new Tween(new Object(),'x',Tween.regularEaseOut, numsPosX[4][0], numsPosX[4][1] ,time_to_move)
		
		holder4.tweenX.onMotionChanged = function(event){	
			
			barG4["Canvas.Left"] = event.target._pos
			barTH4["Canvas.Left"] = event.target._pos;
			if(index==4){
				barG4.opacity-=opacitySpeed;
			}
		}
		holder4.tweenX.onMotionFinished = function(event){
			showContent(index)
		}

		holder4.tweenX.start();	
		
		//---------------------------------------------//
        /*		
		holder5 = objsArr["Bar5"];
		
		barG5 = main.findName("Bar5Grup");
		barTH5 = main.findName("Bar5_tileHolder");
		holder5.tweenX = new Tween(new Object(),'x',Tween.regularEaseOut, numsPosX[5][0], numsPosX[5][1] ,time_to_move)
		
		holder5.tweenX.onMotionChanged = function(event){	
			
			barG5["Canvas.Left"] = event.target._pos
			barTH5["Canvas.Left"] = event.target._pos;
			if(index==5){
				barG5.opacity-=opacitySpeed;
			}
		}
		holder5.tweenX.onMotionFinished = function(event){
			showContent(index)
		}

		holder5.tweenX.start();		
		*/
		//---------------------------------------------//
	
}

function showContent(ind){

	//alert(s.name)
	var currentBtn=btnNum-1
	if(currentBtn==0){
		currentBtn=4
	}
	if(ind==currentBtn){
		bar = main.findName("Bar"+ind+"Grup")
		bar.visibility="Collapsed"
	}
	else{
		bar = main.findName("Bar"+ind+"Grup")
		bar.opacity=1;
	}
}

function getSWF(swWidth, swHeight, swFile, swWmode) {
    var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width=' + swWidth + ' height=' + swHeight + ' VIEWASTEXT>';
    str += '<param name="movie" value="' + swFile + '" />';
    str += '<param name="quality" value="high" />';
    // wmode = window, transparent, opaque
    str += '<param name="wmode" value="' + swWmode + '" />';
    str += '<param name="menu" value="false" />';
    str += '<embed src="' + swFile + '" width=' + swWidth + ' height=' + swHeight + ' menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
    document.write(str);
}




