var biturl = '';

$(document).ready(function() {

	/*
	 * Highlighting Search
	 */
	
	var searchHintText = "Suchbegriff eingeben";
	
	$("#searchString").val(searchHintText).addClass("searchHint");
	
	$("#searchString").unload(function() {
		$(this).val(searchHintText).addClass("searchHint");
	});
	
	$("#searchString").focus(function() {
		if ($(this).val() == searchHintText) {		
			$(this).removeClass("searchHint").addClass("searchFocus");
			$(this).val("");
		} else {
			$(this).addClass("searchFocus");
		}
	});
	
	$("#searchString").change(function() {
		if ($(this).val() == "") {
			$(this).removeClass("searchFocus").addClass("searchHint");
			$(this).val(searchHintText);		
		} else if ($(this).val() == searchHintText) {
			$(this).removeClass("searchFocus").addClass("searchHint");
		} else {
			$(this).removeClass("searchHint");
		}
	});
	
	$("#searchString").blur(function(){
		if ($(this).val() == "") {
			$(this).removeClass("searchFocus").addClass("searchHint");
			$(this).val(searchHintText);
		} else if ($(this).val() == searchHintText) {
			$(this).removeClass("searchFocus").addClass("searchHint");	
		} else {
			$(this).removeClass("searchHint").removeClass("searchFocus");
		}
	});
	
	/*
	 * Activate Tabs
	 */
	
	$("#boxA").tabs();
	$("#boxB").tabs();
	
	/*
	 * Enable Twitter sharing with bit.ly-shortened URI
	 */
	
	//var siteUrl = encodeURI(document.location.href);
	var siteUrl = 'http://www.cnx.de/';
	var reqUrl = 'http://api.bit.ly/shorten?login=colognetworx&apiKey=R_9fd44f6e6e8be1fa12a241506ec161d4&longUrl=' + siteUrl + '&format=json&version=2.0.1&callback=?';
	$.getJSON(reqUrl, function(data) {
		if (data.statusCode == "OK") {
			biturl = data.results[siteUrl].shortUrl;
		}
	});
	if (biturl == '') {
		biturl = window.location.href;
	}
	
	twttr.anywhere(function(twitter) {
		$("#twitterAnywhere").click(function(event) {
			event.preventDefault();
			twitter("#twitterAnywhereBox").tweetBox({
				width: 660,
				label: "Twittern Sie über diesen Artikel:",
				defaultContent: biturl
			});
		});
	});
});
	
	/*
	 * Place Banners using swfobject
	 */
	
	function addSWFContent(file, id, width, height, vars) {
		var flashvars = vars;
		var params = {};
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = id;
		swfobject.embedSWF(file, id, width, height, "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
	}
	
	addSWFContent("swf/VF_360_M1_Soho_Maps_WP_728x90_0212.swf", "banner_b", 728, 90, {});
	addSWFContent("swf/VF_360_M1_Soho_Maps_WP_160x600_0212.swf", "banner_a", 160, 600, {});
	
	
	
	

