// JavaScript Document
function doDialogs(){
	var singleid = $("#singleid");
		   itemid = singleid.val();
		$("#wishlist-form").dialog({
			autoOpen: false,
			height: 300,
			width: 350,
			modal: true,
			buttons: {
				'Add To My Wishlist': function() {
					
					$.ajax({
						   
						   
						   
							method: "get",url: "/new/album_wishlist_save.php",data: "ai="+itemid,
							//beforeSend: function(){$("#albumloading").show("fast");}, 
							//complete: function(){ $("#albumloading").hide("fast");}, 
							success: function(html){ 
							$("#wishlist-form").html(html);
							//$('#wishlist-form').dialog('open');
							//$("#albumcontainer").show("slow"); 
							// 
					 }
				 });
					
					//$(this).dialog('close');
					},
				Cancel: function() {
					$(this).dialog('close');
				}
			},
			close: function() {
				
				//allFields.val('').removeClass('ui-state-error');
			}
		});

		$("#cart-form").dialog({
			autoOpen: false,
			height: 300,
			width: 350,
			modal: true,
			buttons: {
				'Add To Cart': function() {
					
					$.ajax({
							method: "get",url: "/new/wishlist_save.php",data: "ai="+itemid,
							//beforeSend: function(){$("#albumloading").show("fast");}, 
							//complete: function(){ $("#albumloading").hide("fast");}, 
							success: function(html){ 
							$("#wishlist-form").html(html);
							//$('#wishlist-form').dialog('open');
							//$("#albumcontainer").show("slow"); 
							// 
					 }
				 });
					
					$(this).dialog('close');
					},
				Cancel: function() {
					$(this).dialog('close');
				}
			},
			close: function() {
				
				//allFields.val('').removeClass('ui-state-error');
			}
		});
}
function trim(str) { 
    str.replace(/^\s*/, '').replace(/\s*$/, ''); 

   return str;
}

function clickclear(thisfield, defaulttext) {				  
	if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	var cleanstring = thisfield.value;
	if(cleanstring.charAt(0) == ' '){ thisfield.value = defaulttext; }

	if (cleanstring == '') {
	thisfield.value = defaulttext;
	}
}



$(document).ready(function() {
    
	$('.altip img').tooltip({ 
    delay: 0, 
    showURL: false, 
    bodyHandler: function() { 
        return $("<img/>").attr("src", this.src); 
    } 
});	
$('.actiondiv *').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
});


$('.sortdiv *').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
});

	$(".jumpmenu").change(function() {
        var val = document.getElementById('artistmenu').selectedIndex;
		
        if (val != '') {
        var dropdownValue = document.getElementById('artistmenu')[val].value;
		    location.href=dropdownValue;
        }
    });
	$(".jumpmenual").change(function() {
        var val = document.getElementById('albummenu').selectedIndex;
		
        if (val != '') {
        var dropdownValue = document.getElementById('albummenu')[val].value;
		    location.href=dropdownValue;
        }
    });
});

function albumAlphaSort(letter){
	
	$("#alphasort-div").hide("slow");
							//
							
							$.ajax({
							method: "get",url: "/new/albumAlpha_sort.php",data: "sort="+letter,
							beforeSend: function(){$("#alphasort-divloading").show("fast");}, 
							complete: function(){ $("#alphasort-divloading").hide("fast");}, 
							success: function(html){ 
							 
							$("#alphasort-div").show("slow");$("#alphasort-div").html(html); 
					 }
				 }); 
	
	
	}
	
function albumAlphaSortField(letter,dir,field,pagno){
	$("#alphasort-div").hide("slow");
							
		$.ajax({
		method: "get",url: "/new/albumAlpha_sort.php",data: "sort="+letter+"_"+dir+"_"+field+"_"+pagno,
		beforeSend: function(){$("#alphasort-divloading").show("fast");}, 
		complete: function(){ $("#alphasort-divloading").hide("fast");}, 
		success: function(html){ 
		 
		$("#alphasort-div").show("slow");$("#alphasort-div").html(html); 
		}
	}); 
	
	
	}	
function albumSort(dir,field){
	
	$("#albumcontainer").hide("fast");
							//
							
							$.ajax({
							method: "get",url: "/new/basic_album_sort.php",data: "sort="+dir+"_"+field,
							beforeSend: function(){$("#albumloading").show("fast");}, 
							complete: function(){ $("#albumloading").hide("fast");}, 
							success: function(html){ 
							
							$("#albumcontainer").show("slow"); $("#albumcontainer").html(html); 
					 }
				 }); 
	
	
	}
	
function albumPagination(dir,field,pagno){
	$("#albumcontainer").hide("fast");
							//
							
							$.ajax({
							method: "get",url: "/new/basic_album_pag.php",data: "sort="+dir+"_"+field+"_"+pagno,
							beforeSend: function(){$("#albumloading").show("fast");}, 
							complete: function(){ $("#albumloading").hide("fast");}, 
							success: function(html){ 
							
							$("#albumcontainer").show("slow");$("#albumcontainer").html(html);  
					 }
				 });	
	
	
	}
