/*
CSS Browser Selector v0.4.0 (Nov 02, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

function resizeme(){
	var left_size = document.getElementById("left").offsetHeight;
	var right_size = document.getElementById("right").offsetHeight;

	if(left_size<right_size){
		document.getElementById("left").style.height = right_size+20+"px";
	}
}

function printContents() {
	iWidth = window.screen.width;
	iHeight = window.screen.height;
    wt = 630;
    ht = 460;
    lt = (iWidth - wt) / 2;
    tp = (iHeight - ht) / 2;
    window.open("print.php", '', 'height='+ht+',width='+wt+',top='+tp+',left='+lt+',toolbar=no,resizable=no,scrollbars=yes'); 
}

function printFlash(file, width, height, id, transparency)
{
	if (transparency == true) {

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
					+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
					+ 'width="'+width+'" height="'+height+'" id="'+id+'" align="middle">'
					+ '<param name="allowScriptAccess" value="sameDomain" />'
					+ '<param name="movie" value="'+file+'" />'
					+ '<param name="quality" value="high" />'
					+ '<param name="bgcolor" value="#ffffff" />'
					+ '<param name="wmode" value="transparent" />'
					+ '<embed src="'+file+'" quality="high" bgcolor="#ffffff" wmode="transparent"'
					+ ' width="'+width+'" height="'+height+'" name="'+id+'" align="middle"'
					+ ' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"'
					+ ' pluginspage="http://www.macromedia.com/go/getflashplayer" />'
					+ '</object>');
	}
					
	else {

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
					+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
					+ 'width="'+width+'" height="'+height+'" id="'+id+'" align="middle">'
					+ '<param name="allowScriptAccess" value="sameDomain" />'
					+ '<param name="movie" value="'+file+'" />'
					+ '<param name="quality" value="high" />'
					+ '<param name="bgcolor" value="#ffffff" />'
					+ '<param name="wmode" value="transparent" />'
					+ '<embed src="'+file+'" quality="high" bgcolor="#ffffff"'
					+ ' width="'+width+'" height="'+height+'" name="'+id+'" align="middle"'
					+ ' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"'
					+ ' pluginspage="http://www.macromedia.com/go/getflashplayer" />'
					+ '</object>');
	}				
	
}

function preview(file, desc, width, height) {
 if (desc == null) {
   desc = '';
 }
 var left = (screen.width - width) / 2;
 var top = (screen.height - height + 20) / 2;
 window.open("preview.php?file="+file+"&desc="+desc, "_preview_", "width="+width+",height="+height+",top="+top+",left="+left);
}

var timer = null;

function startTimer() {
    timer = setTimeout('hideLocked()',1000);
}

function hideLocked() {
	var dymek = document.getElementById('dymek');
	dymek.style.visibility = 'hidden';
	clearTimer();
}

function locked(evt) {
	var dymek = document.getElementById('dymek');
	if (evt.pageX) {
		dymek.style.left = evt.pageX - 4 + 'px';
		dymek.style.top = evt.pageY - 4 + 'px';
	} else {
		dymek.style.left = evt.clientX + document.body.scrollLeft - 4 + 'px';
		dymek.style.top = evt.clientY + document.body.scrollTop - 4 + 'px';
	}
	dymek.style.visibility = 'visible';
	clearTimer();
}

function clearTimer() {
	if (timer != null) {
       clearTimeout(timer);
       timer = null;
    }
}

function getWindowHeight() {
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    return window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return document.body.clientHeight;
  }
  return 0;
}
function getWindowWidth() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
//    return window.innerWidth - 20;
    return window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return document.body.clientWidth;
  }
  return 0;
}

function submitBMI() {
	height = document.getElementById('height').value;
	weight = document.getElementById('weight').value;

	var error = 0;
	document.getElementById('weight_err').innerHTML = document.getElementById('height_err').innerHTML = '';
	var err = '';
	var bmi = 0.0;
	var comment = '';
	var objRegExp = /^\d{2,3}$/
	if(!objRegExp.test(weight)) {
		error = 1;
		document.getElementById('weight_err').innerHTML = 'Niepoprawna wartość wagi<br>';
	}
	if(!objRegExp.test(height)) {
		error = 1;
		document.getElementById('height_err').innerHTML = 'Niepoprawna wartość wzrostu<br>';
	}
	if (error == 0) {
		bmi = Math.round(((10000 * weight) / (height * height)) * 10);
		if (bmi < 185) {
			comment = 'niedowaga';
		} else if (bmi < 250) {
			comment = 'prawidłowa masa ciała';
		} else if (bmi < 300) {
			comment = 'nadwaga';
		} else if (bmi < 350) {
			comment = 'I stopień otyłości';
		} else if (bmi < 400) {
			comment = 'II stopień otyłości';
		} else {
			comment = 'III stopień otyłości (ekstremalna)';
		}
		err = "Twój BMI: <span class='bmiscore'>" + (bmi / 10) + "</span> - " + comment;
	}
	document.getElementById('bmiscore').innerHTML = err;
	return false;
}

function submitWHR() {
	var waist = document.getElementById('waist').value;
	var hip = document.getElementById('hip').value;
	var gender = 'none';
	var error = 0;
	document.getElementById('waist_err').innerHTML = document.getElementById('hip_err').innerHTML = '';
	var err = '';
	var objRegExp = /^\d{2,3}$/
  var whr = 0.0;
	var comment = '';

	if (document.getElementById('male').checked) {
		gender = 'male';
	} else if (document.getElementById('female').checked) {
		gender = 'female';
	}

	if(!objRegExp.test(waist)) {
		error = 1;
		document.getElementById('waist_err').innerHTML = 'Niepoprawna wartość obwodu w talii<br>';
	}
	if(!objRegExp.test(hip)) {
		error = 1;
		document.getElementById('hip_err').innerHTML = 'Niepoprawna wartość obwodu w biodrach<br>';
	}
	if (gender == 'none') {
		err = err + 'Nie wybrano płci<br>';
	}
	if (error == 0) {
		whr = waist / hip;
		if (gender == 'male') {
			if (whr < 1.0) {
				comment = 'otyłość udowo-pośladkowa';
			} else {
				comment = 'otyłość wisceralna (brzuszna)';
			}
		} else {
			if (whr < 0.8) {
				comment = 'otyłość udowo-pośladkowa';
			} else {
				comment = 'otyłość wisceralna (brzuszna)';
			}
		}
		err = "Twój WHR: <span class='whrscore'>" + (Math.round(+whr * 100) / 100) + "</span> - " + comment;
	}
	document.getElementById('whrscore').innerHTML = err;
	return false;
}


with (navigator) if (appName.indexOf('Microsoft')!=-1 && appVersion.indexOf('Mac')==-1)
{
	document.write('<scr'+'ipt language="VBScript">\nMM_flash = NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n</scr'+'ipt>');
}

function MM_checkPlugin(plgIn)
{
  	var result = false;

 	if (navigator.appName.indexOf('Microsoft')==-1 || (navigator.plugins && navigator.plugins.length))
  	{
  		result = navigator.plugins[plgIn] != null ? true : false;
  	}
  	else
  	{
  		if (navigator.appName.indexOf('Microsoft')!=-1 && navigator.appVersion.indexOf('Mac')==-1)
		{
			result = MM_flash;
		}
	}
	result = result == true ? true : false;
	return result;  		
}

var flashExists = MM_checkPlugin("Shockwave Flash");


//flashExists = false;
function printTrialBase()
{
	document.write('<div class="tbbaner"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
					  'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'+
					  'WIDTH="400" HEIGHT="100" id="trialbase" ALIGN="">'+
					  '<PARAM NAME=movie VALUE="images/trialbase.swf">'+
					  '<param name="wmode" value="transparent">'+
					  '<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="images/trialbase.swf" wmode="transparent" quality=high bgcolor=#FFFFFF  WIDTH="400" HEIGHT="100" NAME="trialbase" ALIGN=""'+
					  'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></EMBED>'+
					  '</OBJECT></div>');
}
function printMovie(movie, mini, title)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
					+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '
					+ 'width="300" height="258" id="atero_tv" align="middle">'
					+ '<param name="allowScriptAccess" value="sameDomain" />'
					+ '<param name="movie" value="images/player_atero.swf" />'
					+ '<param name="quality" value="high" />'
					+ '<param name="bgcolor" value="#ffffff" />'
					+ '<param name="flashVars" value="film='+movie+'|'+title+'|'+mini+'" />'
					+ '<embed src="images/player_atero.swf" quality="high" bgcolor="#005586"'
					+ ' flashVars="film='+movie+'|'+title+'|'+mini+'"'
					+ ' width="300" height="258" name="atero_tv" align="middle"'
					+ ' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"'
					+ ' pluginspage="http://www.macromedia.com/go/getflashplayer" />'
					+ '</object>');
}



function showNode(nazwa)
{
	element = document.getElementById(nazwa);
 
   if(element.style) {
      if(element.style.display == 'block' ){
         element.style.display = 'none';
      } else {
         element.style.display = 'block';
      }
   }
}

var calc = {
	comment: function() {
		$('#box #mainBox .comment img').click(function(){
			$("#dialog_comment").dialog({ minHeight: 300, minWidth: 800, 
			modal: true,
			position: 'top',
			open: function(event, ui) { 
			$('.ui-widget-overlay').height($(document).height());
			$('.ui-dialog').css('top','10px');
			$(document).scrollTop(0);
			}
});
		}).hover(
			function(){
				$(this).attr('src', 'images/calc/komentarz_on.png');
			},
			function(){
				$(this).attr('src', 'images/calc/komentarz_off.png');
			}
		);		
	},
	score: function() {
		$('#submitScore').click(function(){
			$('#scoreForm').submit();
		}).hover(
			function(){
				$(this).attr('src', 'images/score/oblicz_on.png');
			},
			function(){
				$(this).attr('src', 'images/score/oblicz_off.png');
			}
		);
		$('#clearCalc').click(function(){
			$('#scoreRes').hide();
			$('#scoreBox .score2').hide();
			$('#scoreForm').show();
			$('#scoreBox .score1').show();
			$('#scoreForm #plecK').attr('checked', false);
			$('#scoreForm #plecM').attr('checked', false);
			$('#scoreForm #wiek').getSetSSValue(1);
			$('#scoreForm #skurczowe').getSetSSValue(1);
			$('#scoreForm #cholesterol_mmol').getSetSSValue(1);
			$('#scoreForm #cholesterol_mg').getSetSSValue(1);
			$('#scoreForm #cholesterol_jedn').getSetSSValue(1);
			$('#scoreForm #paliN').attr('checked', false);
			$('#scoreForm #paliT').attr('checked', false);
		}).hover(
				function(){
					$(this).attr('src', 'images/calc/wyczysc_on.png');
				},
				function(){
					$(this).attr('src', 'images/calc/wyczysz_off.png');
				}
			);
		$('#backScore').click(function(){
			$('#scoreBox').removeClass('scoreBack2').addClass('scoreBack1');
			$('#scoreRes').hide();
			$('#scoreBox .score2').hide();
			$('#scoreForm').show();
			$('#scoreBox .score1').show();
			$('#scoreForm #plecK').attr('checked', true);
			$('#scoreForm #wiek').getSetSSValue(1);
			$('#scoreForm #skurczowe').getSetSSValue(1);
			$('#scoreForm #cholesterol_mmol').getSetSSValue(1);
			$('#scoreForm #cholesterol_mg').getSetSSValue(1);
			$('#scoreForm #cholesterol_jedn').getSetSSValue(1);
			$('#scoreForm #paliN').attr('checked', true);
		}).hover(
			function(){
				$(this).attr('src', 'images/score/powrot_on.png');
			},
			function(){
				$(this).attr('src', 'images/score/powrot_off.png');
			}
		);
		$('#cholesterol_jedn').change(function(){
			if ($(this).val() == 'mmol') {
				$('#cholesterol_mg').attr('disabled',true).next().hide();
				$('#cholesterol_mmol').attr('disabled',false).next().show();
				$('#cholesterol_mmol').getSetSSValue($('#cholesterol_mg').getSetSSValue());
			}
			if ($(this).val() == 'mg') {
				$('#cholesterol_mmol').attr('disabled',true).next().hide();
				$('#cholesterol_mg').attr('disabled',false).next().show();
				$('#cholesterol_mg').getSetSSValue($('#cholesterol_mmol').getSetSSValue());
			}
		});
	    var options = { 
			target: '#scoreRes', 
 		    success: function(responseText, statusText, xhr, $form) {
				$('#scoreBox').removeClass('scoreBack1').addClass('scoreBack2');
				$('#scoreBox .score1').hide();
				$('#scoreRes').show();
				$('#scoreBox .score2').show();
			} 
		}; 
		$('#scoreForm').ajaxForm(options);
		$('#scoreForm input:radio').checkbox();
		$('#scoreForm select').sSelect();
		$('#scoreForm #cholesterol_mg').attr('disabled',true).next().hide();
	},
	findrisc: function() {
		$('#submitFindrisc').click(function(){
			$('#findriscForm').submit();
		}).hover(
			function(){
				$(this).attr('src', 'images/findrisc/oblicz_on.png');
			},
			function(){
				$(this).attr('src', 'images/findrisc/oblicz_off.png');
			}
		);
		$('#clearCalc').click(function(){
			$('#findriscRes').hide();
			$('#findriscBox .findrisc2').hide();
			$('#findriscForm').show();
			$('#findriscBox .findrisc1').show();
			$('#findriscForm #plecM').attr('checked', false);
			$('#findriscForm #plecK').attr('checked', false);
			$('#findriscForm #wiek').getSetSSValue(1);
			$('#findriscForm #bmi').getSetSSValue(1);
			$('#findriscForm #obwod_m').getSetSSValue(1);
			$('#findriscForm #obwod_k').getSetSSValue(1);
			$('#findriscForm #wysilekT').attr('checked', false);
			$('#findriscForm #wysilekN').attr('checked', false);
			$('#findriscForm #owoceT').attr('checked', false);
			$('#findriscForm #owoceN').attr('checked', false);
			$('#findriscForm #cisnienieN').attr('checked', false);
			$('#findriscForm #cisnienieT').attr('checked', false);
			$('#findriscForm #glukozaN').attr('checked', false);
			$('#findriscForm #glukozaT').attr('checked', false);
			$('#findriscForm #cukrzyca1').attr('checked', false);
			$('#findriscForm #cukrzyca2').attr('checked', false);
			$('#findriscForm #cukrzyca3').attr('checked', false);
		}).hover(
				function(){
					$(this).attr('src', 'images/calc/wyczysc_on.png');
				},
				function(){
					$(this).attr('src', 'images/calc/wyczysz_off.png');
				}
			);
		$('#plecK').bind('check',function(){
			$('#obwod_m').attr('disabled',true).next().hide();
			$('#obwod_k').attr('disabled',false).next().show();
		});
		$('#plecM').bind('check',function(){
			$('#obwod_k').attr('disabled',true).next().hide();
			$('#obwod_m').attr('disabled',false).next().show();
		});
		$('#backFindrisc').click(function(){
			$('#findriscBox').removeClass('findriscBack2').addClass('findriscBack1');
			$('#findriscRes').hide();
			$('#findriscBox .findrisc2').hide();
			$('#findriscForm').show();
			$('#findriscBox .findrisc1').show();
			$('#findriscForm #plecM').attr('checked', true);
			$('#findriscForm #wiek').getSetSSValue(1);
			$('#findriscForm #bmi').getSetSSValue(1);
			$('#findriscForm #obwod').getSetSSValue(1);
			$('#findriscForm #wysilekT').attr('checked', true);
			$('#findriscForm #owoceT').attr('checked', true);
			$('#findriscForm #cisnienieN').attr('checked', true);
			$('#findriscForm #glukozaN').attr('checked', true);
			$('#findriscForm #cukrzyca1').attr('checked', true);
		}).hover(
			function(){
				$(this).attr('src', 'images/findrisc/powrot_on.png');
			},
			function(){
				$(this).attr('src', 'images/findrisc/powrot_off.png');
			}
		);
	    var options = { 
			target: '#findriscRes', 
 		    success: function(responseText, statusText, xhr, $form) {
				$('#findriscBox').removeClass('findriscBack1').addClass('findriscBack2');
				/*$('#findriscForm').hide();
				$('#findriscBox .findrisc1').hide();*/
				$('#findriscRes').show();
				$('#findriscBox .findrisc2').show();
			} 
		}; 
		$('#findriscForm').ajaxForm(options);
		$('#findriscForm input:radio').checkbox();
		$('#findriscForm select').sSelect();
		if ($('#findriscForm #plecK').attr('checked') == true) {
			$('#obwod_m').attr('disabled',true).next().hide();
			$('#obwod_k').attr('disabled',false).next().show();
		} else {
			$('#obwod_k').attr('disabled',true).next().hide();
			$('#obwod_m').attr('disabled',false).next().show();
		}
	},
	framingham: function() {
		$('#submitFramingham').click(function(){
			$('#framinghamForm').submit();
		}).hover(
			function(){
				$(this).attr('src', 'images/framingham/oblicz_on.png');
			},
			function(){
				$(this).attr('src', 'images/framingham/oblicz_off.png');
			}
		);
		$('#clearCalc').click(function(){
			$('#framinghamBox').removeClass('framinghamBack2').addClass('framinghamBack1');
			$('#framinghamRes').hide();
			$('#framinghamBox .framingham2').hide();
			$('#framinghamForm').show();
			$('#framinghamBox .framingham1').show();
			$('#framinghamForm #plecM').attr('checked', false);
			$('#framinghamForm #plecK').attr('checked', false);
			$('#framinghamForm #wiek').getSetSSValue(1);
			$('#framinghamForm #cholesterol_calk_mmol').getSetSSValue(1);
			$('#framinghamForm #cholesterol_calk_mg').getSetSSValue(1);
			$('#framinghamForm #cholesterol_calk_jedn').getSetSSValue(1);
			$('#framinghamForm #cholesterol_hdl_mmol').getSetSSValue(1);
			$('#framinghamForm #cholesterol_hdl_mg').getSetSSValue(1);
			$('#framinghamForm #cholesterol_hdl_jedn').getSetSSValue(1);
			$('#framinghamForm #skurczowe').getSetSSValue(1);
			$('#framinghamForm #diabetykN').attr('checked', false);
			$('#framinghamForm #palaczN').attr('checked', false);
			$('#framinghamForm #diabetykT').attr('checked', false);
			$('#framinghamForm #palaczT').attr('checked', false);
		}).hover(
				function(){
					$(this).attr('src', 'images/calc/wyczysc_on.png');
				},
				function(){
					$(this).attr('src', 'images/calc/wyczysz_off.png');
				}
			);
		$('#backFramingham').click(function(){
			$('#framinghamBox').removeClass('framinghamBack2').addClass('framinghamBack1');
			$('#framinghamRes').hide();
			$('#framinghamBox .framingham2').hide();
			$('#framinghamForm').show();
			$('#framinghamBox .framingham1').show();
			$('#framinghamForm #plecM').attr('checked', true);
			$('#framinghamForm #wiek').getSetSSValue(1);
			$('#framinghamForm #cholesterol_calk_mmol').getSetSSValue(1);
			$('#framinghamForm #cholesterol_calk_mg').getSetSSValue(1);
			$('#framinghamForm #cholesterol_calk_jedn').getSetSSValue(1);
			$('#framinghamForm #cholesterol_hdl_mmol').getSetSSValue(1);
			$('#framinghamForm #cholesterol_hdl_mg').getSetSSValue(1);
			$('#framinghamForm #cholesterol_hdl_jedn').getSetSSValue(1);
			$('#framinghamForm #skurczowe').getSetSSValue(1);
			$('#framinghamForm #diabetykN').attr('checked', true);
			$('#framinghamForm #palaczN').attr('checked', true);
		}).hover(
			function(){
				$(this).attr('src', 'images/framingham/powrot_on.png');
			},
			function(){
				$(this).attr('src', 'images/framingham/powrot_off.png');
			}
		);
		$('#cholesterol_calk_jedn').change(function(){
			if ($(this).val() == 'mmol') {
				$('#cholesterol_calk_mg').attr('disabled',true).next().hide();
				$('#cholesterol_calk_mmol').attr('disabled',false).next().show();
				$('#cholesterol_calk_mmol').getSetSSValue($('#cholesterol_calk_mg').getSetSSValue());
			}
			if ($(this).val() == 'mg') {
				$('#cholesterol_calk_mmol').attr('disabled',true).next().hide();
				$('#cholesterol_calk_mg').attr('disabled',false).next().show();
				$('#cholesterol_calk_mg').getSetSSValue($('#cholesterol_calk_mmol').getSetSSValue());
			}
		});
		$('#cholesterol_hdl_jedn').change(function(){
			if ($(this).val() == 'mmol') {
				$('#cholesterol_hdl_mg').attr('disabled',true).next().hide();
				$('#cholesterol_hdl_mmol').attr('disabled',false).next().show();
				$('#cholesterol_hdl_mmol').getSetSSValue($('#cholesterol_hdl_mg').getSetSSValue());
			}
			if ($(this).val() == 'mg') {
				$('#cholesterol_hdl_mmol').attr('disabled',true).next().hide();
				$('#cholesterol_hdl_mg').attr('disabled',false).next().show();
				$('#cholesterol_hdl_mg').getSetSSValue($('#cholesterol_hdl_mmol').getSetSSValue());
			}
		});
	    var options = { 
			target: '#framinghamRes', 
 		    success: function(responseText, statusText, xhr, $form) {
	    	/*$('#framinghamBox').removeClass('framinghamBack1').addClass('framinghamBack2');
				$('#framinghamForm').hide();
				$('#framinghamBox .framingham1').hide();*/
				$('#framinghamRes').show();
				$('#framinghamBox .framingham2').show();
			} 
		}; 
		$('#framinghamForm').ajaxForm(options);
		$('#framinghamForm input:radio').checkbox();
		$('#framinghamForm select').sSelect();
		$('#framinghamForm #cholesterol_calk_mg').attr('disabled',true).next().hide();
		$('#framinghamForm #cholesterol_hdl_mg').attr('disabled',true).next().hide();
	}
}

$(document).ready(function() {
	
	$('#jclock').jclock({
		format: '%A, %d %B %Y, %H:%M:%S'
	});
	  	
	/**
	 * replace hspace and vspace elements with margin
	 */
	$(".wysiwyg img").each(function(){
		vspace = parseInt($(this).attr('vspace'));
		if (vspace > 0) $(this).css({ 'margin-top': vspace+'px', 'margin-bottom': vspace+'px' });
		hspace = parseInt($(this).attr('hspace'));
		if (hspace > 0) $(this).css({ 'margin-left': hspace+'px', 'margin-right': hspace+'px' });
		if ($("html").hasClass('ie7')) {
			align = $(this).attr('align');
			if (align) 
				$(this).css({
					'float': align
				});
		}

	});
	
	$(".wysiwyg font").each(function(){
		var size = parseInt($(this).attr('size'));
		var font = 0;
		if (size==1) font=8;
		if (size==2) font=10;
		if (size==3) font=12;
		if (size==4) font=14;
		if (size==5) font=18;
		if (size==6) font=24;
		if (size==7) font=36;
		if (font > 0) $(this).css({ 'font-size': font+'pt' });
	});
	
});
