// ******** Sideshow before main ********/
$slideshow = {
    context: false,
    tabs: false,
    timeout: 3000,      // time before next slide appears (in ms)
    slideSpeed: 0,   // time it takes to slide in each slide (in ms)
    tabSpeed: 10000,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'scrollLeft',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $('#slideshow');
        
        // set tabs to current hard coded navigation items
        this.tabs = $('ul.slides-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare slideshow and jQuery cycle tabs
        this.prepareSlideshow();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $('div.slides > ul', $slideshow.context).cycle({
            fx: $slideshow.fx,
            timeout: $slideshow.timeout,
            speed: $slideshow.slideSpeed,
            fastOnEvent: $slideshow.tabSpeed,
            pager: $('ul.slides-nav', $slideshow.context),
            pagerAnchorBuilder: $slideshow.prepareTabs,
            before: $slideshow.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });            
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $slideshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $('a[href="#' + nextSlide.id + '"]', $slideshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $slideshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};


$(function() {
    // add a 'js' class to the body
    $('body').addClass('js');
    
    // initialise the slideshow when the DOM is ready
    $slideshow.init();
});  


/******* main *******/
(function ($) {

	$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css("margin-top", mh);
	});
};
})(jQuery);

//this is the new input reseter
(function($){$.fn.placeholder=function(options){var settings=$.extend({},options);$(this).each(function(){var iniVal=$(this).attr('value');if(iniVal===''){return;}$(this).data('iniVal',iniVal);$(this).focus(function(){var value=$(this).val();(value===$(this).data('iniVal'))?$(this).val(''):(0);});$(this).blur(function(){($(this).val()==='')?$(this).val($(this).data('iniVal')):(0);});});};})(jQuery);

$(document).ready(function(){
$('.vide-col li').last().addClass('las-vide-box');
$('.placeholder').placeholder();
Cufon.replace('.newsletter-submit',{fontFamily:'Helvetica'});
Cufon.replace('#tag-line span', { fontFamily: 'Erwin' })
Cufon.replace('.iside-the-blog-top h1, .f-section h3, .f-section #btn-signup',{fontFamily:'Helvetica Bold'});
Cufon.replace('.sidebar-free-test-drive',{fontFamily:'Helvetica', textShadow:'#777777 1px 1px'});
$('.login-menu li:last-child').addClass('last');
//$('.top-menu ul li:last-child').addClass('current-menu-item');

});



$(document).ready(function(){
	$('.f-section ul.no-mrn li:last-child').addClass('top-mrn');
	$('.f-section ul.footer_right_menu li:last-child').addClass('top-mrn1');
    $('.categories_widget ul').addClass('categories');
    $('.tags_widget div').addClass('tags');
    
    $('div.top-menu ul li').each(function() {
        if($(this).has('ul').length) {
            $(this).addClass('has-sub');
        }
    });
    
    $('#header .top-menu ul li ul').wrap('<div class="sub-nav-bg-top"><div class="sub-nav-bg-bottom"></div></div>');
    $('#header .top-menu ul .has-sub .sub-nav-bg-bottom a').addClass('sub-links');
    
});

/**** CM subscribe *******/

	jQuery(function()
	{
		/*jQuery("#dlitjj-dlitjj").focus(function() {
			if( jQuery("#dlitjj-dlitjj").val() == 'Enter Your Email...' )
				jQuery("#dlitjj-dlitjj").val('');
		});
		jQuery("#cm-name").focus(function() {
			if( jQuery("#cm-name").val() == 'Enter Your Name...' )
				jQuery("#cm-name").val('');
		});
		
		jQuery("#dlitjj-dlitjj").blur(function() {
			if( jQuery("#dlitjj-dlitjj").val() == '' )
				jQuery("#dlitjj-dlitjj").val('Enter Your Email...');
		});
		jQuery("#cm-name").blur(function() {
			if( jQuery("#cm-name").val() == '' )
				jQuery("#cm-name").val('Enter Your Name...');
		});
		*/
		jQuery("#subForm").submit(function(evt) {	

			// First, disable the form from submitting
			// this is bad -> jQuery('form#subForm').submit(function() { return false; });
			// this is better 
			evt.preventDefault();
			
			// Grab form action
			formAction = jQuery("form#subForm").attr("action");
			
			// Replace the xxxxx below:
			// If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
			emailId = "dlitjj";
			emailId = emailId.replace("/", "");
			emailId = emailId + "-" + emailId;
			
			// Validate email address with regex
			if (!checkEmail(emailId)) 
			{
				alert("Please enter a valid email address");
				return;
			}
			
			// Serialize form values to be submitted with POST
		  	var str = jQuery("form#subForm").serialize();
			
			// Add form action to end of serialized data
			final = str + "&action=" + formAction;
			
			// Submit the form via ajax
			jQuery.ajax({
				url: "http://www.agilewords.com/blog/cm_subscribe_proxy.php",
				type: "POST",
				data: final,
				success: function(html){
					// If successfully submitted hides the form
					jQuery("#theForm").hide();
					// Shows "Thanks for subscribing" div
					jQuery("#confirmation").slideDown("slow");
					
					// Fire off Google Analytics fake pageview
					var pageTracker = _gat._getTracker("UA-1000088-5");
					pageTracker._trackPageview("/newsletter_signup");
				}
			});
		});
	});
    
    jQuery(function()
	{
		jQuery("#subForm2").submit(function(evt) {	
			
			// First, disable the form from submitting
			// jQuery('form#subForm2').submit(function() { return false; });
			evt.preventDefault();
			
			// Grab form action
			formAction2 = jQuery("form#subForm2").attr("action");
			
			// Replace the xxxxx below:
			// If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
			emailId2 = "dlitjj";
			emailId2 = emailId2.replace("/", "");
			emailId2 = emailId2 + "-" + emailId2 + "2";
			
			// Validate email address with regex
			if (!checkEmail(emailId2)) 
			{
				alert("Please enter a valid email address");
				return;
			}
			
			// Serialize form values to be submitted with POST
		  	var str = jQuery("form#subForm2").serialize();
			
			// Add form action to end of serialized data
			final = str + "&action=" + formAction2;
			
			// Submit the form via ajax
			jQuery.ajax({
				url: "http://www.agilewords.com/blog/cm_subscribe_proxy.php",
				type: "POST",
				data: final,
				success: function(html){
					// If successfully submitted hides the form
					jQuery("#theForm2").hide();
					// Shows "Thanks for subscribing" div
					jQuery("#confirmation2").slideDown("slow");
					
					// Fire off Google Analytics fake pageview
					var pageTracker = _gat._getTracker("UA-1000088-5");
					pageTracker._trackPageview("/newsletter_signup");
				}
			});
		});
	});
    
    function checkEmail(email)
	{	
		var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var emailVal = jQuery("#" + email).val();
		return pattern.test(emailVal);
	}

/**** Twiteer *******/
var twttr=window.twttr||{};(function(){if(!twttr.widgets){twttr.widgets={}}if(!twttr.widgets.host){twttr.widgets.host="platform{i}.twitter.com"}if(typeof twttr.widgets.ignoreSSL==="undefined"){twttr.widgets.ignoreSSL=false}function T(X){var Z=M(X);var Y=twttr.widgets.host;var W=Y.replace("{i}",G++);if(G==3){G=0}return Z+"://"+W}function M(W){return(window.location.protocol.match(/s\:$/)||W)&&!twttr.widgets.ignoreSSL?"https":"http"}function S(a){var X;for(var W in a){X=N.apply(this,W.split("."));for(var Y=0,Z;(Z=X[Y]);Y++){new a[W](Z).render()}}}function I(b){var Y;var Z;var X=function(){if(document.readyState=="complete"){Y()}};var W;var a=function(){try{document.documentElement.doScroll("left");Y()}catch(c){}};if(window.addEventListener){Y=function(){if(!Z){Z=true;b()}window.removeEventListener("DOMContentLoaded",Y,false);window.removeEventListener("load",Y,false)};window.addEventListener("DOMContentLoaded",Y,false);window.addEventListener("load",Y,false)}else{if(window.attachEvent){W=window.setInterval(a,13);Y=function(){if(!Z){Z=true;b()}window.clearInterval(W);window.detachEvent("onreadystatechange",X);window.detachEvent("onload",Y)};window.attachEvent("onreadystatechange",X);window.attachEvent("onload",Y)}}}function N(W,a){var Z,b=[],X,Y;try{if(document.querySelectorAll){b=document.querySelectorAll(W+"."+a)}else{if(document.getElementsByClassName){Z=document.getElementsByClassName(a);for(X=0;(Y=Z[X]);X++){if(Y.tagName.toLowerCase()==W){b.push(Y)}}}else{Z=document.getElementsByTagName(W);var d=new RegExp("\\b"+a+"\\b");for(X=0;(Y=Z[X]);X++){if(Y.className.match(d)){b.push(Y)}}}}}catch(c){}return b}function Q(W){return encodeURIComponent(W).replace(/\+/g,"%2B")}function D(W){return decodeURIComponent(W)}function J(Y){var X=[];for(var W in Y){if(Y[W]!==null&&typeof Y[W]!=="undefined"){X.push(Q(W)+"="+Q(Y[W]))}}return X.sort().join("&")}function P(Z){var b={},Y,a,X,W;if(Z){Y=Z.split("&");for(W=0;(X=Y[W]);W++){a=X.split("=");if(a.length==2){b[D(a[0])]=D(a[1])}}}return b}function F(X,Y){for(var W in Y){X[W]=Y[W]}return X}function R(X){var W;if(X.match(/^https?:\/\//)){return X}else{W=location.host;if(location.port.length>0){W+=":"+location.port}return[location.protocol,"//",W,X].join("")}}function A(){var W=document.getElementsByTagName("link");for(var X=0,Y;(Y=W[X]);X++){if(Y.getAttribute("rel")=="canonical"){return R(Y.getAttribute("href"))}}return null}function K(Y){var Z=[];for(var X=0,W=Y.length;X<W;X++){Z.push(Y[X])}return Z}function C(){var X=document.getElementsByTagName("a"),d=document.getElementsByTagName("link"),W=/\bme\b/,Z=/^https?\:\/\/(www\.)?twitter.com\/(#!\/)?([a-zA-Z0-9_]+)\/?$/,c=K(X).concat(K(d)),b,f,Y;for(var a=0,e;(e=c[a]);a++){f=e.getAttribute("rel");Y=e.getAttribute("href");if(f&&Y&&f.match(W)&&(b=Y.match(Z))){return b[3]}}}var E=document.title,L=encodeURI(location.href),G=0,U={en:{vertical:[55,62],horizontal:[110,20],none:[55,20]},de:{vertical:[67,62],horizontal:[110,20],none:[67,20]},es:{vertical:[64,62],horizontal:[110,20],none:[64,20]},fr:{vertical:[65,62],horizontal:[110,20],none:[65,20]},it:{vertical:[55,62],horizontal:[110,20],none:[55,20]},ko:{vertical:[55,62],horizontal:[110,20],none:[55,20]},ja:{vertical:[80,62],horizontal:[130,20],none:[80,20]}},H={en:1,de:1,es:1,fr:1,it:1,ko:1,ja:1},B={vertical:1,horizontal:1,none:1},V={en:"Twitter For Websites: Tweet Button",de:"Twitter fA1r Webseiten: Tweet-SchaltflA�che",es:"Twi`tter para sitios web: BotA3n para Twittear",fr:'Twitter pour votre site web : bouton "Tweeter"',it:"Tweeter per i siti web: Bottone Tweet",ko:"Twitter i�1�2�i �: 트io� �2��1",ja:"WEBa��a��af^a��a��Twitter: af�a��af1af^afoa�?af3"};twttr.TweetButton=function(a){this.originElement=a;var X=a.href.split("?")[1],Z=X?P(X):{},W=Z.count||a.getAttribute("data-count"),Y=Z.lang||a.getAttribute("data-lang");this.text=Z.text||a.getAttribute("data-text")||E;this.via=Z.via||a.getAttribute("data-via")||C();this.url=Z.url||a.getAttribute("data-url")||A()||L;this.statusID=Z.status_id||a.getAttribute("data-status-id");this.related=Z.related||a.getAttribute("data-related");this.counturl=Z.counturl||a.getAttribute("data-counturl");this.searchlink=Z.searchlink||a.getAttribute("data-searchlink");this.placeid=Z.placeid||a.getAttribute("data-placeid");if(!B[W]){W="horizontal"}this.count=W;if(!H[Y]){Y="en"}this.lang=Y};F(twttr.TweetButton.prototype,{parameters:function(){var W;if(this.statusID){W={status_id:this.statusID}}else{W={text:this.text,url:this.url,via:this.via,related:this.related,count:this.count,lang:this.lang,counturl:this.counturl,searchlink:this.searchlink,placeid:this.placeid}}W._=(new Date()).getTime();return J(W)},render:function(){if(!twttr.TweetButton.fragment){twttr.TweetButton.fragment=document.createElement("div");twttr.TweetButton.fragment.innerHTML='<iframe allowtransparency="true" frameborder="0" scrolling="no" tabindex="0" class="twitter-share-button twitter-count-'+this.count+'"></iframe>'}var X=twttr.TweetButton.fragment.firstChild.cloneNode(false);X.src=T()+"/widgets/tweet_button.html?"+this.parameters();var Y=U[this.lang][this.count];X.style.width=Y[0]+"px";X.style.height=Y[1]+"px";X.title=V[this.lang];var W=this.originElement.parentNode;if(W){W.replaceChild(X,this.originElement)}}});var O={"a.twitter-share-button":twttr.TweetButton};S(O);I(function(){S(O)})}());


/** Facebook ****/
/*1298080693,176728940,JIT Construction: v345401,en_US*/

if (!window.FB) {FB = {};} if(!FB.dynData) { FB.dynData = {"site_vars":{"canvas_client_compute_content_size_method":1,"use_postMessage":0,"use_xdProxy":0,"use_ui_server":1,"monitor_usage_regex":"somethingtoputhere.com|huffingtonpost.com|lala.com","monitor_usage_rate":0.05,"enable_custom_href":1},"ui_server_dialogs":{"bookmark.add":1,"friends.add":1},"resources":{"base_url_format":"http:\/\/{0}.facebook.com\/","base_cdn_url":"http:\/\/static.ak.fbcdn.net\/","api_channel":1297703241,"api_server":1297703241,"www_channel":1297703164,"xd_proxy":1297703038,"xd_comm_swf_url":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf","share_button":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yg\/r\/yZiDLhSvAE9.gif","login_img_dark_small_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/y2\/r\/ECSptXRJiXu.gif","login_img_dark_medium_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yN\/r\/WMAGVllinGS.gif","login_img_dark_medium_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yq\/r\/CtXTsD9gwTy.gif","login_img_dark_large_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yg\/r\/di8GQ4yWYmF.gif","login_img_dark_large_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yz\/r\/WuhUANysBjg.gif","login_img_light_small_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yG\/r\/HPpl_Q9ir03.gif","login_img_light_medium_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yG\/r\/QVAKZwo2mNu.gif","login_img_light_medium_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yA\/r\/11hJsvQEMup.gif","login_img_light_large_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yq\/r\/RwaZQIP0ALn.gif","login_img_light_large_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/y6\/r\/kGCxkZx-uZa.gif","login_img_white_small_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yu\/r\/HSGgAQzgm6f.gif","login_img_white_medium_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yJ\/r\/a3H8zoa1Ymj.gif","login_img_white_medium_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yK\/r\/McNhTwo6iLp.gif","login_img_white_large_short":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/y_\/r\/vE_oh0zqP1Z.gif","login_img_white_large_long":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yc\/r\/bGxF25CxBsQ.gif","logout_img_small":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yL\/r\/_gsP01S3mwQ.gif","logout_img_medium":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/y2\/r\/NhZ-RyMbOUr.gif","logout_img_large":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yf\/r\/C9lMHpC5ik8.gif"}};} if (!FB.locale) {FB.locale = "en_US";} if (!FB.localeIsRTL) {FB.localeIsRTL = false;}


if(!window.FB)window.FB={};if(!window.FB.isSecure)window.FB.isSecure=function(){return (window.location.href.indexOf('https')===0)||(window.name.indexOf('_fb_https')>-1);};if(!window.FB.Share){FB.Share={results:{},resetUrls:function(){this.urls={};this.urlsA=[];},addQS:function(d,c){var a=[];for(var b in c)if(c[b])a.push(b.toString()+'='+encodeURIComponent(c[b]));return d+'?'+a.join('&');},getUrl:function(a){return a.getAttribute('share_url')||window.location.href;},getType:function(a){return a.getAttribute('type')||'button_count';},pretty:function(a){return a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);},updateButton:function(a){var b=this.getUrl(a);if(this.results[b])a.fb_count=this.results[b].total_count;this.displayBox(a,3);},displayBox:function(a,d){if(typeof(a.fb_count)=='number'&&a.fb_count>=d)for(var c=1;c<=2;c++){var b=a.firstChild.childNodes[c];b.className=b.className.replace('fb_share_no_count','');if(c==2)b.lastChild.innerHTML=this.pretty(a.fb_count);}},renderButton:function(c){var k=this.getUrl(c);var h=this.getType(c);var i=c.innerHTML.length>0?c.innerHTML:'Share';var g={u:k,t:k==window.location.href?document.title:null,src:'sp'};c.href=this.addQS((FB.isSecure()?'https:':'http:')+'//www.facebook.com/sharer.php',g);c.onclick=function(){if(!c.fb_clicked){c.fb_count+=1;FB.Share.displayBox(this,1);c.fb_clicked=true;}window.open(c.href,'sharer','toolbar=0,status=0,width=626,height=436');return false;};c.style.textDecoration='none';if(!this.results[k]&&(h.indexOf('count')>=0)){this.urls[k]=true;this.urlsA.push(k);}var j='Small';var a='<span class=\'FBConnectButton FBConnectButton_'+j+'\''+' style=\'cursor:pointer;\'>'+'<span class=\'FBConnectButton_Text\'>'+i+'</span></span>';if(h.indexOf('count')>=0){var e=(h=='box_count');var f=(e?'top':'right');var d='<span class=\'fb_share_size_'+j+' '+(e?'fb_share_count_wrapper':'')+'\'>';var b='<span class=\'fb_share_count_nub_'+f+' fb_share_no_count\'></span>';b+='<span class=\'fb_share_count fb_share_no_count'+' fb_share_count_'+f+'\'>'+'<span class=\'fb_share_count_inner\'>&nbsp;</span></span>';d+=(e)?'<span></span>'+b+a:a+b;}else if(h.indexOf('icon')>=0){var d='<span class=\'FBConnectButton_Simple\'>'+'<span class=\'FBConnectButton_Text_Simple\'>'+(h=='icon_link'?i:'&#xFEFF;')+'</span>';}else var d=a;c.innerHTML=d;c.fb_rendered=true;},insert:function(a){(document.getElementsByTagName('HEAD')[0]||document.body).appendChild(a);},renderAll:function(d){var c=document.getElementsByName('fb_share');var a=c.length;for(var b=0;b<a;b++){if(!c[b].fb_rendered)this.renderButton(c[b]);if(this.getType(c[b]).indexOf('count')>=0&&!c[b].fb_count&&this.results[this.getUrl(c[b])])this.updateButton(c[b]);}},fetchData:function(){var c=document.createElement('script');var a=[];for(var b=0;b<this.urlsA.length;++b)a.push('"'+this.urlsA[b].replace('\\','\\\\').replace('"','\\"')+'"');c.src=this.addQS((FB.isSecure()?'https:':'http:')+'//api.facebook.com/restserver.php',{v:'1.0',method:'links.getStats',urls:'['+a.join(',')+']',format:'json',callback:'fb_sharepro_render'});this.resetUrls();this.insert(c);},stopScan:function(){clearInterval(FB.Share.scanner);FB.Share.renderPass();},renderPass:function(){FB.Share.renderAll();if(FB.Share.urlsA.length>0)FB.Share.fetchData();},_onFirst:function(){var b=document.createElement('link');b.rel='stylesheet';b.type='text/css';var a=(FB.isSecure()?'https://s-static.ak.fbcdn.net/':'http://static.ak.fbcdn.net/');b.href=a+'connect.php/css/share-button-css';this.insert(b);this.resetUrls();window.fb_sharepro_render=function(c){for(var d=0;c&&d<c.length;d++)FB.Share.results[c[d].url]=c[d];FB.Share.renderAll();};this.renderPass();this.scanner=setInterval(FB.Share.renderPass,700);if(window.attachEvent){window.attachEvent("onload",FB.Share.stopScan);}else window.addEventListener("load",FB.Share.stopScan,false);}};FB.Share._onFirst();}


if (FB && FB.Loader) { FB.Loader.onScriptLoaded(["FB.Share","FB.SharePro"]); }
