﻿google.load("language", "1");
Cufon.replace('h1');
Cufon.replace(' blockquote');
var $translatetext;

$(document).ready(function(){
	theGB = '<img src="http://stil.problemas.se/bilder/lib/famfamfam_flag_icons/gb.png" alt="english" class="floatRight"/>';
	theNO = '<img src="http://stil.problemas.se/bilder/lib/famfamfam_flag_icons/no.png" alt="norsk" class="floatRight"/>';
	theSE = '<img src="http://stil.problemas.se/bilder/lib/famfamfam_flag_icons/se.png" alt="svenska" class="floatRight"/>';
	var theOrg = $(".body").html()
//	$(".body").prepend(theSE + theGB + theNO)
	$("img[alt='english']").css("cursor","pointer").click(function(){
//		alert("FOO")
		$(".body p").each(function(){
			
			var $this = ($(this))
	//		alert($(this).html())
			google.language.translate($(this).html(), "", "en", function(result) {
				if (result.translation) {
					 $this.html(result.translation);
				}
			});
		
		});
	});
	$("img[alt='norsk']").css("cursor","pointer").click(function(){
//		alert("FOO")
		$(".body p").each(function(){
		
			var $this = ($(this))
	//		alert($(this).html())
			google.language.translate($(this).html(), "", "no", function(result) {
				if (result.translation) {
					 $this.html(result.translation);
				}
			});
		
		});
	});
	$("img[alt='svenska']").css("cursor","pointer").click(function(){
		location.reload(true)		
	});
});
/*    function ChangeContentLanguage(lang) {
        
        var translatedString = ""
        if ($("#translatedText p").length <= 0){
                google.language.translate($("#translatedText").html().toString(), "", lang, function(result) {
                    //alert(result.translation)
                    if (!result.error) {
                        //alert(result.translation)
                        
                        //translatedString += "<p>" + result.translation + "</p>" ;
                        $("#translatedText").html(result.translation)
                    }
                })
        } else {
            $("#translatedText p").each(function(){
                
                google.language.translate($(this).html().toString(), "", lang, function(result) {
                    //alert(result.translation)
                    if (!result.error) {
                        //alert(result.translation)
                        
                        translatedString += "<p>" + result.translation + "</p>" ;
                        $("#translatedText").html(translatedString)
                    }
                })
            });
        }

            google.language.translate(document.getElementById("translationHeader").innerHTML.toString(), "", lang, function(result) {
                if (!result.error) {
                    document.getElementById("translatedHeader").innerHTML = result.translation;
                }
            })
    }
</script>
 */