function getComments(id){
	commentLoader( );
	var url="./includes/classes/product/product-ajax.php?action=getComments&id="+id;
	$.ajax({
	type: "GET",
	  url: url,
	  //data: "?date="+date,
	  cache: false,
	  success: displayComments,
	  error: function(a,b,c){alert(a); alert(b); alert(c)}
	});
}

function displayComments(html){
	getEl('product_comments').innerHTML = html;
}

function saveComment(id){
	var url="./includes/classes/product/product-ajax.php?action=saveComment&id="+id+"&content="+nl2br(getEl('comment_text').value);

/*
	removed as users need to be a member to add comment and user must agree to terms adn condition for become a member.
	if($('#comment_terms_check').attr('checked')) == 'false'){
		var div = createIEElement('div', new Array( ), new Array( ));
		diu.addText('Sorry but you must agree to Kirra Holidays terms and conditions in order to submit a comment to the system.')
	}*/
	commentLoader( );
	$.ajax({
	type: "GET",
	  url: url,
	  //data: "?date="+date,
	  cache: false,
	  success: displayComments
	});
}

function getCommentInput(id){
	commentLoader( );
	var url="./includes/classes/product/product-ajax.php?action=getCommentInput&id="+id;
	$.ajax({
	type: "GET",
	  url: url,
	  //data: "?date="+date,
	  cache: false,
	  success: displayComments
	});
}

function getCommentDisplay(id, page){
	if(blank(page)){
		page = 1;
	}	
	commentLoader( );
	var url="./includes/classes/product/product-ajax.php?action=getCommentDisplay&id="+id+"&_page_products="+page;
	$.ajax({
	type: "GET",
	  url: url,
	  //data: "?date="+date,
	  cache: false,
	  success: displayComments
	});
}



function commentLoader( ){
	displayComments('<table style="width:100%"><tr><td style="text-align:center"><h1>Loading...</h1><br /><img src="./images/loader.gif" alt="loading"/></td></tr></table>');	
}

function submitQuoteRequest(form){

	var data = $(form).serialize();
	submitQuoteRequestLoader( );
	scrollToTop( );
	//submitQuoteRequestLoader( );
	var url="./includes/classes/product/product-ajax.php";
//	var data = $(form).serialize();
	$.ajax({
	type: "POST",
	  url: url,
	 data: data,
	  cache: false,
	  dataType: 'html',
	  success: displayQuoteRequest,
	  async:false,
	  //success: function( ){alert('ass magic');},
	  error: function(a,b,c){alert(a); alert(b); alert(c)}
	});
	
	/*
	
	
	var page = 1;

	commentLoader( );
	var url="./includes/classes/product/product-ajax.php?action=getCommentDisplay&_page_products="+page;
	$.ajax({
	type: "GET",
	  url: url,
	  //data: "?date="+date,
	  cache: false,
	  success: displayComments
	});*/
}


function submitQuoteRequestLoader( ){
	displayQuoteRequest('<table style="width:100%"><tr><td style="text-align:center"><h1>Loading...</h1><br /><img src="./images/loader.gif" alt="loading"/></td></tr></table>');
}

function displayQuoteRequest(body){
	document.getElementById('request-quote-div').innerHTML = body;
}

function basicDialog(title, body){
	var shoppingCartDiv = createIEElement('div', new Array('id', 'class'), new Array('shopping-cart-div', 'shopping-cart-div-class'));
	displayLightBox(10);		
	document.body.appendChild(shoppingCartDiv);
	shoppingCartDiv.innerHTML = '<h1>'+title+'</h1>'+body+'<div style="float:right"><input type="button" class="button" value="Close" onclick="document.body.removeChild(getEl(\'_lightbox_div\'));document.body.removeChild(getEl(\'shopping-cart-div\'));" /></div>';
	
}


function openProductDialog(id){

	if(dickyBrowser( )){
	//if(true){
		var list = document.getElementsByTagName('select');
		for(i=0; i<list.length; i++){
			list[i].style.display = 'none';
		}
	}
	//first we shall create the div to use
	shoppingCartDiv = createIEElement('div', new Array('id', 'class'), new Array('shopping-cart-div', 'shopping-cart-div-class'));	
	document.body.appendChild(shoppingCartDiv);
	//shoppingCartDiv.innerHTML = '<table style="width:100%"><tr><td style="text-align:center"><h1>Loading Cart Interface...</h1><br /><img src="./images/loader.gif" alt="loading"/></td></tr></table>';
	
	//overwrite the properties for the window
	$.jqm.params.overlay = 80;//transparency percentage
	$.jqm.params.overlayClass = 'shopping-cart-lightbox';
	$.jqm.params.ajax = '/includes/classes/product/product-ajax.php?action=productDialog&id='+id;
	$.jqm.params.ajaxText = '<table style="width:100%"><tr><td style="text-align:center"><h1>Loading ...</h1><br /><img src="./images/loader.gif" alt="loading"/></td></tr></table>';
	$.jqm.params.modal = true; //will cause the overlay to be inactive
	//$.jqm.params.type = 'POST';
		
		
	//alert($.jqm.params.ajax);	
	scrollToTop( );
	$('#shopping-cart-div').jqm( );
	$('#shopping-cart-div').jqmShow(); 	
	
	//$('.dialogs').jqm({ajax:'@href',modal:true});
	//$('#dialog').jqmShow();
	//$('#dialog').jqmHide();
}

function getDatePickerDialog(id){
	if(dickyBrowser( )){
		var list = document.getElementsByTagName('select');
		for(i=0; i<list.length; i++){
			list[i].style.display = 'none';
		}
	}
	//first we shall create the div to use
	shoppingCartDiv = createIEElement('div', new Array('id', 'class'), new Array('shopping-cart-div', 'shopping-cart-div-class'));	
	document.body.appendChild(shoppingCartDiv);
	//shoppingCartDiv.innerHTML = '<table style="width:100%"><tr><td style="text-align:center"><h1>Loading Cart Interface...</h1><br /><img src="./images/loader.gif" alt="loading"/></td></tr></table>';
	
	//overwrite the properties for the window
	$.jqm.params.overlay = 80;//transparency percentage
	$.jqm.params.overlayClass = 'shopping-cart-lightbox';
	$.jqm.params.ajax = '/includes/classes/product/product-ajax.php?action=datePicker&id='+id;
	$.jqm.params.ajaxText = '<table style="width:100%"><tr><td style="text-align:center"><h1>Loading ...</h1><br /><img src="./images/loader.gif" alt="loading"/></td></tr></table>';
	$.jqm.params.modal = true; //will cause the overlay to be inactive
	//$.jqm.params.type = 'POST';
		
		
	//alert($.jqm.params.ajax);	
	scrollToTop( );
	$('#shopping-cart-div').jqm( );
	$('#shopping-cart-div').jqmShow(); 	
	
	//$('.dialogs').jqm({ajax:'@href',modal:true});
	//$('#dialog').jqmShow();
	//$('#dialog').jqmHide();
}


