var MivaMerchant = {
	init: function(){
		var mivaScreen = document.body.id;
		mivaScreen = mivaScreen.replace(/-/g, "");
		if( MivaMerchant[ mivaScreen ] )
		{
			$( document ).ready(function()
			{ 
				MivaMerchant[mivaScreen](); // If the function exists, run it, otherwise, don't do anything (like Jeff).
			}); 
		}
	},
	
	home: function()
	{
		$('.tab-video').colorbox({width:670, height: 520});

        $( '.testimonial-text' ).not( ':first' ).hide();

        $( '#headblade-testimonial-vid' ).hover(
            function()
            {
                $( '.testimonial-text' ).hide();
                $( '#headblade-testimonial' ).show();
            },
            function(){}
        );
        $( '#scotte-testimonial-vid' ).hover(
            function()
            {
                $( '.testimonial-text' ).hide();
                $( '#scotte-testimonial' ).show();
            },
            function(){}
        ); 
        $( '#directfix-testimonial-vid' ).hover(
            function()
            {
                $( '.testimonial-text' ).hide();
                $( '#directfix-testimonial' ).show();
            },
            function(){}
        ); 
        $( '#durrani-testimonial-vid' ).hover(
            function()
            {
                $( '.testimonial-text' ).hide();
                $( '#durrani-testimonial' ).show();
            },
            function(){}
        );

        $('#whos-using-mm li a').colorbox();
	},
	

	
	ecommercehosting: function()
	{
		$( "#saas-content li a" ).tooltip( { effect: 'slide' } );
		$( "#saas-tabs-nav" ).tabs( ".saas-panel" );
		
		function readCookie(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		};
		
		var partner = readCookie('partner');
		
		if ( partner )
		{
			$( '#saas-boutique a' ).attr( 'href', '/saas/boutique/paypal' );
			$( '#saas-marketplace a' ).attr( 'href', '/saas/marketplace/paypal' );
			$( '#saas-warehouse a' ).attr( 'href', '/saas/warehouse/paypal' );
			$( '#saas-dedicated a' ).attr( 'href', '/saas/dedicated/paypal' );
		}
		
	}, // end ecommercehosting (saas)
	
	paypal1: function()
	{
		$( "#saas-content li a" ).tooltip( { effect: 'slide' } );
		$( "#saas-tabs-nav" ).tabs( ".saas-panel" );
		
		function createCookie(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		};
		
		createCookie( 'partner', 'paypal', 30 );
		
	}, // end paypal (saas)
	
	paypalspotlight: function()
	{
		$( "#saas-content li a" ).tooltip( { effect: 'slide' } );
		$( "#saas-tabs-nav" ).tabs( ".saas-panel" );		
	}, // end paypal spotlight
	
	/*
	partners: function()
	{
		$('#partners-nav li a').click(function () {
		    $('#partners-nav li').removeClass('selected');
		    $(this).parent('li').addClass('selected');
		
		    thisItem = $(this).attr('rel');
		    if (thisItem != "all") {
		
		        $('#partners-boxes li[rel=' + thisItem + ']').stop().css({
		            'width': '286px',
		            'opacity': 1,
		            'margin': '0 2px 20px',
		            'padding': '20px'
		        });
		
		        $('#partners-boxes li[rel!=' + thisItem + ']').stop().animate({
		            'width': 0,
		            'opacity': 0,
		            'marginRight': 0,
		            'marginLeft': 0,
		            'padding': 0
		        }, 600, function(){
		        	this.style.display = 'none';
	        	});
		    } else {
		
		        $('#partners-boxes li').stop().animate({
		            'opacity': 1,
		            'width': '286px',
		            'margin': '0 2px 20px',
		            'padding': '20px'
		        });
		    }
		});
	}, // end partners
	*/
	hosting: function()
	{	       
		var thisItem =  $('#partners-nav li.selected a').attr('rel');		
		$('#partner-table tr[rel!=' + thisItem + ']').stop().css({
	            'height': 0,
	            'opacity': 0,
	            'width': '660px',
	            'display': 'none'
	        });
	        	 	
		$('#partners-nav li a').click(function() {
		    $('#partners-nav li').removeClass('selected');
		    $(this).parent('li').addClass('selected');
		
		    thisItem = $(this).attr('rel');
		    if (thisItem != 'all') {
		
		        $('#partner-table tr[rel=' + thisItem + ']').stop().css({
		            'height': '45px',
		            'opacity': 1,
		            'width': '680px',
		            'display': 'block'
		        });
		
		        $('#partner-table tr[rel!=' + thisItem + ']').stop().animate({
		            'height': 0,
		            'opacity': 0,
		            'width': 0
		        }, 600, function(){
		        	this.style.display = 'none';
	        	});
		    } else {
		
		        $('#partner-table tr').stop().css({
		            'opacity': 1,
		            'height': '45px',
		            'width': '680px',
		            'display': 'block'
		        });
		    }
		});
	}, // end hosting
	
	mivascriptdevelopers: function()
	{
		$('#partners-nav li a').click(function () {
		    $('#partners-nav li').removeClass('selected');
		    $(this).parent('li').addClass('selected');
		
		    thisItem = $(this).attr('rel');
		    if (thisItem != "all") {
		
		        $('#partner-table tr[rel=' + thisItem + ']').stop().css({
		            'height': '45px',
		            'opacity': 1,
		            'width': '660px',
		            'display': 'block'
		        });
		
		        $('#partner-table tr[rel!=' + thisItem + ']').stop().animate({
		            'height': 0,
		            'opacity': 0,
		            'width': '660px'
		        }, 600, function(){
		        	this.style.display = 'none';
	        	});
		    } else {
		
		        $('#partner-table tr').stop().animate({
		            'opacity': 1,
		            'height': '45px',
		            'width': '660px',
		            'display': 'block'
		        });
		    }
		});
	}, // end developers

    developers: function()
    {
      MivaMerchant.mivascriptdevelopers();
    },
	
	ecommercesoftwarefeatures: function()
	{
		$('.features-video').colorbox({width:670, height: 520});
	}, // end ecommercesoftwarefeatures
	
	mivamerchantfeatureswithupsready: function()
	{
		$('.features-video').colorbox({width:670, height: 520});
	}, // end upsfeatures
	
	smallbusiness: function()
	{
		$('.features-video').colorbox({width:670, height: 520});
	}, // end ecommercesoftwarefeatures
	
	enterprise: function()
	{
		$('.features-video').colorbox({width:670, height: 520});
	}, // end ecommercesoftwarefeatures
	
	webdevelopers: function()
	{
		$('.features-video').colorbox({width:670, height: 520});
	}, // end ecommercesoftwarefeatures
	
	support: function()
	{
		$( '.support-box:even' ).addClass( 'support-box-even' );
	}, // end support
	
    mobile: function()
    {
        $( '#mobile-screenshots a' ).colorbox();
    }, // end mobile

	ecommercewebdesign: function()
	{
		// ---- Carousel ---- //
			$('#recent-sites').jCarouselLite({
				btnNext:'.next-set',
				btnPrev:'.prev-set',
				visible:4,
				scroll:4,
				auto:10000,
				speed:1000
			});
		// ---- Light Box ---- //
			$('.site-gallery').colorbox({
				rel:'gallery',
				current:'',
				photo:true
			}); 
		// ---- Pre-Load Light Box ---- //
		$('.site-gallery').cdzPreloadImages(
			function(total){},
			function(loaded, total){},
			function(){}
		);
		// ---- Form Validation ---- //
			$('#design-form').validate({
				errorContainer:'#design-form div.error-message',
				errorLabelContainer:'#design-form div.error-message ul',
				errorElement:'li',
				rules:{
					client_name:{required:true, minlength:2},
					client_company:{required:true, minlength:2},
					client_phone:{required:true, minlength:2},
					client_email:{required:true, email:true},
					client_url:{required:true},
					client_role:{required:true},
					client_goal:{required:true},
					client_budget:{required:true}
				},
				messages:{
					client_name:{required:'Your First &amp; Last Name Are Required', minlength:jQuery.format('Your Name must be a minimum of {0} characters!')},
					client_company:{required:'Your Company Name Is Required', minlength:jQuery.format('Your Company Name must be a minimum of {0} characters!')},
					client_phone:{required:'Your Phone Number Is Required', minlength:jQuery.format('Your Phone Number must be a minimum of {0} characters!')},
					client_email:{required:'Your Email Address Is Required', email:'Your Email Address must be formatted like name@domain.com'},
					client_url:{required:'Your Website URL Is Required (ex. http://www.domain.com)'},
					client_role:{required:'Your Company Role Is Required'},
					client_goal:{required:'Your Project Goal Is Required'},
					client_budget:{required:'Your Project Budget Is Required'}
				},
		  highlight: function(element, errorClass){
					$(element.form).find('label[for=' + element.id + ']').addClass(errorClass);
		  },
		  unhighlight: function(element, errorClass){
					$(element.form).find('label[for=' + element.id + ']').removeClass(errorClass);
				}
			});
		// ---- Tabs ---- //
			$('.tab-content').hide(); //Hide all content
			$('ul.tabs li:first').addClass('active').show(); //Activate first tab
			$('.tab-content:first').show(); //Show first tab content
			$('ul.tabs li').click(function(){//On Click Event
				$('ul.tabs li').removeClass('active'); //Remove any 'active' class
				$(this).addClass('active'); //Add 'active' class to selected tab
				$('.tab-content').hide(); //Hide all tab content
				var activeTab=$(this).find('a').attr('href'); //Find the href attribute value to identify the active tab + content
				activeTab=activeTab.split('#');
				$('#'+activeTab[activeTab.length-1]).show(); //Fade in the active ID content
				return false;
			});
		// ---- FAQs ---- //
		/*	$('.faqs dd').hide(); // Hide all DDs inside .faqs
			$('.faqs dt').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')}).click(function(){ // Add class "hover" on dt when hover
				$(this).next().slideToggle('normal'); // Toggle dd when the respective dt is clicked
			});*/

	}, // end web design page scripts
	
	blog: function()
	{
		$.beautyOfCode.init({
			brushes: ['Xml', 'JScript', 'Css', 'Plain', 'Php']
		});
		
		$('.tab-video').colorbox({width:400, height: 340});
		$('.tab-video-2').colorbox({width:400, height: 375});
	},
	
	developertrainingseries: function()
	{
		$.beautyOfCode.init({
			brushes: ['Xml', 'JScript', 'Css', 'Plain', 'Php']
		});
		
		$('a.tab-video').colorbox({width:500, height: 350});
	},
	
	testimonials: function()
	{
		$('a.tab-video').colorbox({width:670, height: 520});
		
		$('#scottTest').click(function() {
		  document.getElementById('testTitle').innerHTML = 'Scott Jordan ScotteVest.com';
		  document.getElementById('test-video').href = '/video-landing/scottevest-testimonial';
		  document.getElementById('videoThumb').src = '/images/scottevest_video.png';
		});
		
		$('#toddTest').click(function() {
		  document.getElementById('testTitle').innerHTML = 'Todd Greene HeadBlade.com';
		  document.getElementById('test-video').href = '/video-landing/headblade-testimonial';
		  document.getElementById('videoThumb').src = '/images/headblade_video.png';
		});
		
		$('#robertTest').click(function() {
		  document.getElementById('testTitle').innerHTML = 'Robert Stanley DirectFix.com';
		  document.getElementById('test-video').href = '/video-landing/direct-fix-testimonial';
		  document.getElementById('videoThumb').src = '/images/directfix_video.png';
		});

		$('#jamesTest').click(function() {
		  document.getElementById('testTitle').innerHTML = 'Mitch Goldstone ScanMyPhotos.com';
		  document.getElementById('test-video').href = '/video-landing/scan-my-photos-testimonial';
		  document.getElementById('videoThumb').src = '/images/scanphotos_video.png';
		});


	},
	
	adminlightboxtest: function()
	{
		$('.tab-video').colorbox({width:760, height: 450});
	},
	
	ecommercehostingnewlanding: function()
	{
		$('a.tab-video').colorbox({width:670, height: 520});
		$('#bottomRight li a').tooltip({effect:'slide'});
	},
	
	conference: function()
	{
		$('a.lastSessions').colorbox({
			href:"http://www.mivamerchant.com/assets/breakout-sessions2012.html"
		});
	}
} // end MivaMerchant object

MivaMerchant.init();

// bangarang. 

