	apiKey = '510c36557053d5e566dbe59a569c3436';
	userId = '36872097@N03';
	
	function get_images(target,id,heightOrWidth,size){
		//get photoset id number
		id_num = set_id[id];
		
		//get images
		$.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=' + apiKey + '&photoset_id='+ id_num +'&extras=url_o&format=json&jsoncallback=?', function(data){
			$.each(data.photoset.photo, function(i,item){
				//get image information
				img_src = item.url_o;
				img_title = item.title;
				o_width = item.width_o;
				o_height = item.height_o;
				if(!heightOrWidth === undefined) heightOrWidth = heightOrWidth.toLowerCase();
				if(heightOrWidth == "width"){
					new_width = size;
					ratio = new_width/o_width;
					img_width = o_width * ratio;
					img_height = o_height * ratio;
					img = '<img src="'+img_src+'" alt="'+img_title+'" style="height:'+img_height+'px;width:'+img_width+'px;" />';
				}
				if(heightOrWidth == "height"){
					new_height = size;
					ratio = new_height/o_height;
					img_width = o_width * ratio;
					img_height = o_height * ratio;
					img = '<img src="'+img_src+'" alt="'+img_title+'" style="height:'+img_height+'px;width:'+img_width+'px;" />';
				}
				if(heightOrWidth === undefined){
					img = '<img src="'+img_src+'" alt="'+img_title+'" />';
				}
				
				//add image
				$(target).append(img);
			});
			
					var no_of_images = $('#content img').size();

					$.extend(no_of_images);

					if(no_of_images > 0) {

    					var images = new Array();
   					 	var i = 0;
    					$('img').each( function() {
        					images[i] = $(this).attr('src');
        					i++;
    					});

    					i = 0;

    					$(images).each( function(i){
        					var imageObj = new Image();
        					imageObj.src = images[i];
        					$(imageObj).load( function() {
            					no_of_images--;
            					if(no_of_images == 0){
                					$("#cover").fadeOut();
            					}
        					});
    					});
					} else {
    					$("#cover").fadeOut();
					}
		});
	}
	
	function get_info(target,id){
		//get photoset id number
		id_num = set_id[id];
		
		//get info
		$.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getInfo&api_key=' + apiKey + '&photoset_id='+ id_num +'&format=json&jsoncallback=?', function(data){
			$.each(data, function(i,item){
				if(i == "photoset"){
					$(target).append('<div class="info">'+item.description._content+'</div>');
				}
			});
		});
	}
	
	function get_title(target,id){
		//get photoset id number
		id_num = set_id[id];
		
		//get title
		$.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getInfo&api_key=' + apiKey + '&photoset_id='+ id_num +'&format=json&jsoncallback=?', function(data){
			$.each(data, function(i,item){
				if(i == "photoset"){
					$(target).append('<div class="title">'+item.title._content+'</div>');
				}
			});
		});
	}
	
	function get_url(){
		//process url
		the_url = new String(window.location);
		the_url = the_url.split("?");
		page_id = the_url[1];
		return page_id;
	}
	
	function display_sets(target,exclude){
		//process exclude
		if(exclude === undefined) exclude = '';
		exclude = exclude.toLowerCase();
		exclude = exclude.split(',');
		
		//load data from Flickr
		$.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getList&api_key=' + apiKey + '&user_id='+ userId +'&format=json&jsoncallback=?', function(data){
			$.each(data.photosets.photoset, function(i,item){
				//get photoset name
				title = item.title._content;
				title = title.toLowerCase();
				if(jQuery.inArray(title, exclude)){
					//set url
					url = item.title._content;
					//remove symbols
					url = url.replace(/[^A-Za-z ]/g,'');
					//remove spaces
					url = url.replace(/\s/g,"");
					//add link to target
					$(target).append('<a href="?'+url+'" id="'+url+'">'+item.title._content+'</a>');
				}
			});
        });
	}
