var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-11424420-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();




function emailSecurity(prefix){
	location='mailto:'+prefix+'@ottawaphotos.com'	
}

function sio(image,h,w){
	document.getElementById("blackout").style.display = "block";
	alert(image+","+h+","+w);
}

function stripHTML(oldString) {

   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
   
        if(oldString.charAt(i) == '<') inTag = true;
        if(oldString.charAt(i) == '>') {
              if(oldString.charAt(i+1)=="<")
              {
              		//dont do anything
	}
	else
	{
		inTag = false;
		i++;
	}
        }
   
        if(!inTag) newString += oldString.charAt(i);

   }

   return newString;
}

function updateUserBox(){	
	
	document.getElementById('author').value = '';
	document.getElementById('url').value = '';
	document.getElementById('email').value = '';
	document.getElementById("comment-user-details").style.display = 'none';	
	document.getElementById("fbConnectInfo").innerHTML = "<span style=\"color: #333333;\">"+"<fb:profile-pic uid='loggedinuser' facebook-logo='true' size='small' style='float: left; margin-right: 10px;'></fb:profile-pic>"+"<br>You are signed in with your Facebook account. Welcome, <strong><fb:name uid='loggedinuser' useyou='false' linked='false'></sfb:name></strong>"+"</span>";
	document.getElementById("fbauthor").innerHTML = "<fb:name uid='loggedinuser' useyou='false'></sfb:name>";

	FB.XFBML.Host.parseDomTree();
	
	setTimeout('blah()',1000);


}

function blah(){
	document.getElementById("author").value = document.getElementById("fbauthor").innerHTML
	temp = document.getElementById('author').value;
	profile_id = temp.split('href="')[1]
	profile_url = profile_id.split('">')[0]
	profile_name = profile_id.split('">')[1]
	profile_name = profile_name.split('<')[0]
	
	document.getElementById('author').value = profile_name;
	document.getElementById('url').value = profile_url;
	document.getElementById('email').value = "no-reply@facebook.com";
		
}

function navigationArrow(path){

  $("#nav ul li ul").addClass("push"); // This is line 3
  $("#nav ul li.drop").addClass("enhanced");
  $("#nav ul li.drop").removeClass("drop");
  $("#nav ul li.enhanced span").after(' <img src="' + path + '" />');
  $("#nav ul li.enhanced img").wrap('<a class="arrow rest"></a>');

  $("#nav ul li a.arrow").hover(function(){
    $(this).removeClass("rest").addClass("hover");
  }, function(){
    $(this).removeClass("hover").addClass("rest");
  });
  
  $("#nav ul li a.arrow").click(function(){
    if ($(this).hasClass("hover") == true) {
      $("#nav ul li a.open").removeClass("open").addClass("rest");
      $("#nav ul li ul").hide();
      $(this).removeClass("hover").addClass("open");
      $(this).parent().find("ul").fadeIn();
    } else {
      if ($(this).hasClass("open") == true) {
        $(this).removeClass("open").addClass("hover");
        $(this).parent().find("ul").hide();
      }
    }
  });

  $(document).click(function(event){
    var target = $(event.target);
    if (target.parents("#nav").length == 0) {
      $("#nav ul li a.arrow").removeClass("open").addClass("rest");
      $("#nav ul li ul").hide();
    }
	});

}
