
	function hide(div)
	{
		$(div).style.display = 'none';	
	}
	function toggledisplay(nr)
	{	
		$(nr).style.display = $(nr).style.display == 'none' ? 'block' : 'none';
	}
	function setdisplay(nr,display)
	{	
		$(nr).style.display = display;
	}
	function openpopup(href)
	{
		window.open(href,'mywindow','width=400,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no');
	}
	function opentinypopup(href)
	{
		window.open(href,'mywindow','width=10,height=10,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no');
	}
	
	function showimageattachment(id)
	{
		window.open('showImage.php?openinwindow=true&table=image_attachment&row_id='+id,'preview','width=600,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no');
	}
	
	
function valbutton(radiobutton,name) {
	// place any other field validations that you require here
	// validate myradiobuttons
	myOption = -1;
	for (i=radiobutton.length-1; i > -1; i--) {
		if (radiobutton[i].checked) {
			myOption = i; i = -1;
		}
	}
	if (myOption == -1) {
		alert("You must select a "+name);
		return false;
	}
	return true;
}
	
	
	
	
	function showAddForm()
	{
		$('copyright-notice').style.display = 'block';
	}

		
	function addToCart()
	{
		var url = 'index.php?url=cart&ajax=true&action=ADD';
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
		var pars = Form.serialize('form_add_to_cart');
		if (!document.forms['form_add_to_cart'].size)
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: addToCartResponse, onFailure: ajaxfailed} );
		else if (valbutton(document.forms['form_add_to_cart'].size,'size'))
		{
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: addToCartResponse, onFailure: ajaxfailed} );
		}
	}	
	function addToCartResponse (originalRequest) {
		var newData = originalRequest.responseText;
		$('added-to-cart').innerHTML = newData;
		new Effect.Appear('added-to-cart');
		new Effect.Fade('copyright-notice',{duration:1});
	    new Effect.Appear('checkout-menu-link');
		setTimeout("new Effect.Fade('added-to-cart');",6000);
	}
	/*==================================================================*\
	| AJAX Stuff 
	\*==================================================================*/
			
		function ajaxloading()
		{
			$('load').style.display = 'block';
		}
		function ajaxslowloading()
		{
			Effect.Appear('load',{duration:0.5});
		}
		function ajaxfailed()
		{
			alert('ajax failed');	
		}
		
		/*==================================================================*\
		| Find-Photographers
		\*==================================================================*/
		function findPhotographers (pagenum) {
			var url = 'index.php?url=find-photographer&pagenum='+pagenum;
			var pars = Form.serialize('form_find_photographers');
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxloading, onComplete: findPhotographersResponse, onFailure: ajaxfailed} );
		}
		function findPhotographersResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			Effect.Appear('results',{duration:0.4});
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
		}
		function showPhotographerCategory (category_id) {
			var categorySelect = document.forms['form_find_photographers'].style;
			for (i=0;i<categorySelect.options.length;i++){
			 if (categorySelect.options[i].value==category_id) categorySelect.selectedIndex = i; }
			 $('region').style.display = 'none';
			 $('region_box').checked = false;
			 $('style_div').style.display = 'block';
			 $('style_box').checked = true;
			 var pars = Form.serialize('form_find_photographers');
			var url = 'index.php?url=find-photographer';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxloading, onComplete: findPhotographersResponse, onFailure: ajaxfailed} );
		}
		function showPhotographerCategories () {
			var url = 'index.php?url=find-photographer&ajax=true';
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		function showPhotographerContactForm(member_id)
		{
			var url = 'index.php?url=find-photographer&contactform='+member_id;
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: contactformLoading, onComplete: contactformResponse, onFailure: ajaxfailed} );	
		}
		function contactformLoading()
		{
			$('contact-form').style.display = 'block';	
		}
		function contactformResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('contact-form-form').innerHTML = newData;			
		}
		function contactformsend(member_id)
		{
			var url = 'index.php?url=find-photographer&contactform='+member_id;
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var pars = Form.serialize('form_contact_member');
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: contactformSending, onComplete: contactformSent, onFailure: ajaxfailed} );
		}
		function contactformSending()
		{
			$('contact-form-sending').style.display = 'block';	
		}
		function contactformSent (originalRequest) {
			var newData = originalRequest.responseText;
			$('contact-form').innerHTML = newData;
			$('contact-form-sending').style.display = 'none';
			setTimeout("$('contact-form-sending').style.display = 'none';",100);
		}
		
		/*==================================================================*\
		|  Find-Prints
		\*==================================================================*/
		function findPrints (pagenum) {
			var url = 'index.php?url=find-print&pagenum='+pagenum;
			var pars = Form.serialize('form_find_prints');
			$('results').style.display = 'none';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxloading, onComplete: findPrintsResponse, onFailure: ajaxfailed} );
		}
		function findPrintsResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			Effect.Appear('results',{duration:0.5});
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
		}
		function showPrintCategories (category_id) {
			hideTip();
			var url = 'index.php?url=find-print&ajax=true';
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		function showPrintCategory (category_id) {
			hideTip();
			var categorySelect = document.form_find_prints.cat;
			for (i=0;i<categorySelect.options.length;i++){
			 if (categorySelect.options[i].value==category_id) categorySelect.selectedIndex = i; }
			 $('cat').style.display = 'block';
			 $('cat_box').checked = true;
			 var pars = Form.serialize('form_find_prints');
			var url = 'index.php?url=find-print';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		function showPrintDetails (print_id) {
			hideTip();
			var url = 'active_pages/image-details.php?ajax=true&getPrintDetails='+print_id;
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: findPrintsResponse, onFailure: ajaxfailed} );
		}
		
		/*==================================================================*\
		| Find-Stock
		\*==================================================================*/
		function findStock (pagenum) {
			var url = 'index.php?url=find-stock&pagenum='+pagenum;
			$('results').style.display = 'none';
			var pars = Form.serialize('form_find_stock');
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxslowloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		function findStockResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			Effect.Appear('results',{duration:0.5});
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
			setTimeout("$('results').style.display = 'block';",1000);
		}
		function showStockCategories (category_id) {
			hideTip();
			var url = 'index.php?url=find-stock&ajax=true';
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		function showStockCategory (category_id) {
			hideTip();
			var categorySelect = document.form_find_stock.category;
			for (i=0;i<categorySelect.options.length;i++){
			 if (categorySelect.options[i].value==category_id) categorySelect.selectedIndex = i; }
			 $('cat').style.display = 'block';
			 $('cat_box').checked = true;
			 var pars = Form.serialize('form_find_stock');
			var url = 'index.php?url=find-stock';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		function showStockDetails (stock_id) {
			hideTip();
			var url = 'active_pages/image-details.php?ajax=true&getStockDetails='+stock_id;
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: findStockResponse, onFailure: ajaxfailed} );
		}
		
		/*==================================================================*\
		| Suppliers
		\*==================================================================*/
		function getsuppliers(pagenum)
		{
			$('contact-details').style.display = 'none';	
			$('pagenum').value = pagenum;
			if (pagenum >= lastpage) { $('span_nextpage').style.display = 'none'; $('span_nextpage_nolink').style.display = 'inline';  $('span_nextpage2').style.display = 'none'; $('span_nextpage_nolink2').style.display = 'inline'; }
			else { $('span_nextpage').style.display = 'inline'; $('span_nextpage_nolink').style.display = 'none'; $('span_nextpage2').style.display = 'inline'; $('span_nextpage_nolink2').style.display = 'none'; }
			if (pagenum <= 1) { $('span_prevpage').style.display = 'none'; $('span_prevpage_nolink').style.display = 'inline';$('span_prevpage2').style.display = 'none'; $('span_prevpage_nolink2').style.display = 'inline'; }
			else { $('span_prevpage').style.display = 'inline'; $('span_prevpage_nolink').style.display = 'none'; $('span_prevpage2').style.display = 'inline'; $('span_prevpage_nolink2').style.display = 'none'; }
			var url = 'index.php?url=suppliers&ajax=true&page='+pagenum;
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxslowloading, onComplete: getsuppliersResponse, onFailure: ajaxfailed} );	
		}
		function getsuppliersResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('supplier_table').innerHTML = newData;
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
		}
		function showSupplierDetails(supplier_id)
		{
			var url = 'index.php?url=suppliers&contactdetails='+supplier_id;
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: contactdetailsLoading, onComplete: contactdetailsResponse, onFailure: ajaxfailed} );	
		}
		function contactdetailsLoading()
		{
			$('contact-details').style.display = 'block';	
		}
		function contactdetailsResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('contact-details').innerHTML = newData;			
		}
		
		/*==================================================================*\
		| Portfolio
		\*==================================================================*/
		function getPortfolioImages (member_id,pagenum) {
			var url = 'index.php?url=portfolio&getimages='+member_id+'&pagenum='+pagenum;
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: getPortfolioImagesResponse, onFailure: ajaxfailed} );
		}
		function getPortfolioImagesResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
		}
		
		function getMiniPortfolioImages (member_id,pagenum) {
			hideTip();
			var url = 'index.php?url=portfolio&items_per_page=5&nocontrols=true&getimages='+member_id+'&pagenum='+pagenum;
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: getMiniPortFolioImagesloading, onComplete: getMiniPortfolioImagesResponse, onFailure: ajaxfailed} );
			$('miniresults').style.display = "none";
			/*Effect.Fade('miniresults');*/
		}
		function getMiniPortFolioImagesloading()
		{
			//$('miniload').style.display = 'block';
		}
		function getMiniPortfolioImagesResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('miniresults').innerHTML = newData;
			new Effect.BlindDown('miniresults',{duration:0.5});
			//$('miniload').style.display = 'none';
			setTimeout("$('miniload').style.display = 'none';",100);
		}
		
		function getImageDetails(image_id)
		{
			var url = 'index.php?url=image-details&ajax=true&getstockdetails='+image_id;
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: getImageDetailsResponse, onFailure: ajaxfailed} );
		}
		function getImageDetailsResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			getMiniPortfolioImages($('member_id').value,1);
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
			
		}
		function getOnlyImageDetails(image_id)
		{
			var url = 'index.php?url=image-details&ajax=true&getstockdetails='+image_id+'&justimage=true';
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: getOnlyImageDetailsResponse, onFailure: ajaxfailed} );
		}
		function getOnlyImageDetailsResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('div_image_details').innerHTML = newData;
			/*getMiniPortfolioImages($('member_id').value,1);*/
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
			
		}
		function getPrintDetails(image_id)
		{
			var url = 'index.php?url=image-details&ajax=true&getprintdetails='+image_id;
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: getPrintDetailsResponse, onFailure: ajaxfailed} );
		}
		function getPrintDetailsResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
			getMiniPortfolioImages($('member_id').value,1);
			
		}
		function getOnlyPrintDetails(image_id)
		{
			var url = 'index.php?url=image-details&ajax=true&getprintdetails='+image_id+'&justimage=true';
			try{ if ($('pv1').value == 'true') url = '../'+url;} catch(err) {}
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: getOnlyPrintDetailsResponse, onFailure: ajaxfailed} );
		}
		function getOnlyPrintDetailsResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('div_image_details').innerHTML = newData;
			/*getMiniPortfolioImages($('member_id').value,1);*/
			$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);
			
		}
		
		function getGalleryImages (category,pagenum) {
			var url = 'index.php?url=gallery&getimages=true&pv1='+category+'&pagenum='+pagenum;
			if ($('pv1').value == 'true') url = '../'+url;
			var myAjax = new Ajax.Request( url, {method: 'get', onLoading: ajaxloading, onComplete: getGalleryImagesResponse, onFailure: ajaxfailed} );
		}
		function getGalleryImagesResponse (originalRequest) {
			var newData = originalRequest.responseText;
			$('results').innerHTML = newData;
			Effect.Fade('load');
			setTimeout("$('load').style.display = 'none';",100);
		}
		
		function showResourcesSubcategory (subcategory) {
			var url = 'index.php?url=resources-library&getresults='+subcategory;
			var myAjax = new Ajax.Request( url, {method: 'get', onComplete: showResourcesSubcategoryResponse, onFailure: ajaxfailed} );
		}
		function showResourcesSubcategoryResponse (originalRequest) {
			var newData = originalRequest.responseText;
			jQuery.noConflict();
			try { $("elephant").innerHTML = newData } catch(err) { alert(err); }
			/*$('load').style.display = 'none';
			setTimeout("$('load').style.display = 'none';",100);*/
		}
			