$(document).ready(function() {

	//SITE SEARCH
	$('.search :input').focus(function() {
		if(this.value == this.defaultValue) {
			this.value = '';
		}
	}).blur(function() {
		if(!this.value.length) {
			this.value = this.defaultValue;
		}
	});
	
	//DROPDOWN MENUS
	
	var dd_1 = 0;
	var dd_2 = 0;
	
	$('.dd h2').hover(function() {
		$(this).css({ cursor:'pointer' });
		$(this).css({ textDecoration:'underline' });
	}, function(){
		$(this).css({ textDecoration:'none' });
	});
	
	$('#dd-1 h2').click(function() {
		if(dd_1 == 0) {
			$('#dd-2 ul').hide();
			$('#dd-2 h2').removeClass('select');
			$(this).addClass('select');
			$(this).siblings('ul').show();
			dd_1 = 1;
			dd_2 = 0;
		} else {
			$(this).removeClass('select');
			$(this).siblings('ul').hide();
			dd_1 = 0;
		}
	});
	
	$('#dd-2 h2').click(function() {
		if(dd_2 == 0) {
			$('#dd-1 ul').hide();
			$('#dd-1 h2').removeClass('select');
			$(this).addClass('select');
			$(this).siblings('ul').show();
			dd_2 = 1;
			dd_1 = 0;
		} else {
			$(this).removeClass('select');
			$(this).siblings('ul').hide();
			dd_2 = 0;
		}
	});
	
	//SKIMMER PANELS

	
	$('#expand-panel .more').hover(function() {
		$(this).css({ cursor:'pointer' });
	}, function(){
		
	});
	
	$('#other-ways .more').hover(function() {
		$(this).css({ cursor:'pointer' });
	}, function(){
		
	});
	
	$('#step1 .more').toggle(function() {
		$(this).text('Hide');
		$(this).css({ backgroundPosition:'100% 0' });
		$(this).siblings('.extra').slideDown();
	}, function() {
		$(this).text('Don\'t want to install anything?');
		$(this).css({ backgroundPosition:'100% -200px' });
		$(this).siblings('.extra').slideUp();
	});
	
	$('#stepie .more').toggle(function() {
		$(this).text('Hide');
		$(this).css({ backgroundPosition:'100% 0' });
		$(this).siblings('.extra').slideDown();
		$.scrollTo('400px', 800);
	}, function() {
		$(this).text('Step-by-step instructions');
		$(this).css({ backgroundPosition:'100% -200px' });
		$(this).siblings('.extra').slideUp();
		$.scrollTo(0, 400);
	});
	
	$('#stepsf .more').toggle(function() {
		$(this).text('Hide');
		$(this).css({ backgroundPosition:'100% 0' });
		$(this).siblings('.extra').slideDown();
	}, function() {
		$(this).text('A bit more info?');
		$(this).css({ backgroundPosition:'100% -200px' });
		$(this).siblings('.extra').slideUp();
	});
 	$('#other-ways .more').toggle(function() {
		$(this).text('Hide');
		$(this).css({ backgroundPosition:'100% 0' });
		$(this).parent().siblings('.extra').slideDown();
	}, function() {
		$(this).text('More options?');
		$(this).css({ backgroundPosition:'100% -200px' });
		$(this).parent().siblings('.extra').slideUp();
	});
	
	$('.prg2 .content').hide();
	
	$('.prg2 .show').toggle(function() {
		$(this).text('Hide&nbsp;&#x25bc;');
		$(this).parent().siblings('.content').slideDown();
	}, function() {
		$(this).text('Show&nbsp;&#x25bc;');
		$(this).parent().siblings('.content').slideUp();
	});


	
	$('#display_option #showoptions').toggle(function() {
	  if ($(this).text == 'Show display options +'){
		$(this).text('Hide display options -');
		$(this).siblings('#sort').slideDown();
	  } else {
		$(this).text('Show display options +');
		$(this).siblings('#sort').slideUp();	  
	  }
	}, function() {
	 if ($(this).text == 'Hide display options '){
		$(this).text('Show display options +');
		$(this).siblings('#sort').slideUp();
	  } else {
		$(this).text('Hide display options -');
		$(this).siblings('#sort').slideDown();	  
	  }
	});


	$('#imageContainer').cycle({
	 fx : 'fade',
	 speed : 4000
	});
	
	$('#advanced').hide();
	
	var adv_down = false;
	
	$('#adv_show').click(function() {
	  if (adv_down==false){
		$(this).text('Hide settings -');
		$('#advanced').slideDown();
		adv_down=true;
		return false;
	  } else {
		$(this).text('Show settings +');
		$('#advanced').slideUp();
		adv_down=false; 
		return false;
	  }
	});
	
	var tips = true;
	
	$('#tipsswitch').click(function(){
	 if (tips==true){
	  tips=false;
	  $('#tipsswitch').text('Turn tips on');
	  return false;
	 } else {
	  tips=true;
	  $('#tipsswitch').text('Turn tips off');
	  return false;	 
	 }
	});


	$('#help1').hide();
	
	$('#project_name').focus(function(){
	  if (tips==true){
		$('#help1').fadeIn('slow');
		$('#help5').hide(); shown = false;
		$(this).css('color', '#333;');
	  }
	});
	$('#project_name').blur(function(){
		$('#help1').hide();
	});	
	
	
	
	$('#help2').hide();
	
	$('#project_description').focus(function(){
	  if (tips==true){
		$('#help2').fadeIn('slow');
		$('#help5').hide(); shown = false;
		$(this).css('color', '#333;');
	  }
	});
	$('#project_description').blur(function(){
		$('#help2').hide();
	});	
	
	
	
	$('#help3').hide();
	
	$('#project_type').focus(function(){
	  if (tips==true){
		$('#help3').fadeIn('slow');
		$('#help5').hide(); shown = false;
		$(this).css('color', '#333;');
	  }
	});
	$('#project_type').blur(function(){
		$('#help3').hide();
	});	
	
	
	
	$('#help4').hide();
	
	$('#sharing').focus(function(){
	 if (tips==true){
		$('#help4').fadeIn('slow');
		$('#help5').hide(); shown = false;
		$(this).css('color', '#333;');
	 }
	});
	$('#sharing').blur(function(){
		$('#help4').hide();
	});	



	$('#help5').hide();
	var shown = false;
	
	$('#criterias').click(function(){
	 if (tips==true){
	  if (shown==false) {
		$('#help5').fadeIn('slow');
		$(this).css('color', '#333;');
		shown = true;
	  } else {
		$('#help5').hide();
		shown = false;	    
	  }
	 }
	});

	var rank_down=false;

	$('#rankrest').click(function() {
	  if (rank_down==false){
		$(this).text('Hide the rest -');
		$('#rank_hidden').slideDown();
		rank_down=true;
		return false;
	  } else {
		$(this).text('Show the rest +');
		$('#rank_hidden').slideUp();
		rank_down=false; 
		return false;
	  }
	});
    $.fn.createDialog.defaults = {
        progress: true,
        center: true,
        opacity: 0.7,
        index: 2000,
        method: 'GET',
        data: '',
        bg: '#FFF'
	}


    $("#close").click(function() { $.closeDialog(); });
    
   	$("#iebook").createDialog({
		addr: 'vids/ie-bookmark/index.html',
		bg: '#000000'
	});
 
 	$("#firebook").createDialog({
		addr: 'vids/firefox-bookmark/index.html',
		bg: '#000000'
	});

   	$("#firebook2").createDialog({
		addr: 'vids/firefox-bookmark/index.html',
		bg: '#000000'
	});
 
 	$("#fireadd").createDialog({
		addr: 'vids/firefox-addon/index.html',
		bg: '#000000'
	});

	$("#chrome").createDialog({
		addr: 'vids/chrome-bookmark/index.html',
		bg: '#000000'
	});
 	$("#chrome2").createDialog({
		addr: 'vids/chrome-bookmark/index.html',
		bg: '#000000'
	});

	$("#safari").createDialog({
		addr: 'vids/safari-bookmark/index.html',
		bg: '#000000'
	});
 	$("#safari2").createDialog({
		addr: 'vids/safari-bookmark/index.html',
		bg: '#000000'
	});
 
     $("#header_upper").click(function(){
     $.closeDialog();
     });


});


