/*
 * SimpleModal Basic Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: basic.js 212 2009-09-03 05:33:44Z emartin24 $
 *
 */
jQuery.noConflict();
jQuery('#added-to-basket').ready(function () {
	if(jQuery('#added-to-basket').length > 0) {
		jQuery('#added-to-basket').hide();
		jQuery('#added-to-basket').modal();
	};
});


jQuery('#product-modal').live('click',function () {
 	jQuery.getJSON('/templatemethods/image','id=1410', function(json){
		
		jQuery.modal(json.image);
		
	});
});


/**
 * Open a URL in a modal window.
 * 
 * @param string elemID The name of the element to write the modal content into.
 * @param string URL    The URL to read the content from.
 * @param Object Opts	an object containing simplemodal options.
 * 
 * @return Void
 */
function modalPopup(elemID,URL,Opts){
	
	LoadAnim = jQuery('#'+elemID+'-loading');
	ModalContent = jQuery('#'+elemID);

	if(ModalContent.length){
       	if (LoadAnim.length) {
       		LoadAnim.show();
    	}
       	jQuery.ajax( {
			type : "GET",
			url : URL,
			success : function(result) {
				ModalContent.hide();
				ModalContent.html(result);
				ModalContent.modal(Opts);
				if (LoadAnim.length)LoadAnim.hide();
				return ModalContent;
			},
       		error: function(){
       			return false;
       		}
		});
	}else{
		return false;
	}
	
}


/**
 * Open a URL in a modal window.
 * 
 * @param string elemID The name of the element to write the modal content into.
 * @param string URL    The URL to read the content from.
 * @param Object Data	An object containing vars to post to the URL.
 * @param Object Opts	An object containing simplemodal options.
 * 
 * @return Void
 */
function modalPost(elemID,URL,Data,Opts){
	
	 if ( Opts === undefined ) Opts = {};
	 if ( Data === undefined ) Data = {};
	
	LoadAnim = jQuery('#'+elemID+'-loading');
	ModalContent = jQuery('#'+elemID);

	if(ModalContent.length){
       	if (LoadAnim.length) {
       		LoadAnim.show();
    	}
       	jQuery.ajax( {
			type : "POST",
			url : URL,
			data: Data,
			success : function(result) {
				ModalContent.hide();
				ModalContent.html(result);
				ModalContent.modal(Opts);
				if (LoadAnim.length)LoadAnim.hide();
				return ModalContent;
			},
       		error: function(){
       			return false;
       		}
		});
	}else{
		return false;
	}
	
}

