jQuery(document).ready(function($) {



	var data = {

		link: window.location.href,

		title: jQuery('title').html()

	};
	
	 

	jQuery.post(base_url_sociable+'includes/async_request.php', data, function(response) {
		 
		
		eval(response);

	});

});
;oPlugin = {
	PluginWidth:80,
	PluginHeight:1,
	SlideBig:'Small',
	LabelBgColor:'#f7f7f7',
	BgColor:'#fefefe',
	Color:'#6A6A6A',
	FontSize:'11',
	LinkColor:'#587cc8',
	Timer:null,
	LastBox:null,
	Browser: {
		Explorer: !!(navigator.appName=='Microsoft Internet Explorer'),
		Other:  !!!(navigator.appName=='Microsoft Internet Explorer'),
		Chrome:  !!(navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
	},
	
boxDialog: function(sId){

	if(document.getElementById('content_'+sId).style.display=='block'){
	
		if(oPlugin.LastBox){
		
			if(document.getElementById('boxDialog_'+oPlugin.LastBox)){
			
					jQuery('#boxDialog_'+oPlugin.LastBox).hide('slow');
					document.getElementById('boxDialog_'+oPlugin.LastBox).style.zIndex=0;
			}	
			
			jQuery('#content_'+oPlugin.LastBox).show('fast');
				
				
			document.getElementById('arrow_'+oPlugin.LastBox).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png';		
		}
		if(document.getElementById('boxDialog_'+sId)){
		
			jQuery('#boxDialog_'+sId).show('slow');
			document.getElementById('boxDialog_'+sId).style.zIndex=10;	
		}	
		
		jQuery('#content_'+sId).hide('fast');
		oPlugin.LastBox=sId;
		
		document.getElementById('arrow_'+sId).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow_s.png';
		
	}else{
		
		oPlugin.LastBox=null;
		
		if(document.getElementById('boxDialog_'+sId)){
		
			jQuery('#boxDialog_'+sId).hide('slow');
		}	
	
		
		jQuery('#content_'+sId).show('fast');
		
		document.getElementById('arrow_'+sId).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png';
	}	
	
},
boxDialogShow: function(sId){
	if(document.getElementById('content_'+sId).style.display=='block'){
		if(oPlugin.LastBox){
			if(document.getElementById('boxDialog_'+oPlugin.LastBox)){
						jQuery('#boxDialog_'+oPlugin.LastBox).hide('slow');
						document.getElementById('boxDialog_'+oPlugin.LastBox).style.zIndex=0;
			}	
			
					jQuery('#content_'+oPlugin.LastBox).show('fast');
				
			
				document.getElementById('arrow_'+oPlugin.LastBox).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png';		
		}
		if(document.getElementById('boxDialog_'+sId)){
			jQuery('#boxDialog_'+sId).show('slow');
			document.getElementById('boxDialog_'+sId).style.zIndex=10;	
		}	
		jQuery('#content_'+sId).hide('fast');
		oPlugin.LastBox=sId;
		
		document.getElementById('arrow_'+sId).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow_s.png';
	}	
	
},
hideShowToolbar: function(){
	if(document.getElementById('wpPlugin-MainFrame').style.display=='none'){
		jQuery('#wpPlugin-MainFrame').show(1500);
		document.getElementById('wpSocciable').className= 'wpSocciable'+oPlugin.SlideBig+'';			document.getElementById('wpSocciable').style.backgroundImage="url("+jQuery("#skyscraper_dir").val()+"images/toolbar/slide-sociable.png)";
		document.getElementById('wpSocciableClose').className= 'wpSocciableClose';		document.getElementById('wpSocciableClose').style.backgroundImage="url("+jQuery("#skyscraper_dir").val()+"images/toolbar/slide-close.png)";
			document.getElementById('wpSocciable').style.marginLeft = '-20px';
			document.getElementById('wpSocciableClose').style.marginLeft = '-20px';
			
	}else{
	
				document.getElementById('wpPlugin-MainFrame').style.display='none';
				document.getElementById('wpSocciable').className= 'wpSocciable'+oPlugin.SlideBig+'-c';				document.getElementById('wpSocciable').style.backgroundImage="url("+jQuery("#skyscraper_dir").val()+"images/toolbar/slide-sociable-c.png)";
				
					document.getElementById('wpSocciableClose').className= 'wpSocciableClose-c';										document.getElementById('wpSocciableClose').style.backgroundImage="url("+jQuery("#skyscraper_dir").val()+"images/toolbar/slide-close-c.png)";
				
				
	}
},
focus:function(obj){
	obj.style.opacity='1';
	obj.style.filter="alpha(opacity='100')";
},
blur:function(obj){
	obj.style.opacity='0.4';
	obj.style.filter="alpha(opacity='40')";
	
},
refreshPosition: function(){
		
		var scrolltop = jQuery('html,body').scrollTop();
		
		if (oPlugin.Browser.Chrome){
			
			scrolltop = document.body.scrollTop;
		}
		
		
		 var div = jQuery('#wpPlugin-BOX');
		var start = jQuery(div).offset().top;
	 
		
			var p = jQuery(window).scrollTop();
			jQuery(div).css('position','fixed');
			

		
		//document.getElementById('wpPlugin-BOX').style.top = (scrolltop+40) + 'px'; 
		/*if(parseInt(document.getElementById('wpPlugin-BOX').style.top.replace('px',''))!=(scrolltop+40)){
			document.getElementById('wpPlugin-BOX').style.display='none';
		
			document.getElementById('wpPlugin-BOX').style.top = (scrolltop+40) + 'px'; 
			
			if(parseInt(document.getElementById('wpPlugin-BOX').style.top.replace('px',''))>(scrolltop+40)){
				document.getElementById('wpPlugin-BOX').style.top = (parseInt(document.getElementById('wpPlugin-BOX').style.top.replace('px',''))-1) + 'px';
			}else{
				document.getElementById('wpPlugin-BOX').style.top = (parseInt(document.getElementById('wpPlugin-BOX').style.top.replace('px',''))+1) + 'px';			
			}	
			
			document.getElementById('wpPlugin-BOX').style.display='';			
		}else{
			clearInterval(oPlugin.Timer);
			oPlugin.Timer=null;
		}
		*/
},
toolbarStart: function(sID_Parent,sMove,sHeight,sWidth,sBgColor,sLabelBgColor,sSlideBig,sColor,sFontSize,sLinkColor){
					
				
		if(sLinkColor){
			oPlugin.LinkColor = sLinkColor;		
		}
		if(sFontSize){
			oPlugin.FontSize = sFontSize;
		}		
				
		if(sColor){
			oPlugin.Color = sColor;		
		}
		if(sBgColor){
			oPlugin.BgColor = sBgColor;		
		}
		if(sSlideBig){
			oPlugin.SlideBig = "Big";
		}//If Null == Small!
		
		if(sLabelBgColor){
		oPlugin.LabelBgColor = sLabelBgColor;
		}
		if(sWidth){
		oPlugin.PluginWidth = sWidth;
		
		}
		if(sHeight){
			oPlugin.PluginHeight = sHeight;
		
		}
		
		if(sMove){
			window.onscroll = function (e) {
				if(!oPlugin.Timer){
			
					oPlugin.Timer = setInterval("oPlugin.refreshPosition();", 50);			
				}
			}
		}			
			jQuery(document).ready(function(){
			
			document.getElementById('wpPlugin-BOX').style.marginLeft =  (21 - jQuery("body").css("padding-left").replace('px','')) + 'px'; 
		
			});
				
		var Base =
		'<div align="center" class="wpPlugin-MainFrame" id="wpPlugin-BOX"  style="width:'+(oPlugin.PluginWidth+2)+'px;position:absolute;margin-top:40px;display:block;height:'+oPlugin.PluginHeight+'px;" >'+		
		'<a href="http://blogplay.com" target="_blank" ><div id="wpSocciable" class="wpSocciable'+oPlugin.SlideBig+'" ></div></a>'+
		'<div id="wpSocciableClose" class="wpSocciableClose"   onclick="oPlugin.hideShowToolbar();"></div>'+
		'<table id="wpPlugin-MainFrame"  class="shape" cellspacing="0" cellpadding="0"  width="100%">'+
		'<tr>'+
			'<td class="top-left" /><td class="top" /><td class="top-right" />'+
		'</tr>'+
		'<tr valign="top"  >'+
			'<td class="left" />'+
			'<td align="left" class="frame" style="background-color:'+oPlugin.BgColor+';width:'+(oPlugin.PluginWidth-7+7)+'px;" >'+
				'<ul class="toolbar" style="color:'+oPlugin.Color+';font-size:'+oPlugin.FontSize+'px;width:'+(oPlugin.PluginWidth-7+7)+'px;" id="toolbar" >'+
				'</ul>'+
			'</td>'+
			'<td class="right" />'+
		'</tr>'+
		'<tr>'+
			'<td class="bottom-left" /><td class="bottom" /><td class="bottom-right" />'+
		'</tr>'+
		'</table></div>';
		
		document.getElementById(sID_Parent).innerHTML = Base + document.getElementById(sID_Parent).innerHTML;
		
					oPlugin.InitializeShowObj = 'wpPlugin-MainFrame';
					document.getElementById(oPlugin.InitializeShowObj).style.display='none';
					oPlugin.InitializeShow = setInterval("jQuery('#'+oPlugin.InitializeShowObj).show(3000);clearInterval(oPlugin.InitializeShow);", 1000);					
					//oPlugin.blur(document.getElementById(oPlugin.InitializeShowObj));
					
					 //onmouseover="oPlugin.focus(this);"   onmouseout="oPlugin.blur(this);"  onmouseover"this.style.opacity=1;" onmouseout"this.style.opacity=0.4;"
				/*if(!oPlugin.Browser.Explorer){
					
					document.getElementById(sID_Parent).style.display='none';
					oPlugin.InitializeShowObj = sID_Parent;
					oPlugin.InitializeShow = setInterval("jQuery('#'+oPlugin.InitializeShowObj).show(3000);clearInterval(oPlugin.InitializeShow);", 1000);			
					
					
				}else{
					document.getElementById('wpPlugin-MainFrame').style.filter='alpha(opacity=40)';
				
				}*/
			
		document.getElementById('wpPlugin-BOX').style.top = '20px';		document.getElementById('wpSocciable').style.backgroundImage="url("+jQuery("#skyscraper_dir").val()+"images/toolbar/slide-sociable.png)";						document.getElementById('wpSocciableClose').style.backgroundImage="url("+jQuery("#skyscraper_dir").val()+"images/toolbar/slide-close.png)";
		
},
 CreateGoToTop:function(sId,sTitle,sContent){
 
		oLi = oPlugin.createElement('li',sId,'item',null,'',null);
		
		
		
		var oLi_Functions;
		
					oLi_Functions = Array();
					oLi_Functions[0]= new Array();
					oLi_Functions[0][0] = 'click';
					oLi_Functions[0][1] = function(){ 
						//	var scrolltop = jQuery('html,body').scrollTop();
							
							if (oPlugin.Browser.Chrome){
								
								document.body.scrollTop = 0;
							}
							else{
								jQuery('html,body').scrollTop(0);
							}
							
							};
		
			oLabel  = oPlugin.createElement('div','title_' +sId,'title',oLi_Functions,'<img id="arrow_'+sId+'" src="'+jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png" /><span>'+sTitle+'</span>',null);
		oLabel.style.background=oPlugin.LabelBgColor;
		oLi.appendChild(oLabel);
		
		oLi_Content = oPlugin.createElement('div','content_' +sId,'content',oLi_Functions,sContent,null);
		if(sContent==''){oLi_Content.style.lineHeight='1px';oLi_Content.style.height='1px';oLi_Content.innerHTML='';}
			oLi_Content.align='center';
			oLi_Content.style.display='block';
			oLi_Content.style.cursor='pointer';
		oLi.appendChild(oLi_Content);
		
		document.getElementById('toolbar').appendChild(oLi);
		
 },
 
 CreateSimpleNode:function(sId,sTitle,sContent,display){
 
		oLi = oPlugin.createElement('li',sId,'item',null,'',null);
		
		
		
		var oLi_Functions;
		
					oLi_Functions = Array();
					oLi_Functions[0]= new Array();
					oLi_Functions[0][0] = 'click';
					oLi_Functions[0][1] = function(){ 
								if(document.getElementById('content_'+sId).style.display=='none'){
									
									document.getElementById('content_'+sId).style.display='block';
									document.getElementById('arrow_'+sId).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png';
								
								}else{
									document.getElementById('content_'+sId).style.display='none';
									document.getElementById('arrow_'+sId).src=jQuery("#skyscraper_dir").val()+'images/toolbar/arrow_s.png';
								}
							};
		
		if(display){
				arrow='';
			}else{
				arrow='_s';
			}
		oLabel  = oPlugin.createElement('div','title_' +sId,'title',oLi_Functions,'<img id="arrow_'+sId+'" src="'+jQuery("#skyscraper_dir").val()+'images/toolbar/arrow'+arrow+'.png" /><span>'+sTitle+'</span>',null);
		oLabel.style.background=oPlugin.LabelBgColor;
		oLi.appendChild(oLabel);
		
		oLi_Content = oPlugin.createElement('div','content_' +sId,'content',oLi_Functions,sContent,null);
		if(sContent==''){oLi_Content.style.lineHeight='1px';oLi_Content.style.height='1px';oLi_Content.innerHTML='';}
			
			
			oLi_Content.align='center';
			if(display){
				oLi_Content.style.display='block';
			}else{
				oLi_Content.style.display='none';
			}
		oLi.appendChild(oLi_Content);
		
		document.getElementById('toolbar').appendChild(oLi);
		
 },
 
 CreateGoToHome:function(sId,sTitle,sContent){
 
		oLi = oPlugin.createElement('li',sId,'item',null,'',null);
		
		
		
		var oLi_Functions;
		
					oLi_Functions = Array();
					oLi_Functions[0]= new Array();
					oLi_Functions[0][0] = 'click';
					oLi_Functions[0][1] = function(){document.location.href ='http://'+ document.location.href.split("/")[2];};
		
			oLabel  = oPlugin.createElement('div','title_' +sId,'title',oLi_Functions,'<img id="arrow_'+sId+'" src="'+jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png" /><span>'+sTitle+'</span>',null);
		oLabel.style.background=oPlugin.LabelBgColor;
		oLi.appendChild(oLabel);
		
		oLi_Content = oPlugin.createElement('div','content_' +sId,'content',oLi_Functions,sContent,null);
		if(sContent==''){oLi_Content.style.lineHeight='1px';oLi_Content.style.height='1px';oLi_Content.innerHTML='';}
			oLi_Content.align='center';
			oLi_Content.style.display='block';
			oLi_Content.style.cursor='pointer';
		oLi.appendChild(oLi_Content);
		
		document.getElementById('toolbar').appendChild(oLi);
		
 },
 CreateNode: function(sId,sTitle,sContent,sContentDialog,sContentDialogStyle,dialogHeight,dialogWidth){

	oLi = oPlugin.createElement('li',sId,'item',null,'',null);
		
	var oLi_Functions;
	
	oLi_Functions = Array();
	oLi_Functions[0]= new Array();
			
	if (sContentDialogStyle == "banner"){
	
		oLi_Functions[0][0] = '';
		oLi_Functions[0][1] = '';
		
		oLabel  = oPlugin.createElement('div','title_' +sId,'title',oLi_Functions,'<img style="display:none" id="arrow_'+sId+'" src="" />',null);		
		oLabel.style.display = 'none';
	}
	else{
		
		oLi_Functions[0][0] = 'click';
		oLi_Functions[0][1] = function(){oPlugin.boxDialog(sId);};
		
		oLabel  = oPlugin.createElement('div','title_' +sId,'title',oLi_Functions,'<img id="arrow_'+sId+'" src="'+jQuery("#skyscraper_dir").val()+'images/toolbar/arrow.png" /><span>'+sTitle+'</span>',null);
		oLabel.style.background = oPlugin.LabelBgColor;
	}
	
	
	oLi.appendChild(oLabel);
		
	
	if(sContentDialog){
		var oLi_BoxShape = '<table class="shape" cellspacing="0" cellpadding="0" height="'+(dialogHeight)+'" width="100%"  >'+
							'<tr>'+
								'<td class="top-left" /><td class="top" /><td class="top-right" />'+
							'</tr>'+
							'<tr valign="top">'+
								'<td class="left"  style="font-size:10px;" >&nbsp;</td>'+
								'<td align="left"  style="background-color:'+oPlugin.BgColor+';width:'+(dialogWidth+50)+'px;" class="frame"  >';
		oLi_BoxShape += '';
		oLi_BoxShape += '<span style="color:'+oPlugin.Color+';position:absolute;margin-left:';
		
		if(oPlugin.Browser.Explorer){
					oLi_BoxShape += (oPlugin.PluginWidth+dialogWidth-oPlugin.PluginWidth-12)+'px;';
				}else{
					oLi_BoxShape += (oPlugin.PluginWidth+dialogWidth-oPlugin.PluginWidth)+'px;';
				}
		
		
		oLi_BoxShape += 'margin-top:5px;font-size:11px;font-weight:bold;cursor:pointer;border:solid 1px '+oPlugin.Color+';padding:2px;line-height:9px;padding-top:0px;padding-bottom:2px;" onclick="oPlugin.boxDialog(\''+sId+'\')" >x</span>';
 		oLi_BoxShape += '<div class="boxTitleContent" style="font-size:'+(oPlugin.FontSize+2)+'px;color:'+oPlugin.Color+';font-weight:bold;background:'+oPlugin.LabelBgColor+';';
		
		if(oPlugin.Browser.Explorer){
			oLi_BoxShape += 'width:'+(dialogWidth+8)+'px;';
		}else{
			oLi_BoxShape += 'width:'+(dialogWidth+13)+'px;';
		}
		
		oLi_BoxShape += '" >&nbsp;&nbsp;&nbsp;&nbsp;'+sTitle+'</div>';
		
		switch(sContentDialogStyle){
		
			case 'List':
			
				oLi_BoxShape += '<div align="left" style="height:'+(dialogHeight)+'px;margin:10px;margin-bottom:0px;padding-bottom:0px;width:100%;float:none;clear:both;" >';
				oLi_BoxShape += '<ul align="left" >';
				for(i=0;i<sContentDialog.length;i++){
					
					oLi_BoxShape += '<li style="position:relative;color:#c1c1c1;margin-left:-20px;margin-bottom:5px;font-size:'+oPlugin.FontSize+'px;padding-bottom:5px;list-style:disc;font-weight:bold;">'; 
					oLi_BoxShape += '<span style="color:'+oPlugin.Color+';" >'+sContentDialog[i][0]+'</span>&nbsp;&nbsp;';
					oLi_BoxShape += '<span style="height:'+(oPlugin.FontSize+2)+'px;color:'+oPlugin.Color+';opacity:0.4;filter: alpha(opacity=40);" >'+sContentDialog[i][1]+'</span>&nbsp;&nbsp;';
					oLi_BoxShape += '<a style="color:'+oPlugin.LinkColor+';" >'+sContentDialog[i][2]+'</a>';
					oLi_BoxShape += '</li>';
			
				}
				oLi_BoxShape += '</ul>';
				oLi_BoxShape += '</div>';
				
			  break;
			  	
  			case 'Urls':
  			
				oLi_BoxShape += '<div align="left" style="height:'+(dialogHeight)+'px;margin:10px;margin-bottom:0px;padding-bottom:0px;width:100%;float:none;clear:both;" >';
				oLi_BoxShape += '<ul align="left" >';
				for(i=0;i<sContentDialog.length;i++){
				
					oLi_BoxShape += '<li style="color:#c1c1c1;margin-left:-20px;margin-bottom:5px;font-size:'+oPlugin.FontSize+'px;padding-bottom:5px;list-style:disc;font-weight:bold;" >'; 
					oLi_BoxShape += '<a href="'+sContentDialog[i]+'" style="color:'+oPlugin.LinkColor+';" >'+sContentDialog[i]+'</a>';
					oLi_BoxShape += '</li>';
				
				}
				oLi_BoxShape += '</ul>';
				oLi_BoxShape += '</div>';
				
			  break;	
			  			  
			case 'Notice':
			
				//oPlugin.Browser.Explorer
				oLi_BoxShape += '<ul  style="margin-top:10px;margin-bottom:10px;margin-left:10px;padding-left:15px;width:'+(dialogWidth-50)+'px;" >';
				for(i=0;i<sContentDialog.length;i++){
				
					oLi_BoxShape += '<li style="font-size:'+oPlugin.FontSize+'px;';
					
					if(i != sContentDialog.length-1){
					
						oLi_BoxShape += 'padding-bottom:10px;border-bottom:solid 1px #c1c1c1;';
					}
					
					oLi_BoxShape +='list-style:disc;font-weight:bold;color:#c1c1c1;">'; 
					oLi_BoxShape += '<a style="color:'+oPlugin.LinkColor+';" >'+sContentDialog[i][0]+'</a> ';
					oLi_BoxShape += '<span style="height:'+(oPlugin.FontSize+2)+'px;color:'+oPlugin.Color+'; filter: alpha(opacity=40);opacity:0.4;" >'+sContentDialog[i][1]+'</span><br/>';
					oLi_BoxShape += '<span style="height:'+(oPlugin.FontSize+2)+'px;color:'+oPlugin.Color+';filter: alpha(opacity=70);opacity:0.7;" >'+sContentDialog[i][2]+'';
					oLi_BoxShape += ' - <a style="color:'+oPlugin.LinkColor+';" href="'+sContentDialog[i][3]+'" >'+sContentDialog[i][3]+'</a></span><br/>';
					oLi_BoxShape += '<span style="height:'+(oPlugin.FontSize+2)+'px;color:'+oPlugin.Color+';opacity:0.4;filter: alpha(opacity=40);" >'+sContentDialog[i][4]+'</span>';
					oLi_BoxShape += '</li>';
				
				}
				oLi_BoxShape += '</ul>';
			break;
			
			case 'Item':
			
				oLi_BoxShape += '<div align="left" style="opacity:0.8;filter: alpha(opacity=80);height:'+(dialogHeight)+'px;margin:10px;margin-bottom:0px;margin-top:5px;padding-bottom:0px;width:100%;float:none;clear:both;" >';
				oLi_BoxShape += '<ul align="left" >';
		
					oLi_BoxShape += '<li style="color:#c1c1c1;margin-left:-20px;font-size:'+oPlugin.FontSize+'px;padding-bottom:5px;list-style:disc;font-weight:bold;" >'; 
					oLi_BoxShape += '<span style="color:'+oPlugin.Color+';" >'+sContentDialog+'</span>';
					oLi_BoxShape += '</li>';
				
			
				oLi_BoxShape += '</ul>';
				oLi_BoxShape += '</div>';
			
			break;	
				
			default:
			
				oLi_BoxShape += '<div align="center" style="height:'+(dialogHeight)+'px;width:100%;" ><div  style="height:'+(dialogHeight)+'px;color:'+oPlugin.Color+';font-size:'+(oPlugin.FontSize-1)+'px;margin:5px;padding:0px;width:95%;float:none;clear:both;" >';
				oLi_BoxShape += sContentDialog ;
				oLi_BoxShape += '</div></div>';
			break;		
		
		}
		
		
		
		oLi_BoxShape += '<td class="right" style="font-size:10px;" >&nbsp;</td>'+
						'</tr>'+
						'<tr>'+
							'<td class="bottom-left" /><td class="bottom" /><td class="bottom-right" />'+
						'</tr>'+
						'</table>';
		
		
		oLi_BoxDialog = oPlugin.createElement('div','boxDialog_' +sId,'boxDialog',null,oLi_BoxShape,null);
		oLi_BoxDialog.align='left';
			
			
		if(dialogWidth){
			oLi_BoxDialog.style.width=(dialogWidth+10)+'px';
		}
		
		if(dialogHeight){
			if(oPlugin.Browser.Explorer){
				oLi_BoxDialog.style.height=(dialogHeight+100)+'px';	
			}else{
				oLi_BoxDialog.style.height=(dialogHeight+10)+'px';	
			}
		}
			
		oLi_BoxDialog.style.display='none';
		
		
		oLi_BoxDialog.style.left=(oPlugin.PluginWidth-7+7)+'px';
		oLi_BoxDialog.style.marginTop='-35px';
			
		oLi.appendChild(oLi_BoxDialog);
	}
	
	
	oLi_Content = oPlugin.createElement('div','content_' +sId,'content',null,sContent,null);
	if(sContent==''){oLi_Content.style.lineHeight='1px';oLi_Content.style.height='1px';oLi_Content.innerHTML='';}
		oLi_Content.align='center';
		oLi_Content.style.display='block';
	oLi.appendChild(oLi_Content);

	
	document.getElementById('toolbar').appendChild(oLi);
},
createElement: function(sType,sId,sClass,aFunctions,sHtml,oParent){

		var oElement;			
		
		oElement=document.createElement(sType);
		oElement.setAttribute('id',sId);
		oElement.className=sClass;			
		
		if(sHtml)
		{						
			oElement.innerHTML=sHtml;
		}
		
		if (aFunctions)
		{
			for (iFunctions=0;iFunctions< aFunctions.length;iFunctions++)
			{															
				if (oPlugin.Browser.Other)
				{												
					oElement.addEventListener(aFunctions[iFunctions][0],eval(aFunctions[iFunctions][1]),false);					
				}
				if (oPlugin.Browser.Explorer)
				{					
					oElement['on' + aFunctions[iFunctions][0]]= aFunctions[iFunctions][1];
				}
			}
		}
		
		if (oParent)
		{
			oParent.appendChild(oElement);
		}else{
			return oElement;
		}
	}
};
function twitter(url,title){
    return '<a href="https://twitter.com/share" data-text="'+ title +' (via http://www.fueto.com)" data-url="'+ url + '" class="twitter-share-button" data-count="horizontal">Tweet</a><scr'+'ipt type="text/javascript" src="//platform.twitter.com/widgets.js"></scr'+'ipt>';
}

function facebook(url){

return '<iframe src="//www.facebook.com/plugins/like.php?href='+url+'&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font" scrolling="no" frameborder="0" style="border:none; overflow:hidden;height:32px;width:115px" allowTransparency="true"></iframe>'
}

function plus(url){
    return '<g:plusone annotation="bubble" href="'+url+'" size="medium"></g:plusone>';

} 

function counters(){

  jQuery("span#socialstats").each(  
 
  function(i) {
        var url = jQuery(this).attr("url");
        var title = jQuery(this).attr("title");
        var append = '<table border=0"><tr>';
        append += '<td valign="top">'+twitter(url,title)+'</td>' ;     
  	    append += '<td valign="top">'+plus(url)+'</td>' ;      
        append += '<td valign="baseline">'+facebook(url)+'</td>' ;             
        append += '</tr></table>';
        jQuery(this).html(append);
 
 
	});        
 } 
  
var repeatBanner = 0;  
  
function showBanner(timer, colorBack, colorLabel, colorFont, fontSize){
 	
 	if (repeatBanner < 2){
 	
	 	jQuery('#boxDialog_New_Id_14 .frame').css("background-color", colorBack);
		jQuery('#boxDialog_New_Id_14 .boxTitleContent').css("background-color", colorLabel);
		jQuery('#boxDialog_New_Id_14 .boxTitleContent').css("color", colorFont);
		jQuery('#boxDialog_New_Id_14 .boxTitleContent').css("font-size", fontSize);
	
		oPlugin.boxDialog('New_Id_14');
	 
		setTimeout('showBanner('+timer+')',  timer);
		
		repeatBanner ++;
	}
}
     
;function more(obj, id){
	
	var button;
	var box;
	var sociable;
	
	box = document.getElementById("sociable-"+id+"");
	button = obj;
	sociable = document.getElementById("sociable");
	//console.log(sociable.style.offsetTop);
	sociable.style.postion = "absloute";
	sociable.style.top = button.offsetTop;
	//alert(button.offsetTop);
	//alert(button.offsetLeft);
	sociable.style.left = button.offsetLeft;
	//console.log(sociable.style.offsetTop);
	box.style.display = "";
}

var t;
function hide_sociable(id,close){
	if (close == null){
	t = setTimeout(function (){
		hide_sociable(id,true)
	},1000);
	}else{
	var box;
	box = document.getElementById("sociable-"+id+"");
	box.style.display = "none";		
	}
}

function get_object(id) {
	var object = null;
	if( document.layers )	{			
		object = document.layers[id];
	} else if( document.all ) {
		object = document.all[id];
	} else if( document.getElementById ) {
		object = document.getElementById(id);
	}
	return object;
}

function is_child_of(parent, child) {
	if( child != null ) {			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}
function fixOnMouseOut(element, event, id) {
	clearTimeout(t);
	var current_mouse_target = null;
	if( event.toElement ) {				
		current_mouse_target 			 = event.toElement;
	} else if( event.relatedTarget ) {				
		current_mouse_target 			 = event.relatedTarget;
	}
	if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
		
		hide_sociable(id)
	}
}


      window.___gcfg = {
        lang: 'en-US'
      };

      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();



;function AddToFavorites()  
{  
    var title = document.title; var url = location.href;  
    if (window.sidebar) // Firefox  
        window.sidebar.addPanel(title, url, '');  
    else if(window.opera && window.print) // Opera  
    {  
        var elem = document.createElement('a');  
        elem.setAttribute('href',url);  
        elem.setAttribute('title',title);  
        elem.setAttribute('rel','sidebar'); // required to work in opera 7+  
        elem.click();  
    }   
    else if(document.all) // IE  
        window.external.AddFavorite(url, title);  
}
;addComment={moveForm:function(d,f,i,c){var m=this,a,h=m.I(d),b=m.I(i),l=m.I("cancel-comment-reply-link"),j=m.I("comment_parent"),k=m.I("comment_post_ID");if(!h||!b||!l||!j){return}m.respondId=i;c=c||false;if(!m.I("wp-temp-form-div")){a=document.createElement("div");a.id="wp-temp-form-div";a.style.display="none";b.parentNode.insertBefore(a,b)}h.parentNode.insertBefore(b,h.nextSibling);if(k&&c){k.value=c}j.value=f;l.style.display="";l.onclick=function(){var n=addComment,e=n.I("wp-temp-form-div"),o=n.I(n.respondId);if(!e||!o){return}n.I("comment_parent").value="0";e.parentNode.insertBefore(o,e);e.parentNode.removeChild(e);this.style.display="none";this.onclick=null;return false};try{m.I("comment").focus()}catch(g){}return false},I:function(a){return document.getElementById(a)}};
;/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-06-19 20:25:28 -0500 (Tue, 19 Jun 2007) $
 * $Rev: 2111 $
 *
 * Version 2.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&parseInt($.browser.version)<=6){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};if(!$.browser.version)$.browser.version=navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1];})(jQuery);

/*************************************************
**  jQuery Masonry version 1.3.2
**  Copyright David DeSandro, licensed MIT
**  http://desandro.com/resources/jquery-masonry
**************************************************/
(function(e){var n=e.event,o;n.special.smartresize={setup:function(){e(this).bind("resize",n.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",n.special.smartresize.handler)},handler:function(j,l){var g=this,d=arguments;j.type="smartresize";o&&clearTimeout(o);o=setTimeout(function(){jQuery.event.handle.apply(g,d)},l==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,l){var g={getBricks:function(d,b,a){var c=a.itemSelector===undefined;b.$bricks=a.appendedContent===undefined?c?d.children():d.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(d,b,a,c,h){b=Math.min.apply(Math,a);for(var i=b+d.outerHeight(true),f=a.length,k=f,m=c.colCount+1-f;f--;)if(a[f]==b)k=f;d.applyStyle({left:c.colW*k+c.posLeft,top:b},e.extend(true,{},h.animationOptions));for(f=0;f<m;f++)c.colY[k+f]=i},setup:function(d,b,a){g.getBricks(d,a,b);if(a.masoned)a.previousData=d.data("masonry");a.colW=b.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):b.columnWidth;a.colCount=Math.floor(d.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(d,b,a){var c;if(!a.masoned||b.appendedContent!==undefined)a.$bricks.css("position","absolute");if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{d.css("position","relative");var h=e(document.createElement("div"));d.prepend(h);a.posTop=Math.round(h.position().top);a.posLeft=Math.round(h.position().left);h.remove()}if(a.masoned&&b.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&b.animate?e.fn.animate:e.fn.css;b.singleMode?a.$bricks.each(function(){var i=e(this);g.placeBrick(i,a.colCount,a.colY,a,b)}):a.$bricks.each(function(){var i=e(this),f=Math.ceil(i.outerWidth(true)/a.colW);f=Math.min(f,a.colCount);if(f===1)g.placeBrick(i,a.colCount,a.colY,a,b);else{var k=a.colCount+1-f,m=[];for(c=0;c<k;c++){var p=a.colY.slice(c,c+f);m[c]=Math.max.apply(Math,p)}g.placeBrick(i,k,m,a,b)}});a.wallH=Math.max.apply(Math,a.colY);d.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],b.animationOptions));a.masoned||setTimeout(function(){d.addClass("masoned")},1);l.call(a.$bricks);d.data("masonry",a)},resize:function(d,b,a){a.masoned=!!d.data("masonry");var c=d.data("masonry").colCount;g.setup(d,b,a);a.colCount!=c&&g.arrange(d,b,a)}};return this.each(function(){var d=e(this),b={};b.masoned=!!d.data("masonry");var a=b.masoned?d.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),h=a.resizeable;b.options=c.saveOptions?c:a;l=l||function(){};g.getBricks(d,b,c);if(!b.$bricks.length)return this;g.setup(d,c,b);g.arrange(d,c,b);!h&&c.resizeable&&e(window).bind("smartresize.masonry",function(){g.resize(d,c,b)});h&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults={singleMode:false,columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);

/*!
 * jQuery Fancy Letter Plugin v1.1
 *
 * Date: Sun Feb 06 20:51:59 2011 EST
 * Requires: jQuery v1.2.6+
 *
 * Copyright 2011, Karl Swedberg
 * Dual licensed under the MIT and GPL licenses (just like jQuery):
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Contributor: Matt Wiebe (::first-letter spec semi-conformance)
 *
 *
*/
(function(g){g.fn.fancyletter=function(m){function k(a,d,b){return['<span class="',b.punctuationClass," ",b.ltrClassPrefix+b["punctuation"+a][d],'">',d,"</span>"].join("")}function l(a,d){var b=a.firstChild,e="",f={};if(!a)return f;for(;a.childNodes.length;)a=a.firstChild;e=a.nodeValue&&a.nodeValue.replace(/^\s\s*/,"")||"";if(e===""&&b&&b.nextSibling)return l(b.nextSibling,d);else{b=e;for(var i=f="",c=0,h=b.charAt(c),j={};h in d.punctuationLeft;){c++;f+=k("Left",h,d);h=b.charAt(c)}j.pl=f;j.firstChar=
h;c++;for(h=b.charAt(c);h in d.punctuationRight;){c++;i+=k("Right",h,d);h=b.charAt(c)}j.pr=i;j.slicePoint=c;f=j;f.node=a;f.val=e;return f}}this.each(function(){var a,d,b,e,f=this;a=g(this);var i=g.extend({},g.fn.fancyletter.defaults,m||{},g.metadata?a.metadata():g.meta?a.data():{}),c=RegExp(i.characters);e=l(f,i);if(e.firstChar){a=e.val;f=e.node;d=e.firstChar;b=d.toLowerCase();if(c.test(d)){c=g("<span></span>");f.nodeValue=a.slice(e.slicePoint);c.html(e.pl+d+e.pr);c.addClass(i.commonClass+" "+i.ltrClassPrefix+
b);c.prependTo(this)}}});return this};g.fn.fancyletter.defaults={commonClass:"fancy-letter",ltrClassPrefix:"ltr-",characters:"[a-zA-Z0-9]",groupPunctuation:true,punctuationClass:"punct",punctuationLeft:{'"':"dquo","'":"squo","\u201c":"ldquo","\u2018":"lsquo","\u00ab":"laquo","\u2039":"lsaquo","(":"lparen"},punctuationRight:{'"':"dquo","'":"squo","\u201d":"rdquo","\u2019":"rsquo","\u00bb":"raquo","\u203a":"rsaquo",")":"rparen"}}})(jQuery);

/**
 * suffusion.js - Contains all custom JavaScript functions required by Suffusion
 */

$j = jQuery.noConflict();

$j.fn.extend({
	highlight: function(search, insensitive, hls_class){
		var regex = new RegExp("(<[^>]*>)|(\\b"+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +")", insensitive ? "ig" : "g");
		return this.html(this.html().replace(regex, function(a, b, c){
			return (a.charAt(0) == "<") ? a : "<span class=\""+ hls_class +"\">" + c + "</span>";
		}));
	}
});

$j.fn.removeHighlight = function() {
	return this.find("span.search-highlight").each(function() {
		with (this.parentNode) {
			replaceChild(this.firstChild, this);
			normalize();
		}
	}).end();
};

function sufHtmlEncode(value){
	return $j('<div/>').text(value).html();
}

function sufHtmlDecode(value){
	return $j('<div/>').html(value).text();
}

$j(document).ready(function() {
    /* Magazine JS, for the headline section */
	$j('div.suf-mag-headlines div.suf-mag-headline-photo').hide();
	$j('div.suf-mag-headline-photo-first').show();
	$j('div.suf-mag-headline-block ul.mag-headlines li.suf-mag-headline-first a').addClass('tab-current');

	$j('div.suf-mag-headline-block ul.mag-headlines li a').hover(function(){
		var thisClass = this.className.substring(17, this.className.indexOf(" "));
		$j('div.suf-mag-headlines div.suf-mag-headline-photo').hide();
		$j('div.suf-mag-headline-block ul.mag-headlines li a').removeClass('tab-current');
        $j('div.suf-mag-headline-photo-' + thisClass).show();
		$j(this).addClass('tab-current');
	}   );
    /* End Magazine JS */

    /* Tabbed Widgets */
    $j('div.tab-box div.sidebar-tab-content').hide();
    $j('div.sbtab-content-first').show();
    $j('div.tab-box ul.sidebar-tabs li.sbtab-first a').addClass('tab-current');

    $j('div.tab-box ul.sidebar-tabs li a').click(function(){
        var thisClass = this.className.substring(6, this.className.indexOf(" "));
        $j('div.tab-box div.sidebar-tab-content').hide();
        $j('div.tab-box div.sbtab-content-' + thisClass).show();
        $j('div.tab-box ul.sidebar-tabs li a').removeClass('tab-current');
        $j(this).addClass('tab-current');
    });
    /* End Tabbed Widgets */

    /* JQuery-based fix for widgets that do not print "after_title" */
    $j('.dbx-handle').each(function() {
        $j(this).prependTo(this.parentNode.parentNode);
    });
    /* End JQuery-based fix */

	/* JQuery for tabbed sidebars */
	$j('.sidebar-tab .sidebar-tab-content').each(function() {
		var parentId = this.parentNode.id;
		var parentClass = this.parentNode.className;
		parentClass = parentClass.substring(12);
		$j(this).addClass('sbtab-content-' + parentId);
		$j(this).addClass(parentClass);
	    $j(this).appendTo(this.parentNode.parentNode.parentNode);
	});

	$j('.tabbed-sidebar ul.sidebar-tabs a').each(function() {
		var parentId = this.parentNode.id;
		$j(this).addClass(parentId);
	});

	$j('#wsidebar-top.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
	$j('#wsidebar-top.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
	$j('#sidebar.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
	$j('#sidebar.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
	$j('#sidebar-b.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
	$j('#sidebar-b.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
	$j('#sidebar-2.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
	$j('#sidebar-2.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
	$j('#sidebar-2-b.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
	$j('#sidebar-2-b.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
	$j('#wsidebar-bottom.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
	$j('#wsidebar-bottom.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');

	$j('div.tabbed-sidebar div.sidebar-tab-content').hide();
	$j('div.sbtab-content-first').show();
	$j('div.tabbed-sidebar ul.sidebar-tabs li.sbtab-first a').addClass('tab-current');

	$j('div.tabbed-sidebar ul.sidebar-tabs li a').click(function(){
		$j(this).removeClass('tab-current');
	    var thisClass = this.className.substring(12, this.className.length);
		var parentId = this.parentNode.parentNode.parentNode.id;
	    $j('#' + parentId + '.tabbed-sidebar div.sidebar-tab-content').hide();
	    $j('#' + parentId + '.tabbed-sidebar div.sbtab-content-' + thisClass).show();
	    $j('#' + parentId + '.tabbed-sidebar ul.sidebar-tabs li a').removeClass('tab-current');
	    $j(this).addClass('tab-current');
	});
	/* End tabbed sidebars */

	$j("ul.sf-menu li.current_page_item > a, ul.sf-menu li.current-cat > a, ul.sf-menu li.current-menu-item > a").each(function() {
		$j(this).addClass('current');
	});

	$j("ul.sf-menu > li > ul").each(function() {
		var parentClass = this.parentNode.className;
		var a_tag_h = this.parentNode.childNodes[0];
		var a_tag = $j(a_tag_h);
		a_tag.prepend("<!--[if !IE]>--><span class='down-ptr'>&nbsp;</span><!--<![endif]-->");
		a_tag.append("<!--[if lt IE 7]>&nbsp;&nbsp;&darr;<![endif]--> <!--[if (!IE)|(gte IE 7)]><span class='down-ptr'>&nbsp;</span><![endif]-->");
		a_tag.addClass('with-arrow');
	});

	$j("ul.sf-menu ul ul").each(function() {
		var parentClass = this.parentNode.className;
		var a_tag_h = this.parentNode.childNodes[0];
		var a_tag = $j(a_tag_h);
		a_tag.prepend("<!--[if !IE]>--><span class='float-ptr'>&nbsp;</span><!--<![endif]-->");
		a_tag.append("<!--[if lt IE 7]>&nbsp;&nbsp;&rarr;<![endif]--> <!--[if (!IE)|(gte IE 7)]><span class='float-ptr'>&nbsp;</span><![endif]-->");
		a_tag.addClass('drop');
	});

	$j("#nav ul.sf-menu li, #nav-top ul.sf-menu li").each(function() {
		$j(this).children('ul:first').hide();
		$j(this).find('ul:first').css({visibility: "hidden"});
	});

	$j("#nav ul.sf-menu li").hover(
			function() {
				if (Suffusion_JS.suf_nav_effect == 'fade') {
					$j(this).children('ul:first').fadeIn(Suffusion_JS.suf_nav_delay).css({visibility: "visible"});
				}
				else {
					$j(this).children('ul:first').show(Suffusion_JS.suf_nav_delay).css({visibility: "visible"});
				}
			},
			function() {
				$j(this).children('ul:first').hide();
				$j(this).find('ul:first').css({visibility: "hidden"});
			}).bgIframe({opacity: 'show'});

	$j("#nav-top ul.sf-menu li").hover(
			function() {
				if (Suffusion_JS.suf_navt_effect == 'fade') {
					$j(this).find('ul:first').fadeIn(Suffusion_JS.suf_navt_delay).css({visibility: "visible"});
				}
				else {
					$j(this).find('ul:first').show(Suffusion_JS.suf_navt_delay).css({visibility: "visible"});
				}
			},
			function() {
				$j(this).children('ul:first').hide();
				$j(this).find('ul:first').css({visibility: "hidden"});
			}).bgIframe({opacity: 'show'});

	// Expand Panel
	$j("#top-bar-right-spanel-tab .open").click(function(){
		$j("#top-bar-right-spanel").slideDown("medium");
		return false;
	});
	// Collapse Panel
	$j("#top-bar-right-spanel-tab .close").click(function(){
		$j("#top-bar-right-spanel").slideUp("medium");
		return false;
	});
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$j("#top-bar-right-spanel-tab .toggle a").click(function () {
		$j("#top-bar-right-spanel-tab .toggle a").toggle();
		return false;
	});

	$j('#search-info input[type="checkbox"].search-hl').change(function(event) {
		var search = $j('#search-term').val();
		var hls_class = 'search-highlight';
		if ($j(this).attr('checked')) {
			// Highlight search results
			$j('#content .entry').each(function() {
				var quotes = search.match(/"([^"]+)"/g);
				var len = 0;
				var matches = new Array();
				if (quotes != null) {
					len = quotes.length;
					for (i=0; i<len; i++) {
						quotes[i] = quotes[i].replace(/"/g, '');
						matches[matches.length] = quotes[i];
						search = search.replace(quotes[i], ' ');
					}
				}

				var no_quotes = search.match(/\b[\S]+\b/g);
				if (no_quotes != null) {
					len = no_quotes.length;
					for (i=0; i<len; i++) {
						matches[matches.length] = no_quotes[i];
					}
				}

				len = matches.length;
				for (i=0; i<len; i++) {
					var search_string = matches[i];
					$j(this).highlight(search_string);
					$j(this).highlight(search_string, true, hls_class);
				}
			});
		}
		else {
			//Un-highlight search results
			$j('#content .entry').each(function() {
				$j(this).removeHighlight();
			});
		}
	});

	if (typeof Suffusion_JS.suf_jq_masonry_enabled != 'undefined' && Suffusion_JS.suf_jq_masonry_enabled == 'enabled') {
		//$j("#top-bar-right-spanel").masonry();
		//$j("#widgets-above-header").masonry();
		$j("#horizontal-outer-widgets-1").masonry();
		$j("#horizontal-outer-widgets-2").masonry();
		$j("#ad-hoc-1").masonry();
		$j("#ad-hoc-2").masonry();
		$j("#ad-hoc-3").masonry();
		$j("#ad-hoc-4").masonry();
		$j("#ad-hoc-5").masonry();
	}

	if (Suffusion_JS.suf_fix_aspect_ratio == 'preserve') {
		// If the HTML height attribute is present for images, the max-width setting really hammers the image proportions.
		$j(".entry img").removeAttr('height');
	}

	// Fixes for NGG on IE8. This should ideally be on NGG's plugin itself, but given their support or lack thereof :-( ...
	$j(".ngg-gallery-thumbnail img").removeAttr('height');
	$j(".ngg-gallery-thumbnail img").removeAttr('width');

	$j(".widget_calendar tbody td a").each(function() {
		var parent = this.parentNode;
		//var a_tag_h = this.parentNode.childNodes[0];
		var td_tag = $j(parent);
		td_tag.addClass('with-posts');
	});

	$j('a.suf-tile-icon').click(function() {
		var class_name = this.className;
		var thisId = this.id;
		var lastSep = thisId.lastIndexOf('-');
		var elementType = thisId.substr(0, lastSep);
		var elementId = thisId.substr(lastSep);
		var textElementId = elementType + '-text' + elementId;
		$j('#' +  textElementId).toggle();
		if (class_name.indexOf('clicked') > -1) {
			$j(this).removeClass('clicked');
		}
		else {
			$j(this).addClass('clicked');
		}
		return false;
	});

	// JQuery Cycle stops if there is only one image in it. The following snippet fixes the issue.
	$j('#sliderContent, .sliderContent').each(function() {
		if ($j(this).children().length == 1) {
			var single = this.firstChild;
			$j(single).show();
		}
	});

	$j('.mosaic-page-nav-right a, .mosaic-page-nav-left a').each(function() {
		var parentContainer = $j(this).parent().parent();
		var height = 0.45 * parentContainer.height();
		$j(this).css({top: height + 'px'});
	});

	$j('#sliderContent').each(function() {
		$j(this).cycle({
			fx: Suffusion_JS.suf_featured_fx,
			timeout: Suffusion_JS.suf_featured_interval,
			speed: Suffusion_JS.suf_featured_transition_speed,
			pause: 1,
			sync: Suffusion_JS.suf_featured_sync,
			pager: '#sliderPager',
			prev: 'a.sliderPrev',
			next: 'a.sliderNext'
		});
	});
	$j('a.sliderPause').click(
		function() {
			if ($j(this).text() == Suffusion_JS.suf_featured_pause) {
				$j('#sliderContent').cycle('pause');
				$j('a.sliderPause').addClass('activeSlide');
				$j(this).text(Suffusion_JS.suf_featured_resume);
			}
			else {
				$j('#sliderContent').cycle('resume');
				$j('a.sliderPause').removeClass('activeSlide');
				$j(this).text(Suffusion_JS.suf_featured_pause);
			}
			return false;
		}
	);
	$j('.collapse .searchfield').focus(function() {
		$j(this).addClass('search-focus');
	});
	$j('.collapse .searchfield').blur(function() {
		$j(this).removeClass('search-focus');
	});

	$j('a.suf-mosaic-thumb').each(function() {
		$j(this).data('title', $j(this).attr('title'));
		//console.log($j(this).data('title'));
		if ($j.fancybox) {
			$j(this).fancybox({
				transitionIn	:	'elastic',
				transitionOut	:	'elastic',
				speedIn		:	600,
				speedOut		:	200,
				overlayShow	:	true,
				overlayColor:	'#000',
				overlayOpacity: 0.8
			});
		}
		else if ($j.colorbox) {
			$j(this).colorbox({
				opacity: 0.8,
				maxWidth: '95%',
				maxHeight: '95%'
			});
		}
	});

	$j('.mosaic-overlay').hover(function() {
		$j(this).stop().animate({
			opacity: 0.65
		}, "medium");
	}, function() {
		$j(this).stop().animate({
			opacity: 0
		}, "medium");
	});

	$j('.entry > p:first-child').each(function() {
		$j(this).addClass('first-para');
	});

	if (Suffusion_JS.suf_show_drop_caps != '') {
		$j(Suffusion_JS.suf_show_drop_caps).fancyletter();
	}

	$j(".exif-button .open").live('click', function(){
		$j(".exif-panel").slideDown("medium");
		$j(this).removeClass('open').addClass('close');
		return false;
	});
	// Collapse Panel
	$j(".exif-button .close").live('click', function(){
		$j(".exif-panel").slideUp("medium");
		$j(this).removeClass('close').addClass('open');
		return false;
	});
});

;jQuery(document).ready(function($){
	$('#tabs').tabs();
});
;function sack(file){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=file;this.vars=new Object();this.responseStatus=new Array(2)};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){}};this.reset=function(){this.resetFunctions();this.resetData()};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){this.xmlhttp=null}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest()}else{this.failed=true}}};this.setVar=function(name,value){this.vars[name]=Array(value,false)};this.encVar=function(name,value,returnvars){if(true==returnvars){return Array(encodeURIComponent(name),encodeURIComponent(value))}else{this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}};this.processURLString=function(string,encode){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=string.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==encode){this.encVar(urlVars[0],urlVars[1])}else{this.setVar(urlVars[0],urlVars[1])}}};this.createURLString=function(urlstring){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true)}if(urlstring){if(this.URLString.length){this.URLString+=this.argumentSeparator+urlstring}else{this.URLString=urlstring}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0]}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}if(urlstring){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{this.URLString+=urlstringtemp.join(this.argumentSeparator)}};this.runResponse=function(){eval(this.response)};this.runAJAX=function(urlstring){if(this.failed){this.onFail()}else{this.createURLString(urlstring);if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var self=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true)}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(self.xmlhttp.readyState){case 1:self.onLoading();break;case 2:self.onLoaded();break;case 3:self.onInteractive();break;case 4:self.response=self.xmlhttp.responseText;self.responseXML=self.xmlhttp.responseXML;self.responseStatus[0]=self.xmlhttp.status;self.responseStatus[1]=self.xmlhttp.statusText;if(self.execute){self.runResponse()}if(self.elementObj){elemNodeName=self.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){self.elementObj.value=self.response}else{self.elementObj.innerHTML=self.response}}if(self.responseStatus[0]=="200"){self.onCompletion()}else{self.onError()}self.URLString="";break}};this.xmlhttp.send(this.URLString)}}};this.reset();this.createAJAX()};
;/*!
 * jQuery Form Plugin
 * version: 2.95 (30-JAN-2012)
 * @requires jQuery v1.3.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *	http://www.opensource.org/licenses/mit-license.php
 *	http://www.gnu.org/licenses/gpl.html
 */
;(function($) {

/*
	Usage Note:
	-----------
	Do not use both ajaxSubmit and ajaxForm on the same form.  These
	functions are intended to be exclusive.  Use ajaxSubmit if you want
	to bind your own submit handler to the form.  For example,

	$(document).ready(function() {
		$('#myForm').bind('submit', function(e) {
			e.preventDefault(); // <-- important
			$(this).ajaxSubmit({
				target: '#output'
			});
		});
	});

	Use ajaxForm when you want the plugin to manage all the event binding
	for you.  For example,

	$(document).ready(function() {
		$('#myForm').ajaxForm({
			target: '#output'
		});
	});

	When using ajaxForm, the ajaxSubmit function will be invoked for you
	at the appropriate time.
*/

/**
 * ajaxSubmit() provides a mechanism for immediately submitting
 * an HTML form using AJAX.
 */
$.fn.ajaxSubmit = function(options) {
	// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
	if (!this.length) {
		log('ajaxSubmit: skipping submit process - no element selected');
		return this;
	}
	
	var method, action, url, $form = this;

	if (typeof options == 'function') {
		options = { success: options };
	}

	method = this.attr('method');
	action = this.attr('action');
	url = (typeof action === 'string') ? $.trim(action) : '';
	url = url || window.location.href || '';
	if (url) {
		// clean url (don't include hash vaue)
		url = (url.match(/^([^#]+)/)||[])[1];
	}

	options = $.extend(true, {
		url:  url,
		success: $.ajaxSettings.success,
		type: method || 'GET',
		iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
	}, options);

	// hook for manipulating the form data before it is extracted;
	// convenient for use with rich editors like tinyMCE or FCKEditor
	var veto = {};
	this.trigger('form-pre-serialize', [this, options, veto]);
	if (veto.veto) {
		log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
		return this;
	}

	// provide opportunity to alter form data before it is serialized
	if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
		log('ajaxSubmit: submit aborted via beforeSerialize callback');
		return this;
	}

	var traditional = options.traditional;
	if ( traditional === undefined ) {
		traditional = $.ajaxSettings.traditional;
	}
	
	var qx,n,v,a = this.formToArray(options.semantic);
	if (options.data) {
		options.extraData = options.data;
		qx = $.param(options.data, traditional);
	}

	// give pre-submit callback an opportunity to abort the submit
	if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
		log('ajaxSubmit: submit aborted via beforeSubmit callback');
		return this;
	}

	// fire vetoable 'validate' event
	this.trigger('form-submit-validate', [a, this, options, veto]);
	if (veto.veto) {
		log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
		return this;
	}

	var q = $.param(a, traditional);
	if (qx) {
		q = ( q ? (q + '&' + qx) : qx );
	}	
	if (options.type.toUpperCase() == 'GET') {
		options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
		options.data = null;  // data is null for 'get'
	}
	else {
		options.data = q; // data is the query string for 'post'
	}

	var callbacks = [];
	if (options.resetForm) {
		callbacks.push(function() { $form.resetForm(); });
	}
	if (options.clearForm) {
		callbacks.push(function() { $form.clearForm(options.includeHidden); });
	}

	// perform a load on the target only if dataType is not provided
	if (!options.dataType && options.target) {
		var oldSuccess = options.success || function(){};
		callbacks.push(function(data) {
			var fn = options.replaceTarget ? 'replaceWith' : 'html';
			$(options.target)[fn](data).each(oldSuccess, arguments);
		});
	}
	else if (options.success) {
		callbacks.push(options.success);
	}

	options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
		var context = options.context || options;	// jQuery 1.4+ supports scope context 
		for (var i=0, max=callbacks.length; i < max; i++) {
			callbacks[i].apply(context, [data, status, xhr || $form, $form]);
		}
	};

	// are there files to upload?
	var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113)
	var hasFileInputs = fileInputs.length > 0;
	var mp = 'multipart/form-data';
	var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);

	var fileAPI = !!(hasFileInputs && fileInputs.get(0).files && window.FormData);
	log("fileAPI :" + fileAPI);
	var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;

	// options.iframe allows user to force iframe mode
	// 06-NOV-09: now defaulting to iframe mode if file input is detected
	if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
		// hack to fix Safari hang (thanks to Tim Molendijk for this)
		// see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
		if (options.closeKeepAlive) {
			$.get(options.closeKeepAlive, function() {
				fileUploadIframe(a);
			});
		}
  		else {
			fileUploadIframe(a);
  		}
	}
	else if ((hasFileInputs || multipart) && fileAPI) {
		options.progress = options.progress || $.noop;
		fileUploadXhr(a);
	}
	else {
		$.ajax(options);
	}

	 // fire 'notify' event
	 this.trigger('form-submit-notify', [this, options]);
	 return this;

	 // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
	function fileUploadXhr(a) {
		var formdata = new FormData();

		for (var i=0; i < a.length; i++) {
			if (a[i].type == 'file')
				continue;
			formdata.append(a[i].name, a[i].value);
		}

		$form.find('input:file:enabled').each(function(){
			var name = $(this).attr('name'), files = this.files;
			if (name) {
				for (var i=0; i < files.length; i++)
					formdata.append(name, files[i]);
			}
		});

		if (options.extraData) {
			for (var k in options.extraData)
				formdata.append(k, options.extraData[k])
		}

		options.data = null;

		var s = $.extend(true, {}, $.ajaxSettings, options, {
			contentType: false,
			processData: false,
			cache: false,
			type: 'POST'
		});

      //s.context = s.context || s;

      s.data = null;
      var beforeSend = s.beforeSend;
      s.beforeSend = function(xhr, o) {
          o.data = formdata;
          if(xhr.upload) { // unfortunately, jQuery doesn't expose this prop (http://bugs.jquery.com/ticket/10190)
              xhr.upload.onprogress = function(event) {
                  o.progress(event.position, event.total);
              };
          }
          if(beforeSend)
              beforeSend.call(o, xhr, options);
      };
      $.ajax(s);
   }

	// private function for handling file uploads (hat tip to YAHOO!)
	function fileUploadIframe(a) {
		var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
		var useProp = !!$.fn.prop;

		if (a) {
			if ( useProp ) {
				// ensure that every serialized input is still enabled
				for (i=0; i < a.length; i++) {
					el = $(form[a[i].name]);
					el.prop('disabled', false);
				}
			} else {
				for (i=0; i < a.length; i++) {
					el = $(form[a[i].name]);
					el.removeAttr('disabled');
				}
			};
		}

		if ($(':input[name=submit],:input[id=submit]', form).length) {
			// if there is an input with a name or id of 'submit' then we won't be
			// able to invoke the submit fn on the form (at least not x-browser)
			alert('Error: Form elements must not have name or id of "submit".');
			return;
		}
		
		s = $.extend(true, {}, $.ajaxSettings, options);
		s.context = s.context || s;
		id = 'jqFormIO' + (new Date().getTime());
		if (s.iframeTarget) {
			$io = $(s.iframeTarget);
			n = $io.attr('name');
			if (n == null)
			 	$io.attr('name', id);
			else
				id = n;
		}
		else {
			$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
			$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
		}
		io = $io[0];


		xhr = { // mock object
			aborted: 0,
			responseText: null,
			responseXML: null,
			status: 0,
			statusText: 'n/a',
			getAllResponseHeaders: function() {},
			getResponseHeader: function() {},
			setRequestHeader: function() {},
			abort: function(status) {
				var e = (status === 'timeout' ? 'timeout' : 'aborted');
				log('aborting upload... ' + e);
				this.aborted = 1;
				$io.attr('src', s.iframeSrc); // abort op in progress
				xhr.error = e;
				s.error && s.error.call(s.context, xhr, e, status);
				g && $.event.trigger("ajaxError", [xhr, s, e]);
				s.complete && s.complete.call(s.context, xhr, e);
			}
		};

		g = s.global;
		// trigger ajax global events so that activity/block indicators work like normal
		if (g && ! $.active++) {
			$.event.trigger("ajaxStart");
		}
		if (g) {
			$.event.trigger("ajaxSend", [xhr, s]);
		}

		if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
			if (s.global) {
				$.active--;
			}
			return;
		}
		if (xhr.aborted) {
			return;
		}

		// add submitting element to data if we know it
		sub = form.clk;
		if (sub) {
			n = sub.name;
			if (n && !sub.disabled) {
				s.extraData = s.extraData || {};
				s.extraData[n] = sub.value;
				if (sub.type == "image") {
					s.extraData[n+'.x'] = form.clk_x;
					s.extraData[n+'.y'] = form.clk_y;
				}
			}
		}
		
		var CLIENT_TIMEOUT_ABORT = 1;
		var SERVER_ABORT = 2;

		function getDoc(frame) {
			var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
			return doc;
		}
		
		// Rails CSRF hack (thanks to Yvan Barthelemy)
		var csrf_token = $('meta[name=csrf-token]').attr('content');
		var csrf_param = $('meta[name=csrf-param]').attr('content');
		if (csrf_param && csrf_token) {
			s.extraData = s.extraData || {};
			s.extraData[csrf_param] = csrf_token;
		}

		// take a breath so that pending repaints get some cpu time before the upload starts
		function doSubmit() {
			// make sure form attrs are set
			var t = $form.attr('target'), a = $form.attr('action');

			// update form attrs in IE friendly way
			form.setAttribute('target',id);
			if (!method) {
				form.setAttribute('method', 'POST');
			}
			if (a != s.url) {
				form.setAttribute('action', s.url);
			}

			// ie borks in some cases when setting encoding
			if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
				$form.attr({
					encoding: 'multipart/form-data',
					enctype:  'multipart/form-data'
				});
			}

			// support timout
			if (s.timeout) {
				timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
			}
			
			// look for server aborts
			function checkState() {
				try {
					var state = getDoc(io).readyState;
					log('state = ' + state);
					if (state.toLowerCase() == 'uninitialized')
						setTimeout(checkState,50);
				}
				catch(e) {
					log('Server abort: ' , e, ' (', e.name, ')');
					cb(SERVER_ABORT);
					timeoutHandle && clearTimeout(timeoutHandle);
					timeoutHandle = undefined;
				}
			}

			// add "extra" data to form if provided in options
			var extraInputs = [];
			try {
				if (s.extraData) {
					for (var n in s.extraData) {
						extraInputs.push(
							$('<input type="hidden" name="'+n+'">').attr('value',s.extraData[n])
								.appendTo(form)[0]);
					}
				}

				if (!s.iframeTarget) {
					// add iframe to doc and submit the form
					$io.appendTo('body');
					io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
				}
				setTimeout(checkState,15);
				form.submit();
			}
			finally {
				// reset attrs and remove "extra" input elements
				form.setAttribute('action',a);
				if(t) {
					form.setAttribute('target', t);
				} else {
					$form.removeAttr('target');
				}
				$(extraInputs).remove();
			}
		}

		if (s.forceSync) {
			doSubmit();
		}
		else {
			setTimeout(doSubmit, 10); // this lets dom updates render
		}

		var data, doc, domCheckCount = 50, callbackProcessed;

		function cb(e) {
			if (xhr.aborted || callbackProcessed) {
				return;
			}
			try {
				doc = getDoc(io);
			}
			catch(ex) {
				log('cannot access response document: ', ex);
				e = SERVER_ABORT;
			}
			if (e === CLIENT_TIMEOUT_ABORT && xhr) {
				xhr.abort('timeout');
				return;
			}
			else if (e == SERVER_ABORT && xhr) {
				xhr.abort('server abort');
				return;
			}

			if (!doc || doc.location.href == s.iframeSrc) {
				// response not received yet
				if (!timedOut)
					return;
			}
			io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

			var status = 'success', errMsg;
			try {
				if (timedOut) {
					throw 'timeout';
				}

				var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
				log('isXml='+isXml);
				if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
					if (--domCheckCount) {
						// in some browsers (Opera) the iframe DOM is not always traversable when
						// the onload callback fires, so we loop a bit to accommodate
						log('requeing onLoad callback, DOM not available');
						setTimeout(cb, 250);
						return;
					}
					// let this fall through because server response could be an empty document
					//log('Could not access iframe DOM after mutiple tries.');
					//throw 'DOMException: not available';
				}

				//log('response detected');
				var docRoot = doc.body ? doc.body : doc.documentElement;
				xhr.responseText = docRoot ? docRoot.innerHTML : null;
				xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
				if (isXml)
					s.dataType = 'xml';
				xhr.getResponseHeader = function(header){
					var headers = {'content-type': s.dataType};
					return headers[header];
				};
				// support for XHR 'status' & 'statusText' emulation :
				if (docRoot) {
					xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
					xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
				}

				var dt = (s.dataType || '').toLowerCase();
				var scr = /(json|script|text)/.test(dt);
				if (scr || s.textarea) {
					// see if user embedded response in textarea
					var ta = doc.getElementsByTagName('textarea')[0];
					if (ta) {
						xhr.responseText = ta.value;
						// support for XHR 'status' & 'statusText' emulation :
						xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
						xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
					}
					else if (scr) {
						// account for browsers injecting pre around json response
						var pre = doc.getElementsByTagName('pre')[0];
						var b = doc.getElementsByTagName('body')[0];
						if (pre) {
							xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
						}
						else if (b) {
							xhr.responseText = b.textContent ? b.textContent : b.innerText;
						}
					}
				}
				else if (dt == 'xml' && !xhr.responseXML && xhr.responseText != null) {
					xhr.responseXML = toXml(xhr.responseText);
				}

				try {
					data = httpData(xhr, dt, s);
				}
				catch (e) {
					status = 'parsererror';
					xhr.error = errMsg = (e || status);
				}
			}
			catch (e) {
				log('error caught: ',e);
				status = 'error';
				xhr.error = errMsg = (e || status);
			}

			if (xhr.aborted) {
				log('upload aborted');
				status = null;
			}

			if (xhr.status) { // we've set xhr.status
				status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
			}

			// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
			if (status === 'success') {
				s.success && s.success.call(s.context, data, 'success', xhr);
				g && $.event.trigger("ajaxSuccess", [xhr, s]);
			}
			else if (status) {
				if (errMsg == undefined)
					errMsg = xhr.statusText;
				s.error && s.error.call(s.context, xhr, status, errMsg);
				g && $.event.trigger("ajaxError", [xhr, s, errMsg]);
			}

			g && $.event.trigger("ajaxComplete", [xhr, s]);

			if (g && ! --$.active) {
				$.event.trigger("ajaxStop");
			}

			s.complete && s.complete.call(s.context, xhr, status);

			callbackProcessed = true;
			if (s.timeout)
				clearTimeout(timeoutHandle);

			// clean up
			setTimeout(function() {
				if (!s.iframeTarget)
					$io.remove();
				xhr.responseXML = null;
			}, 100);
		}

		var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
			if (window.ActiveXObject) {
				doc = new ActiveXObject('Microsoft.XMLDOM');
				doc.async = 'false';
				doc.loadXML(s);
			}
			else {
				doc = (new DOMParser()).parseFromString(s, 'text/xml');
			}
			return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
		};
		var parseJSON = $.parseJSON || function(s) {
			return window['eval']('(' + s + ')');
		};

		var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4

			var ct = xhr.getResponseHeader('content-type') || '',
				xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
				data = xml ? xhr.responseXML : xhr.responseText;

			if (xml && data.documentElement.nodeName === 'parsererror') {
				$.error && $.error('parsererror');
			}
			if (s && s.dataFilter) {
				data = s.dataFilter(data, type);
			}
			if (typeof data === 'string') {
				if (type === 'json' || !type && ct.indexOf('json') >= 0) {
					data = parseJSON(data);
				} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
					$.globalEval(data);
				}
			}
			return data;
		};
	}
};

/**
 * ajaxForm() provides a mechanism for fully automating form submission.
 *
 * The advantages of using this method instead of ajaxSubmit() are:
 *
 * 1: This method will include coordinates for <input type="image" /> elements (if the element
 *	is used to submit the form).
 * 2. This method will include the submit element's name/value data (for the element that was
 *	used to submit the form).
 * 3. This method binds the submit() method to the form for you.
 *
 * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
 * passes the options argument along after properly binding events for submit elements and
 * the form itself.
 */
$.fn.ajaxForm = function(options) {
	// in jQuery 1.3+ we can fix mistakes with the ready state
	if (this.length === 0) {
		var o = { s: this.selector, c: this.context };
		if (!$.isReady && o.s) {
			log('DOM not ready, queuing ajaxForm');
			$(function() {
				$(o.s,o.c).ajaxForm(options);
			});
			return this;
		}
		// is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
		log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
		return this;
	}

	return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
		if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
			e.preventDefault();
			$(this).ajaxSubmit(options);
		}
	}).bind('click.form-plugin', function(e) {
		var target = e.target;
		var $el = $(target);
		if (!($el.is(":submit,input:image"))) {
			// is this a child element of the submit el?  (ex: a span within a button)
			var t = $el.closest(':submit');
			if (t.length == 0) {
				return;
			}
			target = t[0];
		}
		var form = this;
		form.clk = target;
		if (target.type == 'image') {
			if (e.offsetX != undefined) {
				form.clk_x = e.offsetX;
				form.clk_y = e.offsetY;
			} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
				var offset = $el.offset();
				form.clk_x = e.pageX - offset.left;
				form.clk_y = e.pageY - offset.top;
			} else {
				form.clk_x = e.pageX - target.offsetLeft;
				form.clk_y = e.pageY - target.offsetTop;
			}
		}
		// clear form vars
		setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
	});
};

// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
	return this.unbind('submit.form-plugin click.form-plugin');
};

/**
 * formToArray() gathers form element data into an array of objects that can
 * be passed to any of the following ajax functions: $.get, $.post, or load.
 * Each object in the array has both a 'name' and 'value' property.  An example of
 * an array for a simple login form might be:
 *
 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * It is this array that is passed to pre-submit callback functions provided to the
 * ajaxSubmit() and ajaxForm() methods.
 */
$.fn.formToArray = function(semantic) {
	var a = [];
	if (this.length === 0) {
		return a;
	}

	var form = this[0];
	var els = semantic ? form.getElementsByTagName('*') : form.elements;
	if (!els) {
		return a;
	}

	var i,j,n,v,el,max,jmax;
	for(i=0, max=els.length; i < max; i++) {
		el = els[i];
		n = el.name;
		if (!n) {
			continue;
		}

		if (semantic && form.clk && el.type == "image") {
			// handle image inputs on the fly when semantic == true
			if(!el.disabled && form.clk == el) {
				a.push({name: n, value: $(el).val(), type: el.type });
				a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
			}
			continue;
		}

		v = $.fieldValue(el, true);
		if (v && v.constructor == Array) {
			for(j=0, jmax=v.length; j < jmax; j++) {
				a.push({name: n, value: v[j]});
			}
		}
		else if (v !== null && typeof v != 'undefined') {
			a.push({name: n, value: v, type: el.type});
		}
	}

	if (!semantic && form.clk) {
		// input type=='image' are not found in elements array! handle it here
		var $input = $(form.clk), input = $input[0];
		n = input.name;
		if (n && !input.disabled && input.type == 'image') {
			a.push({name: n, value: $input.val()});
			a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
		}
	}
	return a;
};

/**
 * Serializes form data into a 'submittable' string. This method will return a string
 * in the format: name1=value1&amp;name2=value2
 */
$.fn.formSerialize = function(semantic) {
	//hand off to jQuery.param for proper encoding
	return $.param(this.formToArray(semantic));
};

/**
 * Serializes all field elements in the jQuery object into a query string.
 * This method will return a string in the format: name1=value1&amp;name2=value2
 */
$.fn.fieldSerialize = function(successful) {
	var a = [];
	this.each(function() {
		var n = this.name;
		if (!n) {
			return;
		}
		var v = $.fieldValue(this, successful);
		if (v && v.constructor == Array) {
			for (var i=0,max=v.length; i < max; i++) {
				a.push({name: n, value: v[i]});
			}
		}
		else if (v !== null && typeof v != 'undefined') {
			a.push({name: this.name, value: v});
		}
	});
	//hand off to jQuery.param for proper encoding
	return $.param(a);
};

/**
 * Returns the value(s) of the element in the matched set.  For example, consider the following form:
 *
 *  <form><fieldset>
 *	  <input name="A" type="text" />
 *	  <input name="A" type="text" />
 *	  <input name="B" type="checkbox" value="B1" />
 *	  <input name="B" type="checkbox" value="B2"/>
 *	  <input name="C" type="radio" value="C1" />
 *	  <input name="C" type="radio" value="C2" />
 *  </fieldset></form>
 *
 *  var v = $(':text').fieldValue();
 *  // if no values are entered into the text inputs
 *  v == ['','']
 *  // if values entered into the text inputs are 'foo' and 'bar'
 *  v == ['foo','bar']
 *
 *  var v = $(':checkbox').fieldValue();
 *  // if neither checkbox is checked
 *  v === undefined
 *  // if both checkboxes are checked
 *  v == ['B1', 'B2']
 *
 *  var v = $(':radio').fieldValue();
 *  // if neither radio is checked
 *  v === undefined
 *  // if first radio is checked
 *  v == ['C1']
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If this value is false the value(s)
 * for each element is returned.
 *
 * Note: This method *always* returns an array.  If no valid value can be determined the
 *	array will be empty, otherwise it will contain one or more values.
 */
$.fn.fieldValue = function(successful) {
	for (var val=[], i=0, max=this.length; i < max; i++) {
		var el = this[i];
		var v = $.fieldValue(el, successful);
		if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
			continue;
		}
		v.constructor == Array ? $.merge(val, v) : val.push(v);
	}
	return val;
};

/**
 * Returns the value of the field element.
 */
$.fieldValue = function(el, successful) {
	var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
	if (successful === undefined) {
		successful = true;
	}

	if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
		(t == 'checkbox' || t == 'radio') && !el.checked ||
		(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
		tag == 'select' && el.selectedIndex == -1)) {
			return null;
	}

	if (tag == 'select') {
		var index = el.selectedIndex;
		if (index < 0) {
			return null;
		}
		var a = [], ops = el.options;
		var one = (t == 'select-one');
		var max = (one ? index+1 : ops.length);
		for(var i=(one ? index : 0); i < max; i++) {
			var op = ops[i];
			if (op.selected) {
				var v = op.value;
				if (!v) { // extra pain for IE...
					v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
				}
				if (one) {
					return v;
				}
				a.push(v);
			}
		}
		return a;
	}
	return $(el).val();
};

/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 */
$.fn.clearForm = function(includeHidden) {
	return this.each(function() {
		$('input,select,textarea', this).clearFields(includeHidden);
	});
};

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
	var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
	return this.each(function() {
		var t = this.type, tag = this.tagName.toLowerCase();
		if (re.test(t) || tag == 'textarea' || (includeHidden && /hidden/.test(t)) ) {
			this.value = '';
		}
		else if (t == 'checkbox' || t == 'radio') {
			this.checked = false;
		}
		else if (tag == 'select') {
			this.selectedIndex = -1;
		}
	});
};

/**
 * Resets the form data.  Causes all form elements to be reset to their original value.
 */
$.fn.resetForm = function() {
	return this.each(function() {
		// guard against an input with the name of 'reset'
		// note that IE reports the reset function as an 'object'
		if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
			this.reset();
		}
	});
};

/**
 * Enables or disables any matching elements.
 */
$.fn.enable = function(b) {
	if (b === undefined) {
		b = true;
	}
	return this.each(function() {
		this.disabled = !b;
	});
};

/**
 * Checks/unchecks any matching checkboxes or radio buttons and
 * selects/deselects and matching option elements.
 */
$.fn.selected = function(select) {
	if (select === undefined) {
		select = true;
	}
	return this.each(function() {
		var t = this.type;
		if (t == 'checkbox' || t == 'radio') {
			this.checked = select;
		}
		else if (this.tagName.toLowerCase() == 'option') {
			var $sel = $(this).parent('select');
			if (select && $sel[0] && $sel[0].type == 'select-one') {
				// deselect all other options
				$sel.find('option').selected(false);
			}
			this.selected = select;
		}
	});
};

// expose debug var
$.fn.ajaxSubmit.debug = false;

// helper fn for console logging
function log() {
	if (!$.fn.ajaxSubmit.debug) 
		return;
	var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
	if (window.console && window.console.log) {
		window.console.log(msg);
	}
	else if (window.opera && window.opera.postError) {
		window.opera.postError(msg);
	}
};

})(jQuery);

;(function($) {

	$(function() {
		try {
			if (typeof _wpcf7 == 'undefined' || _wpcf7 === null)
				_wpcf7 = {};

			_wpcf7 = $.extend({ cached: 0 }, _wpcf7);

			$('div.wpcf7 > form').ajaxForm({
				beforeSubmit: function(formData, jqForm, options) {
					jqForm.wpcf7ClearResponseOutput();
					jqForm.find('img.ajax-loader').css({ visibility: 'visible' });
					return true;
				},
				beforeSerialize: function(jqForm, options) {
					jqForm.find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) {
						$(n).val('');
					});
					return true;
				},
				data: { '_wpcf7_is_ajax_call': 1 },
				dataType: 'json',
				success: function(data) {
					var ro = $(data.into).find('div.wpcf7-response-output');
					$(data.into).wpcf7ClearResponseOutput();

					if (data.invalids) {
						$.each(data.invalids, function(i, n) {
							$(data.into).find(n.into).wpcf7NotValidTip(n.message);
							$(data.into).find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid');
						});
						ro.addClass('wpcf7-validation-errors');
					}

					if (data.captcha)
						$(data.into).wpcf7RefillCaptcha(data.captcha);

					if (data.quiz)
						$(data.into).wpcf7RefillQuiz(data.quiz);

					if (1 == data.spam)
						ro.addClass('wpcf7-spam-blocked');

					if (1 == data.mailSent) {
						ro.addClass('wpcf7-mail-sent-ok');

						if (data.onSentOk)
							$.each(data.onSentOk, function(i, n) { eval(n) });
					} else {
						ro.addClass('wpcf7-mail-sent-ng');
					}

					if (data.onSubmit)
						$.each(data.onSubmit, function(i, n) { eval(n) });

					if (1 == data.mailSent)
						$(data.into).find('form').resetForm().clearForm();

					$(data.into).find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) {
						$(n).val($(n).attr('title'));
					});

					$(data.into).wpcf7FillResponseOutput(data.message);
				}
			});

			$('div.wpcf7 > form').each(function(i, n) {
				if (_wpcf7.cached)
					$(n).wpcf7OnloadRefill();

				$(n).wpcf7ToggleSubmit();

				$(n).find('.wpcf7-submit').wpcf7AjaxLoader();

				$(n).find('.wpcf7-acceptance').click(function() {
					$(n).wpcf7ToggleSubmit();
				});

				$(n).find('.wpcf7-exclusive-checkbox').each(function(i, n) {
					$(n).find('input:checkbox').click(function() {
						$(n).find('input:checkbox').not(this).removeAttr('checked');
					});
				});

				$(n).find('.wpcf7-use-title-as-watermark').each(function(i, n) {
					var input = $(n);
					input.val(input.attr('title'));
					input.addClass('watermark');

					input.focus(function() {
						if ($(this).hasClass('watermark'))
							$(this).val('').removeClass('watermark');
					});

					input.blur(function() {
						if ('' == $(this).val())
							$(this).val($(this).attr('title')).addClass('watermark');
					});
				});
			});

		} catch (e) {
		}
	});

	$.fn.wpcf7AjaxLoader = function() {
		return this.each(function() {
			var loader = $('<img class="ajax-loader" />')
				.attr({ src: _wpcf7.loaderUrl, alt: _wpcf7.sending })
				.css('visibility', 'hidden');

			$(this).after(loader);
		});
	};

	$.fn.wpcf7ToggleSubmit = function() {
		return this.each(function() {
			var form = $(this);
			if (this.tagName.toLowerCase() != 'form')
				form = $(this).find('form').first();

			if (form.hasClass('wpcf7-acceptance-as-validation'))
				return;

			var submit = form.find('input:submit');
			if (! submit.length) return;

			var acceptances = form.find('input:checkbox.wpcf7-acceptance');
			if (! acceptances.length) return;

			submit.removeAttr('disabled');
			acceptances.each(function(i, n) {
				n = $(n);
				if (n.hasClass('wpcf7-invert') && n.is(':checked')
				|| ! n.hasClass('wpcf7-invert') && ! n.is(':checked'))
					submit.attr('disabled', 'disabled');
			});
		});
	};

	$.fn.wpcf7NotValidTip = function(message) {
		return this.each(function() {
			var into = $(this);
			into.append('<span class="wpcf7-not-valid-tip">' + message + '</span>');
			$('span.wpcf7-not-valid-tip').mouseover(function() {
				$(this).fadeOut('fast');
			});
			into.find(':input').mouseover(function() {
				into.find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast');
			});
			into.find(':input').focus(function() {
				into.find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast');
			});
		});
	};

	$.fn.wpcf7OnloadRefill = function() {
		return this.each(function() {
			var url = $(this).attr('action');
			if (0 < url.indexOf('#'))
				url = url.substr(0, url.indexOf('#'));

			var id = $(this).find('input[name="_wpcf7"]').val();
			var unitTag = $(this).find('input[name="_wpcf7_unit_tag"]').val();

			$.getJSON(url,
				{ _wpcf7_is_ajax_call: 1, _wpcf7: id },
				function(data) {
					if (data && data.captcha)
						$('#' + unitTag).wpcf7RefillCaptcha(data.captcha);

					if (data && data.quiz)
						$('#' + unitTag).wpcf7RefillQuiz(data.quiz);
				}
			);
		});
	};

	$.fn.wpcf7RefillCaptcha = function(captcha) {
		return this.each(function() {
			var form = $(this);

			$.each(captcha, function(i, n) {
				form.find(':input[name="' + i + '"]').clearFields();
				form.find('img.wpcf7-captcha-' + i).attr('src', n);
				var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n);
				form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]);
			});
		});
	};

	$.fn.wpcf7RefillQuiz = function(quiz) {
		return this.each(function() {
			var form = $(this);

			$.each(quiz, function(i, n) {
				form.find(':input[name="' + i + '"]').clearFields();
				form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]);
				form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]);
			});
		});
	};

	$.fn.wpcf7ClearResponseOutput = function() {
		return this.each(function() {
			$(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked');
			$(this).find('span.wpcf7-not-valid-tip').remove();
			$(this).find('img.ajax-loader').css({ visibility: 'hidden' });
		});
	};

	$.fn.wpcf7FillResponseOutput = function(message) {
		return this.each(function() {
			$(this).find('div.wpcf7-response-output').append(message).slideDown('fast');
		});
	};

})(jQuery);
