// JavaScript Document

// copyright2011 cnx colognetworx gmbh
// loading the real facebook button by click
// written by Sven Jan�en aka morshiba

var useAlert = true;
var alertmsg = "Aus datenschutzrechtlichen Gründen bitte erneut den Button anklicken, wenn Sie einen \"Gefällt mir\"-Link an Facebook senden möchten.";
var fbluri = "http://www.facebook.com/plugins/like.php?href=###uri###&layout=button_count&show_faces=false&width=250&action=like&font&colorscheme=light&height=80";

function addIframeClick(fbluri, frame, msg) {
	document.getElementById(frame).contentWindow.document.body.onclick = function() {
		//var fbluri = "http://www.facebook.com/plugins/like.php?href=" + uri + "&layout=button_count&show_faces=false&width=250&action=like&font&colorscheme=light&height=80";
		//var fbluri = "http://www.facebook.com/plugins/like.php?href=" + uri + "&amp;layout=&amp;show_faces=false&amp;width=150&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80";
		document.getElementById(frame).src = fbluri;
		
		var test = getCookie();
		//alert("test = " + test);
		if ( test != "fblikeshown" && useAlert ) {
			alert(msg);
			setCookie();
		}
	}
}


function getCookie () {
  	var ret = "";
  	if (document.cookie) {
	 	var cut1 = document.cookie.indexOf("fb:") + 3;
    	var cut2 = document.cookie.indexOf(":fb");
		if (cut2 == -1) {
			cut2 = document.cookie.length;
		} 
		var mycookie = document.cookie.substring(cut1, cut2);
		//alert("mycookie = " + mycookie);
		cut1 = mycookie.indexOf("=") + 1;
    	ret = mycookie.substring(cut1, mycookie.length);
  }
  return ret;
}


function setCookie() {
  var jetzt = new Date();
  var verfall = 1000 * 60 * 60 * 12 * 1;
  //verfall = 10000;
  var expire = new Date(jetzt.getTime() + verfall);
  document.cookie = "fb:InfoShown=fblikeshown:fb;expires=" + expire.toGMTString() + ";";
}
