var divelem;
function copy2clipboard(elem,pathtoswf) {
  //alert(elem.firstChild.nodeValue);
  text2copy = elem.firstChild.nodeValue;
  divelem =  elem;
  markedSelectTextArea();
  setTimeout("unmarkedSelectTextArea()",5000);
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="'+pathtoswf+'/_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}
function copy2clipboardWidth(elem,pathtoswf,width) {
  //alert(elem.firstChild.nodeValue);
  if(width<120){
  	alert("Min. 120px!");
  }
  text2copy = '<div style="width:' + width + 'px">'+ elem.firstChild.nodeValue + '</div>';
  divelem =  elem;
  markedSelectTextArea();
  setTimeout("unmarkedSelectTextArea()",5000);
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';


    var divinfo = '<embed src="'+pathtoswf+'/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}

function copy2clipboardUserBoxWidth(elem,pathtoswf,width) {
  //alert(elem.firstChild.nodeValue);
  if(width<120){
  	alert("Min. 120px!");
  }
  var textarea = elem.firstChild.nodeValue;  
  
  textarea = textarea.replace('&mapwidth=','&mapwidth='+width);  
  textarea = textarea.replace('scrolling=\"no\" style="padding: 4px 0px 0px 0px;  width:','scrolling=\"no\" style="padding: 4px 0px 0px 0px; width:'+width);
  
  text2copy = '<div style="width:' + width + 'px">'+ textarea + '</div>';
  divelem =  elem;
  markedSelectTextArea();
  setTimeout("unmarkedSelectTextArea()",5000);
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="'+pathtoswf+'/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}



function markedSelectTextArea(){
 divelem.style.backgroundColor = "#6BAFFF";
}
function unmarkedSelectTextArea(){
 divelem.style.backgroundColor = "#FFF";
}


function changeBobsLanguage(input) {
	var redirectUrl = input.options[input.selectedIndex].value;
	var queryKeys = parseUri(window.location.search).queryKey;
	for (var k in queryKeys) {
		if (k != 'l') {
			redirectUrl += '&'+k+'='+queryKeys[k];
		}
	}
	window.location = redirectUrl;
}



/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

