var lastscreenwidth;

function o_click(obj)
{
 
  obj.setAttribute('clicked','y');  
}
 
function mouseOver(obj,cls)
{
 if (obj.getAttribute('clicked')!='y')
 {
  obj.oldclass= obj.className;
  obj.className= obj.oldclass + ' ' + cls;	
 }
}
 
function mouseOut(obj)
{
	 if (obj.getAttribute('clicked')!='y')
	 {
	    obj.className=obj.oldclass;
	 }  
}

function setRightColumn()
{
	
	scrwidth=0;		
	if (window.innerWidth && scrwidth==0)
	{
	 	scrwidth=parseInt(window.innerWidth)
	}
	if (document.documentElement.clientWidth && scrwidth==0)
	{
	  scrwidth=parseInt(document.documentElement.clientWidth)
	}
	if(document.body.clientWidth && scrwidth==0)
	{
	 	scrwidth=parseInt(document.body.clientWidth)
	}
	
	tmpnode=document.getElementById('rightcolumnfixed');
	document.getElementById('rightcolumn').innerHTML=document.getElementById('rightcolumnfixed').innerHTML
 // minScreenwidth=950; // this was the setting we had to create a fixed section to the right of the screen
                        // and make it a normal cell column if the window size was too small to allow a 
                        // reasonable display area
   document.getElementById('rightcolumnfixed').style.visibility='hidden';
   document.getElementById('rightcolumn').style.visibility='visible';
	 document.getElementById('rightcolumnfooter').style.visibility='visible';
	/*if ((scrwidth<=minScreenwidth) )
	{
		
	   document.getElementById('rightcolumnfixed').style.visibility='hidden'; 
		 document.getElementById('rightcolumn').style.visibility='visible';
		 document.getElementById('rightcolumnfooter').style.visibility='visible';
		// movenode("rightcolumnfixed","rightcolumn",)
	}	
	else
	{
		 document.getElementById('rightcolumnfixed').style.visibility='visible'; 
		 document.getElementById('rightcolumn').style.visibility='hidden';
		 document.getElementById('rightcolumnfooter').style.visibility='hidden';
  }*/

}
function movenode(from,to,newid)
{
	tmpNode=document.getElementById(from).cloneNode(true);
  tmpNode.setAttribute('id',newid);	
  tonode=document.getElementById(to);
  tonode.parentNode.insertBefore(tmpNode,tonode);
}



function init()
{
  window.onresize = function()
  {
    setRightColumn()
  };
}

function settarget()
{
	allanchors=document.getElementsByTagName('a');
	for (i=0;i<allanchors.length;i++)
	{
	  if (allanchors[i].className.indexOf('oa_target')>-1)
		{
		  allanchors[i].setAttribute('target','_blank');
		}	
	}
}
function returnQval(key)
{    // this function returns the value of the corresponding key in the querystring
 
    var qstring = window.location.search.substr(1)
		if (qstring.length >0)
    {
        pairs=qstring.split('&')
        for (i=0;i<pairs.length;i++)
        {
            if (pairs[i].split('=')[0] == key)
            {
            return pairs[i].split('=')[1]
            }
        }
    }                   
    return ''
}

function addToClass(ElementId,newclass)
// creates a class value without removing the existing classes and ensures no duplicate
{	
	alreadythere=false;
	el=document.getElementById(ElementId);
	if (el)
	{
		if (el.className)
		{
			cl=el.className.split(' ');
			for (i=0;i<cl.length;i++)
			{
				if (cl[i]==newclass)
				{
					alreadythere=true;
					break; //already there
				}				
			}			
		}
		if (!alreadythere)
		{
			el.className+=' ' + newclass;
		}		
	}	
}

function removeFromClass(ElementId,oldclass)
// removes only the class value that is required leaving all other class values intact
{
  el=document.getElementById(ElementId);
	if (el)
	{
		if (el.className)
		{
			cl=el.className.split(' ');
			for (i=0;i<cl.length;i++)
			{
				if (cl[i]==oldclass)
				{
					cl[i]='';
					break; //found it get out
				}				
			}	
			el.className=cl.join(' '); //join the remaining class values into the class		
		}				
	}	
}


function addToClass_Obj(el,newclass)
// creates a class value without removing the existing classes and ensures no duplicate
{	
  alreadythere=false;
	if (el)
	{
		if (el.className)
		{
			cl=el.className.split(' ');
			for (i=0;i<cl.length;i++)
			{
				if (cl[i]==newclass)
				{
					alreadythere=true;
					break; //already there
				}				
			}			
		}
		if (!alreadythere)
		{
			el.className+=' ' + newclass;
		}
	}	
}

function removeFromClass_Obj(el,oldclass)
// removes only the class value that is required leaving all other class values intact
{
  if (el)
	{
		if (el.className)
		{
			cl=el.className.split(' ');
			for (i=0;i<cl.length;i++)
			{
				if (cl[i]==oldclass)
				{
					cl[i]='';
					break; //found it get out
				}				
			}	
			el.className=cl.join(' '); //join the remaining class values into the class		
		}				
	}	
}

function getScreenwidth()
{
scrwidth=0;
	if (window.innerWidth && scrwidth==0)
	{
	 	scrwidth=parseInt(window.innerWidth)
	}
	if (document.documentElement.clientWidth && scrwidth==0)
	{
	  scrwidth=parseInt(document.documentElement.clientWidth)
	}
	if(document.body.clientWidth && scrwidth==0)
	{
	 	scrwidth=parseInt(document.body.clientWidth)
	}
  return scrwidth;
}

function setCenterCol()
{
  var screenwidth=getScreenwidth();
  var leftcolumn=120;
  var rightcolumn=165;
  var minwidth=745;
  var centerCol="";
  centerCol=screenwidth-leftcolumn-rightcolumn;
  if (centerCol<minwidth)
  {
    centerCol=minwidth;
  }

  document.getElementById("main_content_td").style.width=centerCol+'px';
  document.getElementById("left_and_content").style.width=leftcolumn+rightcolumn+centerCol-25+'px';
  lastscreenwidth=screenwidth;
}

function checkZoom()           // this is necessary for IE as it doesn't fire the onresize if you press ctrl+ or ctrl-
{
  if (lastscreenwidth !=getScreenwidth())
  {
    setCenterCol();
  }
}


function downloadOpen()
{
  window.open("http://www.incrediblecharts.com/free-charting_software/install.exe");
  window.location="http://www.incrediblecharts.com/free-charting_software/free_download.php#start";
}





