$(document).ready(function(){

	$.extend({
  getUrlVars: function(url){
    var vars = [], hash;
    var hashes = url.slice(url.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;
  },
  getUrlVar: function(url,name){
    return $.getUrlVars(url)[name];
  }
});
	
/**
 * Scroll 
 **/
$('.totop').localScroll({duration:650});
var myFile = document.location.toString();
if (myFile.match('#')) { 
  	var myAnchor = '#' + myFile.split('#')[1];
	setTimeout("$.scrollTo($('"+myAnchor+"'), {offset:-200} );",100);	
}

/** 
 * Lightbox 
 **/
var lightbox_config = {
	maxWidth: '100%',
	maxHeight: '100%',
/*	opacity: 0.7,*/
	current: '{current} von {total}',
	prevous: 'Voriges',
	next: 'Nächstes',
	close: 'Schließen'
}

$('.entry img').parent('a[href$=.jpg], a[href$=.png], a[href$=.gif]').each(function (i) {
	id = $(this).parents('.post').attr('id');
	//console.log($(this));
	$(this).addClass('img-link');
	$(this).addClass('img-link').attr('rel',id);
	$(this).addClass('img-link').colorbox(lightbox_config);
});
 
/**
 * YT-Player 
 **/
var videolinks = $('a[title=Flashvideo]');
videolinks.each(function (i) {
file_src = $(this).attr('href')+'&type=image';
image_src = $(this).find('img:first').attr('src');

config = {
	swf: "/wordpress/wp-content/plugins/flash-video-player/mediaplayer/player.swf",
	width: 480,
	height: 360,
	hasVersion: 9,
	expressInstaller:  "/wordpress/wp-content/plugins/flash-video-player/expressinstall.swf",
	params: {
		wmode: 'transparent',
		allowfullscreen: "true",
		allowscriptaccess: "always"					
	},
	flashvars: {
		image: image_src,
		file: file_src,
		width: 480,
		height: 360,
		controlbar: "bottom",
		playlist: "none",
		skin: "/wordpress/wp-content/plugins/flash-video-player/skins/stylish/stylish.swf",
		autostart: "false",
		bufferlength: "1",
		displayclick: "play",
		linktarget: "_blank",
		quality: "true",
		repeat: "none",
		resizing: "true",
		shuffle: "false",
		stretching: "fill",
		volume: "50",
		abouttext: "Robin Schmitz| RS3D.de",
		aboutlink: "http://www.rs3d.de/"
	}
	
};
vimeo = file_src.search(/vimeo.com/);
if (vimeo != -1) {
	config.flashvars.plugins = 'http://www.rs3d.de/media/vimeo.swf';
	config.flashvars.type = 'image';
}

//console.log(config);
$(this).parent('p:first').html('').addClass('flashplayer').flash(config); 
});
 	

/**
 * Search 
 **/
var e = new Object();
e['Suche'] = 'Suche';
if ($("input#s").attr('value') == '') {
	$("input#s").attr('value', e['Suche']);
}
//$("input#s[value='']").attr('value',  e['Suche']);
$('input#s').focus(function(){
   if ($(this).attr('value') == e['Suche']) {
 		$(this).attr('value',  '');
   	}
}).blur(function () {
   	if ($(this).attr('value') == '') {
   		$(this).attr('value',  e['Suche']);
   	}
});

/**
 * Buttons 
 **/
var buttons = 'a.btn, a.more-link, .comments a, a.post-edit-link';
$(buttons).addClass('btn').wrapInner("<span><span></span></span>");
	
var input_button = $('input#searchsubmit');
var submit_txt = input_button.attr('value');
var submit = $('<button class="btn"><span><span>'+submit_txt+'</span></span>');

//$('input#submit').replaceWith(submit);
$('.post input#searchsubmit').replaceWith(submit);


//console.log($('input#submit'));

/**
 * Tooltip
 */
/*
$('h1 a').animate({ 
        opacity:0 
      },0 );
$('h1 a').mouseover(function() {  
     $(this).animate({ 
        opacity: 1
      }, 500 );
 }).mouseout(function() {  
     $(this).animate({ 
        opacity: 0
      }, 0 );
 });  */

/*
$('h1 a').animate({opacity:0},0);
$('h1 a')
  .hover(function(e) {
    $(this).hoverFlow(e.type, { opacity: 1}, 'swing');
  }, function(e) {
    $(this).hoverFlow(e.type, { opacity: 0 }, 'swing');
  });

*/
$('h1 a').attr('title','Home');

$('body').append('<div id="demotip" class="tooltip"><a href="http://www.twitter.com/rs3d" title="Twitter: @rs3d"><img src="/img/t-at-rs3d.gif" alt="Twitter: @rs3d" /></a></div> ');
$('.twitter a').tooltip(
{
	cancelDefault: false,
	delay: 500,
	tip: '.tooltip',
	position: "top left", 
	effect: 'slide',
	direction: 'left',
	slideOffset: 20,
    // another property 
    opacity: 1,
    offset:[60,100]
    
}
);
 


 }); // READY ENDE
