﻿var ie6 = false;

function closeredframe()
{
	try{
		$("#redBox").remove();
		$("#bodyBGBox").remove();
		
	}
	catch(e)
	{
		return false;
	}
	
	return true;		
}

function openEdit(url)
{

	$("body").append('<div id="bodyBGBox"></div><div id="redBox"><div id="inner_redBox"><div class="CS_close"><span>Stäng</span></div><iframe id="redFrame" src="' + url + '"></iframe></div></div>');
	
	$("#inner_redBox").css(
	{
			width: "980px",
			height:($(window).height() - 80) + "px"
	});
	$("#redBox").css(
	{
			width: $(window).width() + "px",
	 	height:$(window).height() + "px"
	});
	$("#bodyBGBox").css(
	{
			width: $(window).width() + "px",
			height:$(window).height() + "px"
	});
	 if(ie6) 
	 	$("#redBox").css({height: ($(document).height() - 80) + "px"});
	 	 
	 $("#redFrame").css(
	 {
		      width: ($("#inner_redBox").width() - 10) + "px",
		      height: ($("#inner_redBox").height() - 25) + "px"
	 });
	 
 		
	 
	 $("#redBox .CS_close span").click(function(){ 
	 	closeredframe();	
	 });
}

$(document).ready(function(){	
	
     jQuery.each(jQuery.browser, function(i, val) {
  		if(i=="msie" && jQuery.browser.version.substr(0,3)=="6.0")
     			ie6 = true;
     });     
  
    $(".CS_Editlinks a").click(function(){ 
   	var url = $(this).attr("href");
   	openEdit(url);
   	return false;
    });
   
});