// variables
var $ = jQuery.noConflict(); 
var listIsOpen = false;

// document ready function
$(document).ready(function() {
  
// set height function starts   
    function fixHeight () {
        	
        	var headerHeight = $("#headerWrap").height();
        	    
				
        	$("#iframe").attr("height", ($(window).height() - headerHeight + 5) + 'px');
        	
    }
// set height function ends          	
// window resize function starts			
    $(window).resize(function () {
               	
        	fixHeight();
        	
    }).resize();
// window resize function ends        	
// select theme/template button function starts			
    $("#selectTemplateBtn").click( function () {
        	
        	if (listIsOpen == true) {
        	
        	$(".templatesList").animate({ 
                                 height: "hide"
                                 },150);
        		
        	listIsOpen = false;
        		
        	} else {
        		
        	$(".templatesList").animate({ 
                                 height: "show"
                                 },150);         		
        		
        	listIsOpen = true;
        		
        	}
        		
        	return false;
        	
    });
// select theme/template button function ends			
// templates/themes list items hover starts			
    $(".templatesList a").hover(function() {   
            $(this).stop().animate({ 
                                 marginLeft: "5px"
                                 },50);
            },function(){
            $(this).stop().animate({
                                 marginLeft: "0px"
                                 },250);
    });
// templates/themes list items hover ends			
// template/theme selected function	starts		
    $(".templatesList a").click(function () {
        	
        	var theme_data = $(this).attr("rel").split(",");
        	        	
			$(".removeFrame").attr("href", theme_data[0]);
			
        	$(".purchase").attr("href", theme_data[1]);
        	$("#iframe").attr("src", theme_data[0]);
        	
        	$(".templatesListWrap a#selectTemplateBtn").text($(this).text());
        	
        	$(".templatesList").animate({ 
                                 height: "hide"
                                 },150);
        	
        	listIsOpen = false;
        	
        	return false;       	
    });
// template/theme selected function	ends			
}); //ducument ready function ends
