function getSubmit( selectedtype )
{
  //document.supportform.supporttype.value = selectedtype ;
  document.supportform.submit(); 
}
function drop( div_id )
{
	divobj = document.getElementById( div_id );
	background = document.getElementById( 'drop_background' );
	var w = divobj.offsetWidth/2;
	divobj.style.left = 0 + "px";
  
	
	divobj.style.top = get_height_scroll() + (window_height() - window_height()) + "px";
	divobj.style.marginLeft = window_width()/2 - w + "px";
	divobj.style.marginTop = 0 + "px";
	background.style.height = parseInt( get_height_scroll()) + parseInt( window_height()) +'px';
	background.style.visibility = "visible";
	divobj.style.visibility = "visible";
}
function close( div_id )
{
divobj = document.getElementById( div_id );
background = document.getElementById( 'drop_background' );
divobj.style.visibility = "hidden";
background.style.visibility = "hidden";
}
function get_height_scroll(){
  scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}
function get_width_scroll() {
  var scrOfX = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}
function window_height() {
	var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
	return myHeight;
}
function window_width() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}
function place_t(targetID, table, column, toolbar, hash){
	var value = document.getElementById('contents_'+hash).innerHTML;
	place(targetID, table, column, value, toolbar, hash);
}
function place(targetID, table, column, value, toolbar, hash){
	
	//clearFlashContent();
	var left = 0;
	var top = 0;

	var element = document.getElementById(hash);
	left += findPosX(element);
	top += findPosY(element);

	
	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
		left += document.body.leftMargin;
		top += document.body.topMargin;
	}
	
	var scroll = parseInt( get_height_scroll()) + parseInt( window_height());
	if(scroll < top)top = top-scroll;
	
	if(isObject("flashContent")){
	//replace object/element with a new div
		replaceSwfWithEmptyDiv("flashContent");
	}
		
	var edit = document.getElementById("edytor");
	var textarea = document.getElementById("edytor_input");
	textarea.value = value;
	createFCK(toolbar);
	edit.style.top = 13+top +"px";
	edit.style.left = ((screen.width -900) / 2) + "px";
	edit.style.visibility = "visible";
	document.edit_form.action = 'http://www.medandlife.com/admin/cms/save/'+table+'/'+column+'/'+ targetID;
}

function hide_all(id){
	var edit = document.getElementById(id);
	edit.style.visibility = "hidden";
}

function findPosX(obj) {
	var curleft = 0;
	if(obj.offsetParent)
	while(1)
	{
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.x)
	curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
	while(1)
	{
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
	curtop += obj.y;
	return curtop;
}


function isObject(targetID){

	var isFound = false;
	var el = document.getElementById(targetID);
	
	if(el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")){
	
		isFound = true;
	
	}
	
	return isFound;

}


function replaceSwfWithEmptyDiv(targetID){

	var el = document.getElementById(targetID);
	
	if(el){
	
		var div = document.createElement("div");
	
		el.parentNode.insertBefore(div, el);
	
		//Remove the SWF
		swfobject.removeSWF(targetID);
	
		//Give the new DIV the old element's ID
		div.setAttribute("id", targetID);
		
	}

}
var y1 = 250;   // change the # on the left to adjuct the Y co-ordinate
(document.getElementById) ? dom = true : dom = false;

function hideIt() {
  if (dom) {document.getElementById("fly_menu").style.visibility='hidden';}
}

function showIt() {
  if (dom) {document.getElementById("fly_menu").style.visibility='visible';}
}

function placeIt() {
  if (dom && !document.all) {
	document.getElementById("fly_menu").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1)) + "px";
	document.getElementById("fly_menu2").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight)) + "px";
        document.getElementById("fly_menu3").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight-100)) + "px";
	document.getElementById("drop_background").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight)) + "px";
  }
  if (document.all) {
	document.all["fly_menu"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight-y1)) + "px";
	document.all["fly_menu2"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight)) + "px";
        document.all["fly_menu3"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight-100)) + "px";

	document.all["drop_background"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight)) + "px";
  }
  window.setTimeout("placeIt()", 25); }



	function showNews(news_id, pokaz, ukryj) {
        var box = 'newsContent' + news_id;
        var arrow = 'answerBtn' + news_id;		
		
        var newsObj = document.getElementById(box);
        var arrowObj = document.getElementById(arrow);		
        var disp = newsObj.style.display;

        if (disp == 'block') {
			var new_disp = 'none';
			var new_arrow = pokaz;
        } else {
			var new_disp = 'block';
			var new_arrow = ukryj;
        }

        newsObj.style.display = new_disp;
        arrowObj.innerHTML = new_arrow;		
	}
	
	function showElement(elementId) {
		var elemObj = document.getElementById(elementId);
		var disp = elemObj.style.display;
		
        if (disp == 'block') {
			elemObj.style.display = 'none';
        } else {
			elemObj.style.display = 'block';
        }		
	}
	
	function get_position(){
			var top_position = document.documentElement.scrollTop;
			$.cookie('pos', top_position);
	};
	function set_position(){
			var top_position = $.cookie('pos');
			window.scrollTo(0,top_position)
			$.cookie('pos', null);
	};
	function up(id, table){
		location.href='http://www.medandlife.com/admin/cms/up/'+table+'/'+id;
	}
	function down(id, table){
		location.href='http://www.medandlife.com/admin/cms/down/'+table+'/'+id;
	}
	function show(id, table){
		location.href='http://www.medandlife.com/admin/cms/show/'+table+'/'+id;
	}
	function hide(id, table){
		location.href='http://www.medandlife.com/admin/cms/hide/'+table+'/'+id;
	}
	function add(id, table){
		location.href='http://www.medandlife.com/admin/cms/add/'+table+'/'+id;
	}	
	function del(id, table){
		location.href='http://www.medandlife.com/admin/cms/delete/'+table+'/'+id;
	}	