/**
 * Reel, http://
 * Copyright (c)2009, CSD
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright       		Qrupa
 * @backenddeveloper		Piotr Kaniuk
 * @frontedndeveloper		Krzysztof Safjanowski
 * @license         		http://www.opensource.org/licenses/mit-license.php The MIT License
 */


/* 
 * jQuery JavaScript Library v1.3.2 
 */
$( window ).load( function () {
  	/* 
 	 * Dropdown menu
	 */
	$( '#header-menu > li > ul' ).css(
	{
		'top': ( $( '#header-menu > li > a' ).height() + parseInt( $( '#header-menu > li > a' ).css( 'padding-top' ) ) + parseInt( $( '#header-menu > li > a' ).css( 'padding-bottom' ) ) -1 )+ 'px'
	});
	
	$( '#header-menu > li' ).hover( function()
	{
		$( this ).find( 'ul' ).css(
		{
			'display': 'block'
		});
	}, function()
	{
		$( this ).find( 'ul' ).css(
		{
			'display': 'none'
		});
	});



	/*
	 * Rollover images
	 */
	jRollover.rollover.init();
	jRollover.rollover.preload();
	

});



$( function()
{
    
    

    
	/*
	 * Scroll Pane
	 */
	$( '#sidebar-video ul.sidebar-video-list' ).jScrollPane(
	{
		dragMaxHeight: 30
	});
	
	
	
	/*
	 * jCarousel fix
	 */
	$( '.jcarousel-clip-horizontal > ul' ).css(
	{
	    width: $( this ).width()
	});



	/*
	 * ?
	 */
	$( '#main-body-results ul li' ).hover( function()
	{
		$( this ).addClass( 'active' );
	}, function()
	{
		$( this ).removeClass( 'active' );
	});



	/*
	 * ?
	 */
	$( '#footer dl.partners-menu dd a').append('<span></span>');
	$( '#sidebar-video .sidebar-video-header ul li:odd, #sidebar-search-box .sidebar-search-box-header ul li:odd' ).addClass( 'odd' );


	
	/*
	 * Popup
	 */
	$( 'div.popup' ).hide();
	$( 'div.popup .close a' ).click(function(e)
	{
		e.preventDefault();
		$( 'div.popup' ).hide();
	});
	

	$( '#add-to-playlist-popup' ).click(function(e)
	{
		e.preventDefault();
		$( 'div.popup' ).hide()
		$( '#add-to-my-playlist' ).show();
	});

    
    $( '#add-to-channel-popup' ).click(function(e)
    {
        e.preventDefault();
        $( 'div.popup' ).hide()
        $( '#add-to-channel' ).show();
    });
    
    $( '#remove-from-playlist-popup' ).click(function(e)
    {
        e.preventDefault();
        $( 'div.popup' ).hide()
        $( '#remove-from-my-playlist' ).show();
    });

    
    $( '#remove-from-channel-popup' ).click(function(e)
    {
        e.preventDefault();
        $( 'div.popup' ).hide()
        $( '#remove-from-channel' ).show();
    });

	
	$( '#share-popup' ).click(function(e)
	{
		e.preventDefault();
		$( 'div.popup' ).hide()
		$( '#share-and-bookmark' ).show();
	});

    $( '#rate-popup' ).click(function(e)
    {
        e.preventDefault();
        $( 'div.popup' ).hide()
        $( '#give-rating' ).show();
    });

    


	/* 
	 * Focus & blur on input#header-form-seach-phrase 
	 */
	var sHeaderFormSeachPhrase = $( '#header-form-seach-phrase' ).val();

	$( '#header-form-seach-phrase' ).focus(function()
	{
		if( ( $( this ).val() ) == sHeaderFormSeachPhrase )
		{
			//disabled on request $( this ).val( '' );
		}
	}).blur(function()
	{
		if( ( $( this ).val() ) == sHeaderFormSeachPhrase || ( $( this ).val() ) == '' )
		{
			$( this ).val( sHeaderFormSeachPhrase );
		}
	});
    
    
    
    /*
     * Make link in login box behave like submit button
     */
     
    $('#header-form-login-submit').click(function(e) {
        e.preventDefault();    
        $('form#header-form-login').submit();
    });

    
    // detect enter on header login form
    
    $('.login_input').keypress(function(e){
        if(e.which == 13){
            $('form#header-form-login').submit();
        }
    });
    
    
    
    
});

function shopredirect(){
    window.location = "shop.php"
}



/* DISABLED
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}

var hash = getUrlVars(); 

var flashvars = {
    id: "../files/2005/flv/" + hash['id'] + ".flv"
};

var params = {
    wmode: "opaque" 
};

var attributes = {};

//swfobject.embedSWF("swf/main-video.swf", "main-video", "640", "380", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);

*/