jQuery.noConflict();
jQuery(document).ready(function($){	
								
	$('#logout').click(function(){
		$.ajax({
		   type: "POST",
		   url: "index.php?option=com_ajax&task=logout&format=raw",
		   data: "",
		   success: function(msg)
			{			   
				alert(msg);
				
				if(msg == "Logout Successful")
				{
					window.location = window.location.href;
				}				 
			}
		 });
		
		return false;
	});
    
    $('#lang_switcher' ).select_skin(); 
    
	$("#menuwrp a img").hover(function() {
		$(this).stop().hide().attr("src", $(this).attr("src").split(".").join("_hover.")).show();
	}, function() {
		$(this).stop().attr("src", $(this).attr("src").split("_hover.").join("."));
	});
	
    //mod by maruf on Dec 7 'vd-wrap-body' has been changed to 'vd-wrap-body2'
    // mon by maruf Dec31
	$('.vd-wrap-body2, #loadvideo, #test').click(function(){
		$('#grayBox2').fadeIn('slow');
		$('#video_center').fadeIn('slow');
		return false;
	});
    
    $("#vd-wrap-bodym li a").each(function(){
        $(this).click(function(){
    		$('#grayBox2').fadeIn('slow');
            $("#video-center-outer").show();
    		$('#video_center').fadeIn('slow');
            //var url = $(this).attr('href');
            current_video_url = "http://engelskfotbollfrontend.qbank.se/deployedFiles/85ae750ad1dbdc5c2703bcfe97e77152.flv"
            //playerSetFile(url);
    		return false;
    	});
    });
    
	$('#grayBox2, #video-center-outer').click(function(){			
		$('#video_center').slideUp('medium', function(){
		      $("#video-center-outer").hide();
			  $('#grayBox2').hide();
		});
		
	});
	$('#login-c, #video_center').click(function(e){
		e.stopPropagation();
	});
	$('#grayBox, .cancel').click(function(){	
		resetForm();
		$('#login-c').slideUp('medium', function(){
			$('#grayBox').hide();
		});
		
	});
    
    //load the flash player 
    //modification START Jan 06 , 2010    
   /*
	var s1 = new SWFObject('<?php //echo JURI::base(); ?>flash/videocenter/hype_vid.swf?cache=1252147631950','video-center-container','635','310','9','');
	s1.addParam('base','flash/videocenter/');
	s1.addParam('wmode','transparent');
    s1.addParam('flashvars','titlesColor=0xbf7a0f');
	s1.write('fla_video');
    */
    
    //modification END Jan 06 , 2010
    
    //new code START Jan 13, 2010
    /* video player codes */	
/*	var player;
	function playerReady(obj) 
	{
	   console.log(obj['id'])
	   if(obj['id'] == 'video_player')
        {
            player = document.getElementById(obj['id']);
        }
		
	};
    */
	
	

	/* video player codes end */
    //new code END Jan 13, 2010
	
	function resetForm(){
		$('input[name*="username"]').val('');
		$('input[name*="password"]').val('');		
	}
	
	$('#login-button').click(login);
	$('#loginform').submit(login);
	
	

	
	//functionality for email
	var pemail = $('#pemail').val();
	$('#pemail').focus(function(){
		if($(this).val() == pemail){
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == ''){
			$(this).val(pemail);
		}
	});
	
	function login(){
		//var username = $('#username').val();
		var username = $("input[name='popupusername']").val();
		var password = $("input[name='popuppassword']").val();
		var remember = $("input:checked").length;
		//alert(remember);
		if(username == ""){
			alert('Please Enter Your Username');
			return false;
		}
		if(password == ""){
			alert('Please Enter Your Password');
			return false;
		}
		if(username && password){
			$.ajax({
			   type: "POST",
			   url: "index.php?option=com_ajax&amp;task=login",
			   data: "username=" + username + "&password=" + password + "&remember=" + remember + "&format=raw",
			   success: function(msg){			   
				 alert(msg);
				 if(msg == "Login Successful"){
					window.location = window.location.href;
				 }				 
			   }
			 });
		}
		
		return false;
	}
    //TEMP mod start
    /*$("#footer_left li a").each(function(){
       $(this)
            .text("Kommer snart")
            .attr('href', '#')
            .click(function(){
                return false;
            });       
    });*/
    
    /*$("a#item-79, a#login").click(function(){
                    return false;
                }).css({
                    'cursor' : 'auto'
                }).attr('href', '#'); 
    */
    
    ////TEMP mod start
	
});
var player;
function playerReady(obj) 
{
    if(obj['id'] == 'video_player')
    {
        player = document.getElementById('video_player');
        player.sendEvent("LOAD", current_video_url);
	    player.sendEvent("PLAY","true");  
    }
	
}

var current_video_url = null;

function playerSetFile(file)
{
    //console.log(player);
        
        player = document.getElementById(obj['id']); 
            
        player.sendEvent("LOAD", file);
	    player.sendEvent("PLAY","true");    
    
	
	//window.location.hash = '#pg-title';
}