/*
 * Dixzar JavaScript Library
 * http://dixzar.com/
 * Copyright (c) 2009 Conwest Resources
 */

function highlight(field) {  
// first set focus  
  field.focus();  
// select all contents  
  field.select();  
}

$(document).ready(function() {
	
	// new comments
	//$("#new_comment").submit(function(){
	//	$.post($(this).attr("action") + '.js', $(this).serialize(), null, "script");
	//	return false;
	//});
	
	// new rating - submit
	$("#new_rating").submit(function(){
		$.post($(this).attr("action") + '.js', $(this).serialize(), null, "script");
		return false;
	});

	$(".button_stream_expired").qtip({
		content: "<b>Streaming Link Expired</b><hr/>You have 7 days to stream a scene from Dixzar. This stream has expired. You must re-purchase this scene in order to stream it again."});
	$(".button_download_unactive").qtip({
		content: "<b>Download Ready</b><hr/>Download must be initiated within 24 hours from activation.  Click here to activate and begin downloading your scene."});
	$(".button_stream_unactive").qtip({
		content: "<b>Streaming Ready</b><hr/>You can view a video online through streaming for 7 days once activated.  Click here to activate and begin streaming your scene."});
	$(".button_downloading").qtip({
		content: "<b>Download Link Activated</b><hr/>You have activated this download.  You have the indicated time remaining to download this scene."});
	$(".button_streaming").qtip({
		content: "<b>Streaming Link Activated</b><hr/>You have activated this stream.  You have the indicated time remaining to view this scene online."});
	$(".button_download_expired").qtip({
		content: "<b>Download Link Expired</b><hr/>You have 24 hours to download a scene once this link has been activated. This link has expired. You must re-purchase this scene in order to download it again."});

	//
	// Removes ugly dotted borders onclick
	$('a').click(function() {
	  this.blur();
	});

	//
	// Login Modal
	$(function() {
		$('#login-modal').css('display','block')
		$("#login-modal").dialog({
			autoOpen: false,
			modal: true,
			buttons: {
				Login: function() {
					$("form#new_session").submit();
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			},
		});
		
		// Open the Login or Register dialog modal box when clicking on
		$('#login-link').click(function() {
			$('#login-modal').dialog('open');
			return false;
		});
	});


	//
	// Makes table rows clickable to first child url
	$('table.linkable tbody tr')
		.hover(	function() { $(this).addClass('hover'); },
						function() { $(this).removeClass('hover'); }
		)
		.click(function() {
			window.location.href = $('a', this).attr('href');
	});

        // Hide longer descriptions
        $(".description_remainder").hide();
	$(".description_more").click(function(){
		$(".description_start").hide();
		$(".description_more").hide();
		$(".description_remainder").slideToggle(600);
	});

	// The embedd links
        $(".embed_codes").hide();
	$("#embed_links").click(function(){
		$(".embed_codes").slideToggle(600);
	});

	// Bookmark sharing
	$("#share_bookmarks").bookmark({addFavorite: true, addEmail: true, icons: '/images/bookmarks.png', sites: ['aol','ask','bookmarkit','delicious','facebook','google','myspace','plaxo','stumbleupon','twitthis','yahoobm']});

});

