/*
OPS AJAX CALL FUNCTION
Date: 17 January 2008
Author: Ashley Glover
Copyright One Part Scisors, 2008


NOTES / MODIFICATIONS:
First line, "setTimeout("initLightbox()", 1);" initiates the lightbox effect gallery tool, used on easylife gallery revision, jan 2008
*/


function getPageJQ(page,stchoice,direction,sortby,currentlot) {

	jQuery(function($j) {  
					 	if (page == "1") {
							$('queryheading').innerHTML = "Welcome to the Easylife Kitchens Gallery!";
						} else 	if (page == "2") {
							$('queryheading').innerHTML = "All Built-in Cupboards";
						} else 	if (page == "3") {
							$('queryheading').innerHTML = "All Bathroom Vanities";
						} else 	if (page == "4") {
							$('queryheading').innerHTML = "All Studies & Bars";
						} else 	if (page == "5") {
							$('queryheading').innerHTML = "All Islands";
						} else 	if (page == "*") {
							$('queryheading').innerHTML = "The Entire Easylife Gallery";
						} else {
							$('queryheading').innerHTML = page;
						}
						
						if (!sortby) {
							sortby == "uploaddate";
						} else {
							if (sortby == "rating") {
								if ($('sortedby')) {
								$('sortedby').innerHTML = "Rating";
								} else {
								$('filler').innerHTML = "";
								}
							}
							if (sortby == "uploaddate") {
								if ($('sortedby')) {
								$('sortedby').innerHTML = "Recently Added";
								} else {
								$('filler').innerHTML = "";
								}
							}
							if (sortby == "category") {
								if ($('sortedby')) {
								$('sortedby').innerHTML = "Category";
								} else {
								$('filler').innerHTML = "";
								}
							}
						}

		$j("#queryresult").load(direction,{section: page, stylechoice: stchoice, sortby: sortby,currentlot: currentlot});
		});  
		$j().ajaxSend(function(r,s){  
		$j("#queryresultHOLD").show();  
		});  
		$j().ajaxStop(function(r,s){  
		$j("#queryresultHOLD").fadeOut("fast");  
	});
}


function getPageAboutJQ(page) {
	jQuery(function($j) {  
		$j("#CompanyInfo").load(page);
		});  
		$j().ajaxSend(function(r,s){  
		$j("#queryresultHOLD").show();  
		});  
		$j().ajaxStop(function(r,s){  
		$j("#queryresultHOLD").fadeOut("fast");  
	});
	
}

function showmeContacts(details) {
	// alert(details)
	if (!details) {
		details = "full";
	}
	jQuery(function($j) {  
		$j("#contactInfo").load("contactInfo.php",{details: details});  
	//	});  
	//	$j().ajaxSend(function(r,s){  
	//	$j("#loadingcontacts").show();  
	//	});  
	//	$j().ajaxStop(function(r,s){  
	//	$j("#loadingcontacts").fadeOut("fast"); 
		$j("#contactInfo").show();
	});
	new Effect.ScrollTo($('top'), {offset: -24});

}
function showassocs(arraylist,current,title) {	
	jQuery(function($j) {  
		$j("#contactInfo").load("showassocs.php",{arraylist: arraylist,current: current,title:title});  
	//	});  
	//	$j().ajaxSend(function(r,s){  
	//	$j("#loadingcontacts").show();  
	//	});  
	//	$j().ajaxStop(function(r,s){  
	//	$j("#loadingcontacts").fadeOut("fast"); 
		$j("#contactInfo").show();
	});
	new Effect.ScrollTo($('top'), {offset: -24});

}
function hideContacts(whatof) {
	new Effect.Fade ($(whatof));	
}
function appearer(whatof) {
	new Effect.Appear ($(whatof), {from:'0.0-0.75'});	
}
function hider(whatof) {
	new Effect.Fade ($(whatof));	
}

function emailoptions(branchname, areafrom, emailaddress) {
	new Effect.Appear ($('contactOptions'));
	new Effect.BlindDown('contactFormFRM');
	$('branchnamer').innerHTML = branchname;
	$('branchnamer2').innerHTML = branchname;
	$('branchnamer3').innerHTML = branchname;
	document.contactFormFRM.branchname.value = branchname;
	document.contactFormFRM.areafrom.value = areafrom;
	document.contactFormFRM.emailaddress.value = emailaddress;
	$('emailerlinker').href = "mailto:" + emailaddress + '?subject=Website Enquiry - Ref: ' + areafrom;
}
function emailbranch () {
	branchname = document.contactFormFRM.branchname.value;
	areafrom = document.contactFormFRM.areafrom.value;
	emailaddress = document.contactFormFRM.emailaddress.value;
	alert(output);
}

//   contact_form
function formbranch() {
	new Effect.BlindDown ($('contactForm'));
}
wf.showAlertOnError = false;
wf.functionName_formValidation = "myCustomValidation";
function myCustomValidation (evt) {
	if(wf.formValidation(evt)) new Ajax.Updater('result', 'send.php',{onLoading:function(request){sendmail()},onComplete:function(request){handelrequest()},parameters:Form.serialize(document.forms['contactFormFRM']), insertion:Insertion.Bottom, asynchronous:true});
	return wf.utilities.XBrowserPreventEventDefault(evt);
}
function sendmail() {
	//Make the Progress Bar Appear
	new Effect.Appear('progress');
}
function handelrequest() {
	new Effect.Fade('progress');
	new Effect.BlindUp('contactFormFRM');
	new Effect.Appear('result');
	setTimeout('new Effect.Fade("contactOptions")', 6000);
	setTimeout('new Effect.Fade("contactInfo")', 6000);
	// $('contactForm').style = display

}
function toggleAbout(whatof) {
	new Effect.BlindUp ($('ServicesInfo'), {queue: 'front'});
	new Effect.BlindDown ($('ServicesInfo'), {queue: 'end'});
}
function scrollup () {
	new Effect.ScrollTo($('top'), {offset: -24});	
}
