// JavaScript Document
// GLOBAL VARIABLES
var animateTime = 50;
var doAnimation = false;
var MAX_MENU = 10;
var ADS_LEVEL = 3;
var adsArray = new Array();
var count = 0;
var TV_REMOTE_TOOLTIPS = {
  '01':'Free EMR and PMS',
  '02':'Higher Reimbursement',
  '03':'Synaserver',
  '04':'Synchronization',
  '05':'Health Information Exchange',
  '06':'Turn-key',
  '07':'Patient Portal',
  '08':'Total Connectivity',
  '09':'Since 1999',
  '10':'Return on Investment',
  '11':'Specialty Specific'
};
var TV_REMOTE_TOOLTIPS2 = {
  '01':'ARRA Stimulus',
  '02':'EMR and PMS',
  '03':'Synaserver',
  '04':'Health Information Exchange',
  '05':'Turn-key',
  '06':'Patient Portal',
  '07':'Since 1999',
  '08':'Return on Investment',
  '09':'Specialty Specific'
};
var NAVIGATIONS = [
  //['Products and Services', 'pricing.html', '18%', 
    //[['Services and Prices', 'pricing.html'],['Hardware Requirements', 'hardware.html'],['SynaMed News', 'news.html']]
  ['Products and Services', 'hardware.html', '18%',
    [['Hardware Requirements', 'hardware.html'],['SynaMed News', 'news.html']]
  ], 
  ['Electronic Medical Records', 'emr.html', '19%',
    [['Electronic Medical Records', 'emr.html'],['Meaningful Use via Dictation','emrd.html'],['Patient Portal','pp.html'],['Server','solution.html'],['Features','clients.html']]
  ], 
  ['Practice Management System', 'pms.html', '19%',
    [['Practice Management','pms.html'],['Features','pmsFeatures.html']]
  ], 
  ['Personal Health Record', 'phr.html', '18%', [['Personal Health Record','phr.html'],['Features','phrFeatures.html']]], 
  ['SynaLink', 'synalink.html', '14%', [['SynaLink','synalink.html'],['Features','synalinkFeatures.html']]], 
  //['Contact', 'contact.html', '8%', null], 
  ['See A Demo', 'javascript:MM_openBrWindow(\'http://www.synamed.com/vco/register.jsp?registerAgain=true\',\'requestademo\',\'scrollbars=yes,resizable=yes,width=700,height=800\')" target="_top', '11%', null]
];
var STATEMENT = 'At <span class="statementSynaFont">Syna</span><span class="statementMedFont">Med</span>, we\'ve created a groundbreaking, integrated, web-based Electronic Medical Records (EMR) / Practice Management System (PMS) that meets all the major needs of healthcare providers from specialists to general practitioners.';// Our award-winning ASP is top-rated by KLAS 2006, AC Group, TETHIC, and TEPR.';

function generateHeader2() { generateHeader(685, 230); }

function generateHeader(w1, w2) {
  document.write('<tr>');
  document.write('<td width="'+w1+'px" style="text-align:left;" height="50px" valign="bottom"><a href="index.html"><img src="imgs/headerLogo.gif"/></a></td>');
  document.write('<td width="'+w2+'px" valign="top" align="right"><table><tr>');
  document.write('<td onmouseout="showSubMenu(this, false);" onmouseover="showSubMenu(this, true);" class="headerLinkTd">');
  document.write('<a href="./vco/index.jsp" class="loginLink" id="loginLink"><span>Log In</span></a>');
  document.write('<div style="width:100%;position:relative;z-index:1000;">');
  document.write('<table style="display:none;">');
  document.write('<tr><td class="loginSub1"></td><td class="loginSub2"></td></tr>');
  document.write('<tr><td colspan="2" class="docLinkTd"><a href="./vco/index.jsp">&nbsp;&nbsp;&nbsp;Doctor</a></td></tr>');
  document.write('<tr><td colspan="2" class="patLinkTd"><a href="./vco/patientPortal/index.jsp">&nbsp;&nbsp;&nbsp;Patient</a></td></tr>');
  document.write('</table></div></td>');
  document.write('<td class="headerLinkSeparator"><span></span></td>');
  //document.write('<td class="headerLinkTd"><a href="mailto:support@synamed.com?subject=Support Request">Support</a></td>');
  document.write('<td class="headerLinkTd"><a href="contact.html">Contact</a></td>');
  document.write('<td class="headerLinkSeparator"><span></span></td>');
  document.write('<td class="headerLinkTd"><a href="mission.html">About</a></td><td width="'+(w2==275?10:5)+'px"></td>');
  document.write('</tr></table></td>');
  document.write('</tr>');
  document.write('<tr><td colspan="100%">');
  showNavigations((w2==275?10:5));
  document.write('</td></tr>');
}

function generateFooter() {
  /*document.write('<tr><td colspan="100%" align="left">');
  document.write('<span class="synaColorGray" style="font-size:10pt">Copyright &copy; 2010 Synamed. All right reserved.</span>');
  document.write(' <a class="synaColorLink" href="" style="font-size:10pt">Terms of Use</a> | ');
  document.write('<a class="synaColorLink" href="" style="font-size:10pt">Privacy Policy</a><br/>');
  document.write('<span class="synaFooterLinkGroup"><a href="index.html" class="synaColorLink2">Home</a> | ');
  document.write('<a href="contact.html" class="synaColorLink2">Contact</a> | ');
  document.write('<a href="testimonials.html" class="synaColorLink2">Testimonials</a> | ');
  document.write('<a href="mission.html" class="synaColorLink2">Our Mission</a> | ');
  document.write('<a href="solution.html" class="synaColorLink2">SynaServer</a> | ');
  document.write('<a href="emr.html" class="synaColorLink2">Electronic Medical Record</a> | ');
  document.write('<a href="pms.html" class="synaColorLink2">Practice Management System</a> | ');
  document.write('<a href="phr.html" class="synaColorLink2">Personal Health Record</a> | ');
  document.write('<a href="clients.html" class="synaColorLink2">Clients</a> | ');
  document.write('<a href="mailto:support@synamed.com?subject=Support Request" class="synaColorLink2">Support</a> | ');
  document.write('<a href="#loginLink" class="synaColorLink2">Log In</a> | ');
  document.write('<a href="pp.html" class="synaColorLink2">Patient Portal</a> | ');
  document.write('<a href="directory.php" class="synaColorLink2">Directory: </a>');
  document.write('<a href="http://www.build-reciprocal-links.com/" class="synaColorLink2">Link Exchange</a></span>');
  document.write('</td></tr>');
  */
  document.write('<tr><td colspan="100%"><div style="display:block;width:905px;">');
  showBottomLinks();
  document.write('</div></td></tr>');
  document.write('<tr><td colspan="100%" class="emptyRow"></td></tr>');
  document.write('<tr><td colspan="100%" class="synaColorGray" style="font-size:10pt;text-align:right;" align="right">Copyright &copy; 2010 SynaMed. All rights reserverd.</td></tr>');
}

function showEmptyRow() {
  document.write('<tr><td colspan="100%" class="emptyRow"></td></tr>');
}

function showBottomLinks() {
  document.write('<center><table>');
  document.write('<tr><td colspan="100%" class="emptyRowSmall"></td></tr>');
  document.write('<tr><td class="synaColorLink" style="font-size:11pt;">');
  document.write('<a href="index.html" class="synaColorLink">Home</a> | ');
  document.write('<a href="contact.html" class="synaColorLink">Contact</a> | ');
  //document.write('<a class="synaColorLink" href="mission.html">Our Mission</a> | ');
  document.write('<a class="synaColorLink" href="mission.html">About</a> | ');
  //document.write('<a class="synaColorLink" href="directory.php">Directory</a> - <a class="synaColorLink" href="http://www.build-reciprocal-links.com/">Link</a>');
  document.write('<a class="synaColorLink" href="disclaimer.html">Disclaimer</a> | ');
  document.write('<a class="synaColorLink" href="termsOfUse2010.htm" target="_new">Terms of Use</a> | ');
  document.write('<a class="synaColorLink" href="privacyPolicy2010.htm" target="_new">Privacy Policy</a>');
  document.write('</td></tr>');
  document.write('<tr><td colspan="100%" class="emptyRowSmall"></td></tr>');
  document.write('</table></center>');
}

function showLowerModule(count, flag) {
  if (count == null) count = 4;
  var width = 227;
  if (count == 3) width = 220;
  var h1 = '<tr><td class="midModuleTitle"><a href="news.html">SynaMed News</a></td></tr>';
  var h2 = '<tr><td class="midModuleDescription"></td></tr>';
  var h3 = '<tr><td><a href="news.html"><img src="imgs/btmModuleImage02.jpg"/></a></td></tr>';
  if (count == 4 || (count == 3 && flag)) {
//    h1 = '<tr><td class="midModuleTitle"><a href="hardware.html">Technology</a></td></tr>';
    h1 = '<tr><td class="midModuleTitle"><a href="arra.html">ARRA</a></td></tr>';
    h2 = '<tr><td class="midModuleDescription"></td></tr>';
//    h3 = '<tr><td><a href="hardware.html"><img src="imgs/btmModuleImage01.jpg"/></a></td></tr>'
    h3 = '<tr><td><a href="arra.html"><img src="imgs/btmModuleImage01.jpg"/></a></td></tr>'
  }
  document.write('<tr><td colspan="100%"><table'+(count==4?' width="905px"':'')+'><tr>');
  document.write('  <td style="background:url(imgs/lowerModule_left.jpg) no-repeat;width:'+width+'px;height:178px;border-right:1px solid #FFFFFF;">');
  document.write('    <center><table>');
  document.write(h1);
  document.write(h2);
  document.write(h3);
  document.write('    </table></center>');
  document.write('  </td>');
  if (count == 4) {
    document.write('  <td style="background:url(imgs/lowerModule_midLeft.jpg) no-repeat;width:'+width+'px;height:178px;border-right:1px solid #FFFFFF;">');
    document.write('    <center><table>');
    document.write('      <tr><td class="midModuleTitle"><a href="news.html">SynaMed News</a></td></tr>');
    document.write('      <tr><td class="midModuleDescription"></td></tr>');
    document.write('      <tr><td><a href="news.html"><img src="imgs/btmModuleImage02.jpg"/></a></td></tr>');
    document.write('    </table></center>');
    document.write('  </td>');
  }
  document.write('  <td style="background:url(imgs/lowerModule_midRight.jpg) no-repeat;width:'+width+'px;height:178px;border-right:1px solid #FFFFFF;">');
  document.write('    <center><table>');
  document.write('      <tr><td class="midModuleTitle"><a href="partnership.html">Partnership Programs</a></td></tr>');
  document.write('      <tr><td class="midModuleDescription"></td></tr>');
  document.write('      <tr><td><a href="partnership.html"><img src="imgs/btmModuleImage03.jpg"/></a></td></tr>');
  document.write('    </table></center>');
  document.write('  </td>');
  document.write('  <td style="background:url(imgs/lowerModule_right.jpg) no-repeat top right;width:'+width+'px;height:178px;border-right:1px solid #FFFFFF;">');
  document.write('    <center><table>');
  document.write('      <tr><td class="midModuleTitle"><a href="testimonials.html">Testimonials</a></td></tr>');
  document.write('      <tr><td class="midModuleDescription"></td></tr>');
  document.write('      <tr><td><a href="testimonials.html"><img src="imgs/btmModuleImage04.jpg"/></a></td></tr>');
  document.write('    </table></center>');
  document.write('  </td>');
  document.write('</tr></table></td></tr>');
}

function showStatementModule() {
  document.write('<tr><td><div class="statementModuleLeft"><div class="statementModuleRight"><div class="statementModuleContent"><br/>');
  document.write(STATEMENT);
  document.write('</div></div></div></td></tr>');
}

function showSubMenu(td, show,isFirst,isLast) {
  var tables = td.getElementsByTagName('table');
  var table = null;
  if (tables != null && tables.length > 0) {
    table = tables[0];
  }
  if (table != null) {
    table.style.display = show?"":"none";
  }
  var span = td.firstChild.firstChild; // span
  if (span != null) {
    span.className = show?"selected":"";    
  }
  if (isFirst) {
    var naviBarLeft = document.getElementById('naviBarLeft');
    if (naviBarLeft != null) { naviBarLeft.className = 'naviBarLeft'+(show?'Selected':'');}
  }
  if (isLast) {
    var naviBarRight = document.getElementById('naviBarRight');
    if (naviBarRight != null) { naviBarRight.className = 'naviBarRight'+(show?'Selected':'');}
  }
}

function showNavigations(fixWidth) {
  document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>');
  document.write('<td class="naviBarLeft" id="naviBarLeft"></td>');
  document.write('<td class="naviBarCenter"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>');
  for (var i = 0; i < NAVIGATIONS.length; i++) {
    var nav = NAVIGATIONS[i];
    var children = nav[nav.length-1];
    document.write('<td width="'+nav[2]+'" onmouseout="showSubMenu(this,false,'+(i==0)+','+(i==NAVIGATIONS.length-1)+');" onmouseover="showSubMenu(this,true,'+(i==0)+','+(i==NAVIGATIONS.length-1)+');"'+(i>0?' class="naviTd"':'')+'>');
    document.write('<a href="'+nav[1]+'" class="navi"><span>'+nav[0]+'</span></a>');
    if (children != null) {
      document.write('<div style="width:100%;position:relative;z-index:1000;">');
      document.write('<table cellpadding="0" cellspacing="0" style="display:none;" class="buttonwrapper">');
      for (var c = 0; c < children.length; c++) {
        document.write('<tr><td'+(c+1==children.length?' class="borderBottom"':'')+' align="left">');
	document.write('<a class="boldbuttons" href="'+children[c][1]+'"><span>'+children[c][0]+'</span></a></td></tr>');
      }
      document.write('</table></div>');
    }
    document.write('</td>');
  }
  document.write('</tr></table></td>');
  document.write('<td class="naviBarRight" id="naviBarRight"></td>');
  if (fixWidth) { document.write('<td width="'+fixWidth+'px"></td>'); }
  document.write('</tr></table>');
}

function initTvRemotePreload() {
  for (var key in TV_REMOTE_TOOLTIPS2) {
    var tvRemote = document.getElementById('tvRemote'+key);
    tvRemote.src = 'imgs/tvScreen/tn_'+key+'_downOver.gif';
    tvRemote.src = 'imgs/tvScreen/tn_'+key+'_up.gif';
  }
}

var toScroll = new Object();
function stopScrolling(elId, up) {
  var scrollId = elId+(up?'_up_':'_down_');
  toScroll[scrollId] = false;
}
function startScrolling(elId, up) {
  var scrollId = elId+(up?'_up_':'_down_');
  toScroll[scrollId] = true;
  scrollElement(elId, up);
}
function scrollElement(elId, up) {
  var scrollId = elId+(up?'_up_':'_down_');
  if (toScroll[scrollId] && toScroll[scrollId] == true) {
    scrollByHeight(elId, up?-5:5);
    setTimeout('scrollElement("'+elId+'", '+up+');', 20);
  }
}
function scrollByHeight(elId, h) {
  var el = document.getElementById(elId);
  if (el != null) {
    el.scrollTop += h;
  }
}

function scrollwindow(){
  if (document.all && !document.getElementById)
    temp=document.body.scrollTop
  else
    temp=window.pageYOffset
  if (alt==0)
    alt=2
  else
    alt=1
  if (alt==0)
    curpos1=temp
  else
    curpos2=temp
  if (curpos1!=curpos2){
    if (document.all)
      currentpos=document.body.scrollTop+speed
    else
      currentpos=window.pageYOffset+speed
      window.scroll(0,currentpos)
    }
  else{
    currentpos=0
    window.scroll(0,currentpos)
  }
}

function getSelectedTestimonialPage() {
  for (var i = 1; i <= 3; i++) {
    var content = document.getElementById('testimonialBox'+i);
    if (content != null && content.style.display == '') {
      return i;
    }
  }
  return 1;
}
function nextTestimonialPage() {
  changeTestimonialPage(getSelectedTestimonialPage()+1);	
}
function prevTestimonialPage() {
  changeTestimonialPage(getSelectedTestimonialPage()-1);	
}
function changeTestimonialPage(p) {
  var page = p<=0?3:p>3?1:p;
  for (var i = 1; i <= 3; i++) {
    var content = document.getElementById('testimonialBox'+i);
    var img = document.getElementById('testimonialImg'+i);
    var er = document.getElementById('testimonialER'+i);
    if (i == page) {
      content.style.display = '';
      if (img != null) { img.style.display = ''; }
      if (er != null) { er.style.display = ''; }
    } else {
      content.style.display = 'none';
      if (img != null) { img.style.display = 'none'; }
      if (er != null) { er.style.display = 'none'; }
    }
  }
  var pc = document.getElementById('pageCounter');
  pc.innerHTML = ''+page;
}

function getSelectedPsRemotePage() {
  for (var i = 1; i <= 4; i++) {
    var content = document.getElementById('contentText'+i);
    if (content != null && content.style.display == '') {
      return i;
    }
  }
  return 1;
}
function nextPSRemotePage() {
  changePSRemotePage(getSelectedPsRemotePage()+1);
}
function prevPSRemotePage() {
  changePSRemotePage(getSelectedPsRemotePage()-1);
}
function changePSRemotePage(p) {
  var page = p<=0?4:p>4?1:p;
  for (var i = 1; i <= 4; i++) {
    var content = document.getElementById('contentText'+i);
    if (i == page) {
      content.style.display = '';
    } else {
      content.style.display = 'none';
    }
  }
}

function getPosition(obj) {
  var curleft = curtop = 0;
  if (obj != null && obj.offsetParent) {
    do {
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
    } while (obj = obj.offsetParent);
  }
  return [curleft, curtop];
}

function handleMouseOverTvRemote(screenNum) {
  var tvRemote = document.getElementById('tvRemote'+screenNum);
  if (tvRemote != null) {
    tvRemote.style.cursor = 'pointer';
    tvRemote.src = 'imgs/tn_'+screenNum+'_downOver.gif';
  }
  showTvRemoteTooltip(screenNum);
}

function handleMouseOverTvRemote2(screenNum) {
  var tvRemote = document.getElementById('tvRemote'+screenNum);
  if (tvRemote != null) {
    tvRemote.style.cursor = 'pointer';
    tvRemote.src = 'imgs/tvScreen/tn_'+screenNum+'_downOver.gif';
  }
  showTvRemoteTooltip(screenNum, TV_REMOTE_TOOLTIPS2[screenNum]);
}

var curScreenNum = 1;
function rotateTvScreen() {
  if (curScreenNum == -1) { return; }
  if (curScreenNum == 7) { curScreenNum = 8; } //to be remove later.
  if (curScreenNum == 9) { curScreenNum = 1; }
  showTvScreen(curScreenNum);
  curScreenNum++;
  setTimeout('rotateTvScreen()', 8000);
}

function handleMouseClickTvRemote(screenNum) {
  curScreenNum = -1;
  showTvScreen(screenNum);
}

function showTvScreen(screenNum) {
  for (var i = 1; i <= 11; i++) {
    var curNum = i<10?'0'+i:''+i;
    var tvScreen = document.getElementById('tvScreen'+curNum);
    if (tvScreen == null) { continue; }
    if (curNum == screenNum) {
      tvScreen.style.display = '';
    } else {
      tvScreen.style.display = 'none';
    }
  }	
}

function showTvRemoteTooltip(screenNum, tooltip) {
  var tvRemote = document.getElementById('tvRemote'+screenNum);
  var tooltipContainer = document.getElementById('tvRemoteTooltipContainer');  // change tooltip position
  var tooltipText = document.getElementById('tvRemoteTooltipText'); // change tooltip text
  var tooltipArrowLeft = document.getElementById('tvRemoteTooltipArrowLeft'); // change tooltip arrow position by changing this width
  if (tvRemote!= null && tooltipContainer != null && tooltipText != null && tooltipArrowLeft != null) {
    if (tooltip != null) {
      tooltipText.innerHTML = tooltip;
    } else {
      tooltipText.innerHTML = TV_REMOTE_TOOLTIPS[screenNum];
    }
    tooltipContainer.style.display = '';
    var tvRemotePos = getPosition(tvRemote);
    tooltipContainer.style.top = (tvRemotePos[1]-30) + 'px';
	tooltipContainer.style.width='auto';
    var containerWidth = document.getElementById('tvRemoteTooltip').offsetWidth;
	tooltipContainer.style.width = containerWidth;
    if (screenNum == '01') {
      tooltipContainer.style.left = tvRemotePos[0] + 'px';
      tooltipArrowLeft.style.width = '8px';
    } else if (screenNum == '02') {
      tooltipContainer.style.left = (tvRemotePos[0]-28) + 'px';
      tooltipArrowLeft.style.width = 36+'px';
    } else {
      tooltipContainer.style.left = (tvRemotePos[0]-(containerWidth/2)+11) + 'px';
      tooltipArrowLeft.style.width = (containerWidth/2)+'px';
    }
  }
}

function handleMouseOutTvRemote(screenNum) {
  var tvRemote = document.getElementById('tvRemote'+screenNum);
  if (tvRemote != null) {
    tvRemote.src = 'imgs/tn_'+screenNum+'_up.gif';
  }
  var tooltipContainer = document.getElementById('tvRemoteTooltipContainer');
  if (tooltipContainer != null) {
    tooltipContainer.style.display = 'none';
  }
}

function handleMouseOutTvRemote2(screenNum) {
  var tvRemote = document.getElementById('tvRemote'+screenNum);
  if (tvRemote != null) {
    tvRemote.src = 'imgs/tvScreen/tn_'+screenNum+'_up.gif';
  }
  var tooltipContainer = document.getElementById('tvRemoteTooltipContainer');
  if (tooltipContainer != null) {
    tooltipContainer.style.display = 'none';
  }
}

function makeNewsHeader(title, lnk, description) {
	var msg = '<h1>';
	msg += title;
	msg += ':</h1><br/>';
	return msg;
}

function makeNewsLine(title, lnk, description) {
	var msg = '<img src="imgs/star.png"/><span class="newsLink">';
	if (lnk && lnk != '') {
		msg += '<a href="' + lnk;	
	}
	msg += title;
	if (lnk && lnk != '') {
		msg += '</a>';	
	}
	if (description && description != '') {
		msg += ' - ' + description;	
	}
	msg += '</span><br/>';
	return msg;
}

function showElement(id, show) {
  //mouseOverMenu[id] = show;
  if (doAnimation) {
	animateShow(id, show);
	//if (show) animateShow(id);
	//else animateHide(id);
  } else {
    var elem = document.getElementById(id);
    if (elem != null) {
      if (show) elem.style.display = "";
      else elem.style.display = "none";
    }
  }
}

function animateShow(id, show, start) {
	var parent = document.getElementById(id);
	if (parent != null) {
		if (show) parent.style.display = "";
		var i = 1;
		if (start != null) i = start;
		var child = document.getElementById(''+ id+i);
		//alert(child);
		if (child == null) {
			if (!show) parent.style.display = "none";
			return;
		}
		if (show) child.style.display="";
		else child.style.display="none";
		setTimeout('animateShow(\''+id+'\', '+show+', '+(i+1)+');', animateTime);
	}
}

// Ads Tags methods
function Ads(width, height, frameId) {
	this.w = width;
	this.h = height;
	this.fn = frameId;
	this.tHtml = null;
}

Ads.prototype.init = function() {
	if (this.w == 120 && this.h == 600)
		this.tHtml = 'ads120x600.html';
	else if (this.w == 160 && this.h == 600)
		this.tHtml = 'ads160x600.html';
	else if (this.w == 300 && this.h == 250)
		this.tHtml = 'ads300x250.html';
	else if (this.w == 468 && this.h == 60)
		this.tHtml = 'ads468x60.html';
	else if (this.w == 728 && this.h == 90)
		this.tHtml = 'ads728x90.html';
}

Ads.prototype.show = function() {
	var f = document.getElementById(this.fn);
	if (f && f != null && this.tHtml != null) {
		f.src = this.tHtml;
	}
}

function showAds(width, height, level) {
	var id = 'adsFrame' + count;
	if (((!level || level == null) && ADS_LEVEL > 0) || parseInt(level) <= ADS_LEVEL) {
	document.write('<iframe src="blank.html" width="'+width+'px" height="'+height+'px" frameborder="0" id="'+id+'" name="'+id+'" scrolling="no" margin="0px" padding="0px" style="z-index: 0;"></iframe>');
	}
	var ads = new Ads(width, height, id);
	ads.init();
	adsArray[count] = ads;
	count++;
}

function showAds2(width, height, level) {
	try {
	var adsString = null;
	if ((!level || level == null) && ADS_LEVEL > 0) {
		adsString = getAdsString(width, height);
	} else if (parseInt(level) <= ADS_LEVEL) {
		adsString = getAdsString(width, height);	
	}
	if (adsString != null) {
		//alert(adsString);
		document.write(adsString);
	}
	} catch (err){
		alert(err);
	}
}
function getAdsString(width, height) {
	try {
	if (!width || !height) return;
	var position;
	if (width == 120 && height == 600)
		position = '@x08';
	else if (width == 160 && height == 600)
		position = '@x10';
	else if (width == 300 && height == 250)
		position = '@x15';
	else if (width == 468 && height == 60)
		position = '@Position1';
	else if (width == 728 && height == 90)
		position = '@Top1';
	if (!position) {
		alert('invalid ads size');
		return null;
	}
	var OAS_rn = new String (Math.random());
	var OAS_rns = OAS_rn.substring (2, 11);
	return '<scr'+'ipt LANGUAGE="JavaScript1.1" SRC="http://network.realmedia.com/RealMedia/ads/adstream_jx.ads/synamed/ros/'+width+'x'+height+'/hlt/ss/a/1'+OAS_rns+position + '"></scr'+'ipt>'
	} catch (err) {
		alert(err);
		return null;
	}
}
// end of ads tags methods

var gradientshadow={}
gradientshadow.depth=6 //Depth of shadow in pixels
gradientshadow.containers=[]

gradientshadow.create=function(){
var a = document.all ? document.all : document.getElementsByTagName('*')
for (var i = 0;i < a.length;i++) {
	if (a[i].className == "shadow") {
		for (var x=0; x<gradientshadow.depth; x++){
			var newSd = document.createElement("DIV")
			newSd.className = "shadow_inner"
			newSd.id="shadow"+gradientshadow.containers.length+"_"+x //Each shadow DIV has an id of "shadowL_X" (L=index of target element, X=index of shadow (depth) 
			if (a[i].getAttribute("rel"))
				newSd.style.background = a[i].getAttribute("rel")
			else
				newSd.style.background = "black" //default shadow color if none specified
			document.body.appendChild(newSd)
		}
	gradientshadow.containers[gradientshadow.containers.length]=a[i]
	}
}
gradientshadow.position()
window.onresize=function(){
	gradientshadow.position()
}
}

gradientshadow.position=function(){
if (gradientshadow.containers.length>0){
	for (var i=0; i<gradientshadow.containers.length; i++){
		for (var x=0; x<gradientshadow.depth; x++){
  		var shadowdiv=document.getElementById("shadow"+i+"_"+x)
			shadowdiv.style.width = gradientshadow.containers[i].offsetWidth + "px"
			shadowdiv.style.height = gradientshadow.containers[i].offsetHeight + "px"
			shadowdiv.style.left = gradientshadow.containers[i].offsetLeft + x + "px"
			shadowdiv.style.top = gradientshadow.containers[i].offsetTop + x + "px"
		}
	}
}
}

if (window.addEventListener)
window.addEventListener("load", gradientshadow.create, false)
else if (window.attachEvent)
window.attachEvent("onload", gradientshadow.create)
else if (document.getElementById)
window.onload=gradientshadow.create

function showAllAds() {
  for (var i = 0; i < adsArray.length; i++) {
	adsArray[i].show();	
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function NiftyCheck() {
  if(!document.getElementById || !document.createElement) {
    return false;
  }
  var b = navigator.userAgent.toLowerCase();
  if (b.indexOf("msie 5") > 0 && b.indexOf("opera") == -1) {
    return false;
  }
  return true;
}

function Rounded(className, sizex, sizey, sizex_b, sizey_b) {
	var bk;
	if (!NiftyCheck()) return;
	if (typeof(sizex_b) == 'undefined')
		sizex_b = sizex;
	if (typeof(sizey_b) == 'undefined')
		sizey_b = sizey;
	var v = getElements(className);
	var l = v.length;
	for (var i = 0; i < l; i++) {
		color = get_current_style(v[i],"background-color","transparent");
		bk = get_current_style(v[i].parentNode,"background-color","transparent");
		AddRounded(v[i], bk, color, sizex, sizey, true);
		AddRounded(v[i], bk, color, sizex_b, sizey_b, false);
	}
}

Math.sqr = function (x) {
  return x*x;
};

function Blend(a, b, alpha) {

  var ca = Array(
    parseInt('0x' + a.substring(1, 3)), 
    parseInt('0x' + a.substring(3, 5)), 
    parseInt('0x' + a.substring(5, 7))
  );
  var cb = Array(
    parseInt('0x' + b.substring(1, 3)), 
    parseInt('0x' + b.substring(3, 5)), 
    parseInt('0x' + b.substring(5, 7))
  );
  return '#' + ('0'+Math.round(ca[0] + (cb[0] - ca[0])*alpha).toString(16)).slice(-2).toString(16)
             + ('0'+Math.round(ca[1] + (cb[1] - ca[1])*alpha).toString(16)).slice(-2).toString(16)
             + ('0'+Math.round(ca[2] + (cb[2] - ca[2])*alpha).toString(16)).slice(-2).toString(16);

  return '#' + ('0'+Math.round(ca[0] + (cb[0] - ca[0])*alpha).toString(16)).slice(-2).toString(16)
             + ('0'+Math.round(ca[1] + (cb[1] - ca[1])*alpha).toString(16)).slice(-2).toString(16)
             + ('0'+Math.round(ca[2] + (cb[2] - ca[2])*alpha).toString(16)).slice(-2).toString(16);
}

function AddRounded(el, bk, color, sizex, sizey, top) {
  if (!sizex && !sizey)
	return;
  var i, j;
  var d = document.createElement("div");
  d.style.backgroundColor = bk;
  var lastarc = 0;
  for (i = 1; i <= sizey; i++) {
    var coverage, arc2, arc3;
    // Find intersection of arc with bottom of pixel row
    arc = Math.sqrt(1.0 - Math.sqr(1.0 - i / sizey)) * sizex;
    // Calculate how many pixels are bg, fg and blended.
    var n_bg = sizex - Math.ceil(arc);
    var n_fg = Math.floor(lastarc);
    var n_aa = sizex - n_bg - n_fg;
    // Create pixel row wrapper
    var x = document.createElement("div");
    var y = d;
    x.style.margin = "0px " + n_bg + "px";
	x.style.height='1px';
	x.style.overflow='hidden';
    // Make a wrapper per anti-aliased pixel (at least one)
    for (j = 1; j <= n_aa; j++) {
      // Calculate coverage per pixel
      // (approximates circle by a line within the pixel)
      if (j == 1) {
        if (j == n_aa) {
          // Single pixel
          coverage = ((arc + lastarc) * .5) - n_fg;
        }
        else {
          // First in a run
          arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
          coverage = (arc2 - (sizey - i)) * (arc - n_fg - n_aa + 1) * .5;
          // Coverage is incorrect. Why?
          coverage = 0;
        }
      }
      else if (j == n_aa) {
        // Last in a run
        arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
        coverage = 1.0 - (1.0 - (arc2 - (sizey - i))) * (1.0 - (lastarc - n_fg)) * .5;
      }
      else {
        // Middle of a run
        arc3 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j) / sizex)) * sizey;
        arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
        coverage = ((arc2 + arc3) * .5) - (sizey - i);
      }
      
      x.style.backgroundColor = Blend(bk, color, coverage);
	  if (top)
	      y.appendChild(x);
      else
	      y.insertBefore(x, y.firstChild);
      y = x;
      var x = document.createElement("div");
		x.style.height='1px';
		x.style.overflow='hidden';
      x.style.margin = "0px 1px";
    }
    x.style.backgroundColor = color;
    if (top)
	    y.appendChild(x);
    else
		y.insertBefore(x, y.firstChild);
    lastarc = arc;
  }
  if (top)
	  el.insertBefore(d, el.firstChild);
  else
	  el.appendChild(d);
}

function getElements(className) {
	var elements = [];
	var el = document.getElementsByTagName('DIV');  
	var regexp=new RegExp("\\b"+className+"\\b");
	for (var i = 0; i < el.length; i++) 
	{
		if (regexp.test(el[i].className)) 
			elements.push(el[i]);
	}
	return elements;
}

function get_current_style(element,property,not_accepted)
{
  var ee,i,val,apr;
  try
  {
    var cs=document.defaultView.getComputedStyle(element,'');
    val=cs.getPropertyValue(property);
  }
  catch(ee)
  {
    if(element.currentStyle)
  	{
	    apr=property.split("-");
	    for(i=1;i<apr.length;i++) apr[i]=apr[i].toUpperCase();
	    apr=apr.join("");
	    val=element.currentStyle.getAttribute(apr);
   }
  }
  if((val.indexOf("rgba") > -1 || val==not_accepted) && element.parentNode)
  {
	 if(element.parentNode != document) 
		 val=get_current_style(element.parentNode,property,not_accepted);
	 else
		 val = '#FFFFFF';
  }
  if (val.indexOf("rgb") > -1 && val.indexOf("rgba") == -1)
	  val = rgb2hex(val);
  if (val.length == 4)
	  val = '#'+val.substring(1,1)+val.substring(1,1)+val.substring(2,1)+val.substring(2,1)+val.substring(3,1)+val.substring(3,1);
  return val;
}

function rgb2hex(value)
{
	var x = 255;
	var hex = '';
	var i;
	var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
	var array=regexp.exec(value);
	for(i=1;i<4;i++) hex += ('0'+parseInt(array[i]).toString(16)).slice(-2);
	return '#'+hex;
}

