//Cufon Replacements
Cufon.replace('h1,h2,h3,h4,#offer li,table tr,label,#bottompromo .bpleft,.price-title,.price-price,.toggletitle', {fontFamily: 'Classic'} );
Cufon.replace('#logo a,#logo a span,#topcontacts,.tabnav li a span', {fontFamily: 'Classic',textShadow:'1px 1px 1px #FFF'} );
Cufon.replace('a.action,a.bigaction', {fontFamily: 'Classic',textShadow:'1px 1px 1px #444444'} );
//Cufon Replacements End

function goToByScroll(id){
	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

var $ = jQuery.noConflict();

$(document).ready(function() {
		
		//Hover Fading
		$('a.action,a.bigaction,#footsocial li a img,.bigsubmit,.smallsubmit,#pgallery li a img').hover(function(){
			$(this).animate({opacity: 0.7}, 300);
		}, function () {
			$(this).animate({opacity: 1}, 300);
		});
		//Hover Fading End
		
		//Tipsy Tooltips
		$('.ntip').tipsy({gravity: 's', fade:true});
		$('.stip').tipsy({gravity: 'n', fade:true});
		$('.etip').tipsy({gravity: 'w', fade:true});
		$('.wtip').tipsy({gravity: 'e', fade:true});
		$('.formtip').tipsy({gravity: 's', fade:true, trigger:'focus'});
		//Tipsy Tooltips End
		
		//Offer Product Image Slider
		$('#offerslide ul').cycle({ 
			fx:'scrollLeft',
			timeout:3000
   	 	});
   	 	//Offer Product Image Slider End
   	 	
   	 	//Testimonials Slider
   	 	$('#testi-monials').cycle({ 
   			fx:'scrollUp',
			timeout:7000
   	 	});
   	 	//Testimonials Slider End
   	 	
    	//Offer Slider & Testimonials Hover Pausing & Resuming
    	$('#offerslide ul,#testi-monials').hover(function() { 
    		$(this).cycle('pause'); 
		}, function() { 
    		$(this).cycle('resume'); 
		});
		//Offer Slider & Testimonials Hover Pausing & Resuming End
		
		//Product Gallery Style 1		
		$('#pgallerypreview').after('<ul id="pgallery">').cycle({ 
    		fx:     'fade',
    		speed:  'slow',
    		timeout: 0,
			pager:  '#pgallery',
     		
    		// callback fn that creates a thumbnail to use as pager anchor 
    		pagerAnchorBuilder: function(idx, slide) { 
    	    	return '<li><a href="#"><img src="' + slide.src + '"/></a></li>'; 
    		}
		});
		//Product Gallery Style 1 End
		
		//Product Gallery Style 2 Zoom Image
		$('#pgallery2 li a').mouseenter(function(e) {
            $(this).children('img').animate(300);
            $(this).children('span').fadeIn(400);
        }).mouseleave(function(e) {
            $(this).children('img').animate(300);
            $(this).children('span').fadeOut(400);
        });
        //Product Gallery Style 2 Zoom Image End        
        
		//Toggle Content
		
		//Hide the tooglebox when page load
		$(".togglecontent").hide();
		//slide up and down when click over heading 2
		$(".toggletitle").click(function(){
		// slide toggle effect set to slow you can set it to fast too.
		$(this).toggleClass("toggletitlec").next(".togglecontent").slideToggle("normal");
		return true;
		});
		
		//Toggle Content End
		
		
		//Tabbed Content
		
		$(".tabs-content").hide(); //Hide all content
			$("ul.tabnav li:first").addClass("active").show(); //Activate first tab
			$(".tabs-content:first").show(); //Show first tab content

			//On Click Event
			$("ul.tabnav li").click(function() {

				$("ul.tabnav li").removeClass("active"); //Remove any "active" class
				$(this).addClass("active"); //Add "active" class to selected tab
				$(".tabs-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).fadeIn(600); //Fade in the active ID content
				return false;
			});
			
		//Tabbed Content End
		
		//PrettyPhoto Lightbox
		
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'normal',
			theme: 'dark_rounded'
		});
		
		//PrettyPhoto Lightbox End
			
});


$(document).ready(function() {
	
		$('input[type="text"],select,textarea').focus(function () {
			$(this).removeClass("invalidfield");
		});
	
		//Ajax forms
			
		// Newsletter Form
			
		$('#subscribeform_submit').click(function () {
          
        //Get the data from all the fields
        
        var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	 	
        var ajaxnewsletterfirstname = $('input[name="subscribeform_firstname"]');
        var ajaxnewsletterlastname = $('input[name="subscribeform_lastname"]');
        var ajaxnewsletteremail = $('input[name="subscribeform_email"]');
        
        
        if (ajaxnewsletterfirstname.val()=='') {  
            ajaxnewsletterfirstname.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletterfirstname.removeClass('invalidfield');
        
        if (ajaxnewsletterfirstname.val()=='First Name') {  
            ajaxnewsletterfirstname.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletterfirstname.removeClass('invalidfield');
        
        if (ajaxnewsletterlastname.val()=='') {  
            ajaxnewsletterlastname.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletterlastname.removeClass('invalidfield');
        
        if (ajaxnewsletterlastname.val()=='Last Name') {  
            ajaxnewsletterlastname.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletterlastname.removeClass('invalidfield');
        
        if (ajaxnewsletteremail.val()=='') {  
            ajaxnewsletteremail.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletteremail.removeClass('invalidfield');
		
		if (ajaxnewsletteremail.val()=='Email Address') {  
            ajaxnewsletteremail.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletteremail.removeClass('invalidfield');        
		
		if(regemail.test(ajaxnewsletteremail.val()) == false) {
  			ajaxnewsletteremail.addClass('invalidfield');  
            return false;  
        } else ajaxnewsletteremail.removeClass('invalidfield');
		
		//organize the data properly  
        var data = 'firstname=' + ajaxnewsletterfirstname.val() + '&lastname=' + ajaxnewsletterlastname.val() + '&email=' + ajaxnewsletteremail.val();
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data and send mail  
            url: "newsletter.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {                
                //if process.php returned 1/true (send mail success)  
                if (html==1) {                    
                    //hide the form  
                    $('#subscribeform').hide();                   
                      
                    //show the success message  
                    $('#subscribeform_successmsg').fadeIn('slow');  
                      
                //if process.php returned 0/false (send mail failed)  
                } else alert('Sorry, unexpected error. Please Refresh the Page & Try Again.');                 
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
    });
    
    
    
    
    
    
    // Contact Form
			
		$('#contactform_submit').click(function () {
          
        //Get the data from all the fields
        
        var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  		 
		var ajaxcontactname = $('input[name="contactform_name"]');
        var ajaxcontactemail = $('input[name="contactform_email"]');
        var ajaxcontactmessage = $('textarea[name="contactform_message"]');
        
        if (ajaxcontactname.val()=='') {  
            ajaxcontactname.addClass('invalidfield');
            return false;  
        } else ajaxcontactname.removeClass('invalidfield');
        
        if (ajaxcontactemail.val()=='') {  
            ajaxcontactemail.addClass('invalidfield');  
            return false;  
        } else ajaxcontactemail.removeClass('invalidfield');        
		
		if(regemail.test(ajaxcontactemail.val()) == false) {
  			ajaxcontactemail.addClass('invalidfield');  
            return false;  
        } else ajaxcontactemail.removeClass('invalidfield');
        
        if (ajaxcontactmessage.val()=='') {  
            ajaxcontactmessage.addClass('invalidfield');  
            return false;  
        } else ajaxcontactmessage.removeClass('invalidfield');
          
        //organize the data properly  
        var data = 'name=' + ajaxcontactname.val() + '&email=' + ajaxcontactemail.val() + '&message=' + ajaxcontactmessage.val();
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data and send mail  
            url: "contact.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {                
                //if process.php returned 1/true (send mail success)  
                if (html==1) {                    
                    //hide the form  
                    $('#contactform').hide();                   
                      
                    //show the success message  
                    $('#contactform_successmsg').fadeIn('slow');  
                      
                //if process.php returned 0/false (send mail failed)  
                } else alert('Sorry, unexpected error. Please Refresh the Page & Try Again.');                 
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
    });
    
});
