$().ready(function() {

    $(window).load(function () {
        
        if(jQuery().pngFix) {
            $(document).pngFix();
        }
        
        if(jQuery().preloadCssImages) {
            $.preloadCssImages();
        }
        
        if(jQuery().easySlider) {
            
            
            $("#banner_home").slideDown('slow');
            //$("#slider ul").slideDown(2000);
        	$("#slider").easySlider({
        		auto: true, 
        		continuous: true, 
                pause: 10000,  
                speed: 1000, 
                numeric: true
        	});
            
        }
        
        $(".portfolio_page").hide().delay('500').slideDown('slow');
    
    });
    
    if(jQuery().fancybox) {
    	$(".fancybox").fancybox({
    		'width'				: '70%',
    		'height'			: '75%',
    		'autoScale'			: false,
    		'transitionIn'		: 'none',
    		'transitionOut'		: 'none',
    		'type'				: 'iframe'
    	});
      
    	$(".fancybox_gallery").fancybox({
    		'transitionIn'	:	'elastic',
    		'transitionOut'	:	'elastic',
    		'speedIn'		:	600, 
    		'speedOut'		:	200, 
    		'overlayShow'	:	false
    	});
   }
    
    $(".payment_form_loading").hide();
    //$("#payment_form").hide();
	$("#payment_form_submit").click(function() {
	    $(".payment_form_loading").show();
        $("#payment_form").hide();
	});
    
    $('#card_type').change(function() {
        
        if( ($(this).val() == 'Maestro' ) || ($(this).val() == 'Solo' ) ){
            $("#show_issue_no").slideDown();
        }else{
            
            // Reset the issue number
            $('#issue_no').val('') ;
            
            // Then slide up to hide
            $("#show_issue_no").slideUp();
        }
        
    });
    
    $("#upload_image").show();
    $(".image_uploading").hide();
	$("#upload_image").click(function() {
	    $(".image_uploading").show();
        $("#upload_image").hide();
	});
    
    $('#change_user_id').change(function() {
    
        alert('Importing advertisers default contact details.');
        window.location = $(this).attr('title')+$(this).val();
        return false;
    });
    
	$(".thumbs, .clicks").click(function() {
		window.location=$(this).find("a").attr("href");return false;
	});

    $('#edit_user_id').change(function() {
        
    });
    
    $('#search, .per_line, .search_button').focus(function() {
      $(this).val('');
    });

    $(".change_password").hide();
	$(".show_password").click(function() {
	    $(".hide_password").hide();
		$(".change_password").show();
	});
    
	$(".password_cancel").click(function() {
	    $(".hide_password").show();
		$(".change_password").hide();
	});
    
	$.ajaxSetup ({  
		cache: false  
	});
    
    $('.action_delete').click(function(event) {
        var answer = confirm('Are you sure you want to complete this task?');
        
        if (answer){
                
            var hideID = $(this).attr('id');
            var loadUrl = $(this).attr('title');
        
    		$.get(
    			loadUrl,
    			{language: "php", version: 5},
    			function(responseText){
                    alert(responseText);
                    location.reload();
    			},
    			"html"
    		);
            
            
        }else{
            
        }
        
        return false;
    }) 
    
    $('.action_status').click(function(event) {
        var answer = confirm('Are you sure you want to change this status?');
        
        if (answer){
                
            var hideID = $(this).attr('id');
            var loadUrl = $(this).attr('title');
        
    		$.get(
    			loadUrl,
    			{language: "php", version: 5},
    			function(responseText){
                    alert(responseText);
                    location.reload();
    			},
    			"html"
    		);
            
            
        }else{
            
        }
        
        return false;
    })

    if(jQuery().lightBox) {
        $('.gallery_thumbs a').lightBox();
        $('.form_comments a').lightBox();
        $('.branded_logos a').lightBox();
    }
    
});
