// JavaScript Document
function clickclear(thisfield) {
  if (thisfield.value == 'search...') {
    thisfield.value = "";
	 document.getElementById('change').style.color = '#000000';
  }
}
 
function clickrecall(thisfield) {
  if (thisfield.value == "") {
   thisfield.value = 'search...';
    document.getElementById('change').style.color = '#C8C8C8';
  }
}

function DisableButton(id){
	$('input[type=submit]#'+id).val('Processing...');
	$('input[type=submit]#'+id).attr('disabled', 'disabled');
}

function ask(){
	var ans = confirm('Do you want to delete?')
	
	if(ans)
		return true;
	else
		return false;
}

function product_slideShow() {
	//Set the opacity of all images to 0
	$('#product_gallery a').css({opacity: 0.0});
	//Get the first image and display it (set it to full opacity)
	$('#product_gallery a:first').css({opacity: 0.7});
	//Set the caption background to semi-transparent
	$('#product_gallery .caption').css({opacity: 0.7});
	//Resize the width of the caption according to the image width
	$('#product_gallery .caption').css({width: $('#product_gallery a').find('img').css('width')});
	//Get the caption of the first image from REL attribute and display it
	$('#product_gallery .content').html($('#product_gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('product_gallery()',6000);
}

function product_gallery() {
	//if no IMGs have the show class, grab the first image
	var current = ($('#product_gallery a.show')?  $('#product_gallery a.show') : $('#product_gallery a:first'));
	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#product_gallery a:first') :current.next()) : $('#product_gallery a:first'));	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	//Set the opacity to 0 and height to 1px
	$('#product_gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#product_gallery .caption').animate({opacity: 1},100 ).animate({height: '100px'},500 );
	//Display the content
	$('#product_gallery .content').html(caption);
}

function event_slideShow() {
	//Set the opacity of all images to 0
	$('#event_gallery a').css({opacity: 0.0});
	//Get the first image and display it (set it to full opacity)
	$('#event_gallery a:first').css({opacity: 1.0});
	//Set the caption background to semi-transparent
	$('#event_gallery .caption').css({opacity: 0.7});
	//Resize the width of the caption according to the image width
	$('#event_gallery .caption').css({width: $('#event_gallery a').find('img').css('width')});
	//Get the caption of the first image from REL attribute and display it
	$('#event_gallery .content').html($('#event_gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('event_gallery()',6000);
}

function event_gallery() {
	//if no IMGs have the show class, grab the first image
	var current = ($('#event_gallery a.show')?  $('#event_gallery a.show') : $('#event_gallery a:first'));
	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#event_gallery a:first') :current.next()) : $('#event_gallery a:first'));	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	//Set the opacity to 0 and height to 1px
	$('#event_gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#event_gallery .caption').animate({opacity: 1},100 ).animate({height: '100px'},500 );
	//Display the content
	$('#event_gallery .content').html(caption);
}
