$(document).ready(function() {
		
	$("a.add_note_button").click(function () { 
		$("div#"+this.id+"_add_note").toggle("normal");
	});
	
	$("a.increase_bw").click(function () {
		$("div#bw").toggle("normal");
	});
	
	$("a.increase_colour").click(function () {
		$("div#colour").toggle("normal");
	});
	
	$("a.increase_lease").click(function () {
		$("div#lease").toggle("normal");
	});
	
	$("a.increase_3d").click(function () {
		$("div#3d").toggle("normal");
	});
	
	$("a.increase_commercial").click(function () {
		$("div#commercial").toggle("normal");
	});
	
	$("input:text, textarea, input:password").each(function(){
		if(this.value == '')
			this.value = this.title;
	});
	$("input:text, textarea, input:password").click(function(){
		if(this.value == this.title)
			this.value = '';
	});
	$("input:text, textarea, input:password").blur(function(){
		if(this.value == '')
			this.value = this.title;
	});
	$("input:image, input:button, button:submit").click(function(){
		$(this.form.elements).each(function(){
			if(this.type =='text' || this.type =='textarea' || this.type =='password'){
				if(this.value == this.title && this.title != ''){
					this.value='';
				}
			}
		});
	});
	
	$.get("./_ui/js/create.php", { load: 'ok' }, function(data){
		$("div#selected_photographs").html(data);
	});
	
	$.get("./_ui/js/change.php", { id: document.getElementById('packages').value, vendor_email: document.getElementById('vendor_email').value }, function(data){
		$("span#package_details").html(data);
	});        
	
	$("select#packages").change(function () {
		//$("span#package_details").html('<br/><br/><img src="./_ui/images/loading.gif" alt="Loading" />');            
		$.get("./_ui/js/change.php", { id: document.getElementById('packages').value, vendor_email: document.getElementById('vendor_email').value }, function(data){
			$("span#package_details").html(data);
		});
	});    
	
	$("input#vendor_email").keyup(function () {
		//$("span#package_details").html('<br/><br/><img src="./_ui/images/loading.gif" alt="Loading" />');            
		$.get("./_ui/js/change.php", { id: document.getElementById('packages').value, vendor_email: document.getElementById('vendor_email').value }, function(data){
			$("span#package_details").html(data);
		});
	});
	
	$("input#add_to_requirements").click(function () {
		//$("span#package_details").html('<br/><br/><img src="./_ui/images/loading.gif" alt="Loading" />');            
		$.get("./_ui/js/create.php", { add: document.getElementById('photos_req').value, title: document.getElementById('photos_req').options[document.getElementById('photos_req').selectedIndex].title  }, function(data){
			$("div#selected_photographs").html(data);
		});
		$.get("./_ui/js/change.php", { id: document.getElementById('packages').value, vendor_email: document.getElementById('vendor_email').value }, function(data){
			$("span#package_details").html(data);
		});        
	});
 });
