var x;

var y;

var curx;

var cury;
//LIGHTBOX
$(document).ready(function() {
open("http://shafeek-dance.com/gallery/091.JPG");
links = $("a[rel=lightbox]");					   
$("a[rel=lightbox]").click(function(event) {
  event.preventDefault();
links.each( function( index ) {
    var link = $( this );
    link.click( function( c ) {
        c.preventDefault();
        open( link.attr( 'href' ) );
        links.filter( '.selected' ).removeClass( 'selected' );
        link.addClass( 'selected' );
    } );
    link.attr( {'lb-position': index} );
} );

});

						   })
function open(img_src)
{
var e = document.getElementById('screen');
$("#waiter").fadeIn();
e.style.display = "none";
e.src = img_src;
$(e).load(function () {
e.style.width = "auto";
e.style.height = "auto";
 $("#waiter").fadeOut(function(){
            $(e).fadeIn("slow")
        });

});
}


$(window).resize(function() {

		wheight();

		move(curx, cury);

		$('.scrollable').tinyscrollbar();    

		

});



var winheight = $(window).height();	

function wheight() {

	 winheight = $(window).height();	

	if (winheight<700){

		winheight=700;

		$('#pagewrapper').css('height',winheight)

	}

	else{

		$('#pagewrapper').css('height',winheight)

	}

						   }





function move(x,y)

{

	$(".hidden_img").animate({opacity:0, left:-50},100)

	/*wid = $(window).width();*/

	$("#shuffler").stop();



	var wid = $('#pagewrapper').width();

	var heig = $('#pagewrapper').height();

	var osax=-(x*wid)-wid;

	var osay=-(y*heig)-heig;

	

	$('#shuffler').animate({

        left:osax,

		top:osay

    },700, 'linear', function(){$(".hidden_img").animate({opacity:1, left:0},1000)}

		);

		cury=y;

		curx=x;

	/*currnum=num;*/

	/*currdist=num*wid;*/

	

}

var vid;

function videochange(vid){

	document.getElementById("video").src = vid;

	}

var wid;

var idecko='2';



function setactive(num) {

								  $('.active').removeClass("active");

								  idecko = '#m-id'+num;

								  $(idecko).addClass("active"); }

					   

$(window).ready(function() {

$(".hidden_menu").animate({opacity:1, top:20},2000);	

$(".shafeek").animate({opacity:1, left:50, top:10},2000);

})
	

var a;
var b;
window.onload = function(){
		
	
	$(".player_out").click(function(){$(".player_out").css('visibility','hidden');
											stopVideo()				
															});	
	$(".vid_container > a").click(function(){$(".player_out").css('visibility','visible');})
	
	
	a = $(".vid_container > a");
    for(var i=0; i<a.length; i++){
        if(!/#ytplayer/.test(a[i].href)) continue;
        var link = a[i].innerHTML.match(/\/vi\/([^\/]+)/);
        if(link) (function(vidId){
            a[i].onclick = function(){
                player.loadVideoById(vidId);
				
            }
        })(link[1]);
    }
					
}

// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
var player;

function onYouTubePlayerAPIReady() {
    player = new YT.Player('player', {
        height: '390',
        width: '640',
        videoId: 'r2tAHKQCF9k',
        events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
        }
    });
}

// 4. The API will call this function when the video player is ready.


function onPlayerReady(event) {
	$('.scrollable').tinyscrollbar();
  //  event.target.playVideo();
}

// 5. The API calls this function when the player's state changes.
//    The function indicates that when playing a video (state=1),
//    the player should play for six seconds and then stop.
var done = false;

function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
        setTimeout(stopVideo, 6000);
        done = true;
		
    };
	
}

function stopVideo() {
    player.stopVideo();
}


$(document).ready(function() {
						   

		wheight();						   

	

$('.back').click(function () {

								  $('.el_in > a').removeClass("active");

								  $('#m-id7').addClass("active"); });

$('.el_in > a').click(function () {

								  $('.el_in > a').removeClass("active");

								  $(this).addClass("active"); });



$('.scrollable').tinyscrollbar();

})

function getdata(what,where) { // get data from source (what)

 try {

   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():

  		new ActiveXObject("Microsoft.XMLHTTP");

 }

 catch (e) { /* do nothing */ }



 document.getElementById(where).innerHTML ="<img style='margin-top:40px;' src='/images/load.gif'>";

// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)

 ajaxdestination=where;

 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV

 xmlhttp.open("GET", what);

 xmlhttp.send(null);

  return false;

}



function triggered() { // put data returned by requested URL to selected DIV

  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 

    document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;

}
