// Makes sure the three main divs are the same height.
function adaptMainDivs()
{
    var leftDiv		   = document.getElementById('leftareadiv');
    var mainDiv		   = document.getElementById('mainareadiv');
    var rightDiv	   = document.getElementById('rightareadiv');
    var rightBorderDiv = document.getElementById('rightareaborderdiv');
    var mainandleftdiv = document.getElementById('mainandleftdiv');
    var pagemaindiv	   = document.getElementById('pagemaindiv'); 
    var rightShadowDiv = document.getElementById('PageShadowRight');
//    var leftShadowDiv  = xGetElementById('PageShadowLeft');	   

    // min-height
    var height = 400;
       
    // find the highest div
    if (leftDiv) leftDiv.style.height = 'auto';
    if (leftDiv  && leftDiv.clientHeight  > height) height = leftDiv.clientHeight;
    if (mainDiv) mainDiv.style.height = 'auto';
    if (mainDiv  && mainDiv.clientHeight  > height) height = mainDiv.clientHeight;
    if (rightDiv) rightDiv.style.height = 'auto';
    if (rightDiv && rightDiv.clientHeight > height)	height = rightDiv.clientHeight;
    if (mainandleftdiv) mainandleftdiv.style.height = 'auto';
    if (mainandleftdiv && mainandleftdiv.clientHeight > height) height = mainandleftdiv.clientHeight;
    if (rightBorderDiv) rightBorderDiv.style.height = 'auto';
    if (rightBorderDiv && rightBorderDiv.clientHeight > height) height = rightBorderDiv.clientHeight;

    // set new height
    if (leftDiv)  leftDiv.style.height  = height + 'px';
    if (mainDiv)  mainDiv.style.height  = height + 'px';
    if (rightDiv) rightDiv.style.height = height + 'px';
    if (mainandleftdiv) mainandleftdiv.style.height = height + 'px';
    if (rightBorderDiv) rightBorderDiv.style.height = height + 'px';
    
    //new code to set shadow height
//    rightShadowDiv.style.height =   pagemaindiv.clientHeight;
//    leftShadowDiv.style.height =   pagemaindiv.clientHeight;
}


// This function will fire a click event on the specified control when the 
// enter key is pressed in a text field. Attach this function to the 
// onkeypressed-event on the text field.
function fireClickOnEnter(evt, controlId)
{
    var control = document.getElementById(controlId);
    var keyCode = (typeof window.event == 'object') ? window.event.keyCode : evt.keyCode;

    // If enter is pressed -> fire click-event on the control
    if (control && (keyCode == 13))
    {
        control.focus();
        control.click();
        return false;
    }
    else
    {
        return true;
    }
}

function adaptDivsExpand()
{
    var leftDiv		   = document.getElementById('leftareadiv');
    var mainDiv		   = document.getElementById('mainareadiv');
    var rightDiv	   = document.getElementById('rightareadiv');
    var mainandleftdiv = document.getElementById('mainandleftdiv');

    // min-height
    var height = 400;
    mainDiv.style.height = 'auto';
    mainandleftdiv.style.height = 'auto';
    // find the highest div
    if (leftDiv  && leftDiv.clientHeight  > height) height = leftDiv.clientHeight;
    if (mainDiv  && mainDiv.clientHeight  > height) height = mainDiv.clientHeight;
    if (rightDiv && rightDiv.clientHeight > height)	height = rightDiv.clientHeight;
    if (mainandleftdiv && mainandleftdiv.clientHeight > height) height = mainandleftdiv.clientHeight;

    // set new height
    if (leftDiv)  leftDiv.style.height  = height + 'px';
    if (mainDiv)  mainDiv.style.height  = height + 'px';
    if (rightDiv) rightDiv.style.height = height + 'px';
    if (mainandleftdiv) mainandleftdiv.style.height = height + 'px';
}

// Open print office window
function PrintPage(url)
{

		if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		html += '<LINK rel="stylesheet" type="text/css" href="http://www.socialdemokraterna.se/styles/main.css">';
		
		html += '\n</HE' + 'AD>\n<BO' + 'DY class="printCopy" bgcolor="#ffffff" style="BACKGROUND-COLOR: #ffffff; background-image: "";">\n';
		
		html += '<div align="center" style="BACKGROUND-COLOR: #ffffff"><table cellspacing="0" width="580px"><tr>';
		html += '<td><img src="http://www.socialdemokraterna.se/images/sociald_grey.gif" /></td>';
		html += '<td valign="bottom" align="right" style="font-weight: bold; font-size: 10px; font-family: Tahoma, Verdana, Arial, \'Trebuchet MS\'; padding-bottom: 5px;">';
		html += 'En utskrift från socialdemokraterna.se';
		html += '</td></tr><tr><td colspan="2"><hr noshade size="2" color="black" width="580px" /></td></tr><tr valign="top"><td colspan="2">';
		html += '<div id="mainareadiv">';
		
		
		var printReadyElem = document.getElementById("mainareadiv");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
		
		html += '</div></div></td></tr><tr><td colspan="2"><hr noshade size="2" color="black" width="580px" /></td></tr>';
		html += '<tr><td colspan="2" style="font-weight: bold; font-size: 10px; font-family: Tahoma, Verdana, Arial, \'Trebuchet MS\'; padding-bottom: 5px;">';
		html += '<center>© Detta material är skyddat enligt lagen om upphovsrätt.</center></td></tr></table></div>';
			
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';		
		

		var printWin = window.open('', 'printSpecial', 'width=666,height=614,location=no,scrollbars=yes,menubar=yes,toolbar=no,resizable=no,status=yes');
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
//		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
	
}
function TipPage(url)
{
    w = window.open(url, 'PrintOfficeWindow', 'width=340,height=420,location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=no,status=yes');
    w.focus();
}
// Open window for viewing all pictures
function openSecureWindow(url)
{
    w = window.open(url, 'SecureWindow', 'width=950,height=800,location=yes,scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes,status=yes,');
    w.focus();
}
function CreateFlash(menuflash,flashvars, width, height)
{
  var d = document.getElementById('flashdiv');
  d.innerHTML = 
		'<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ 'WIDTH="' + width + '" HEIGHT="' + height + '"'
		+ 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"'
		+ 'VIEWASTEXT title="">'
		+ '<PARAM NAME="MOVIE" VALUE="' + menuflash + '"'
		+ '<PARAM NAME="QUALITY" VALUE="high">'
		+ '<PARAM NAME="FLASHVARS" VALUE="' + flashvars + '">'
		+ '<EMBED SRC="' + menuflash + '"'
		+ 'WIDTH="' + width + '" HEIGHT="' + height + '"'
		+ 'QUALITY="high"'
		+ 'TYPE="application/x-shockwave-flash"'
		+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"'
		+ ' FLASHVARS="' + flashvars + '"'
		+ '</EMBED>'
		+ '</OBJECT>'
}