﻿//default style sheet = 11
var readCook = getCookie("CorPicNewFontSize");

var sz=11;


setInitalStyleSheet(sz);
function setInitalStyleSheet(cookVal)
{
	var li; //links of styles sheets
	var cssCol = document.getElementsByTagName("link");

	for(var i=0; li=cssCol[i]; i++) 
	{

		window.defaultStatus = cssCol[i].getAttribute("title");
		// get stylesheets
     		if(li.getAttribute("rel").indexOf("style") != -1 && li.getAttribute("title")) 
		{

			if(li.getAttribute("title").indexOf("article") != -1) li.disabled = true;
			// check if 1 - it's a stylesheet with a title, 2- if it is an article stylesheet, disable it
			if (li.getAttribute("title").indexOf(cookVal) > -1) li.disabled = false;
			// if it's the next in line, enable it
		
		}
	}
}
function selectStyleSheet(dir) 
{

	var li; //links of styles sheets
	//make sure we're under limit
	sz = parseInt(sz);
	dir = parseInt(dir);
	//alert(sz);
	if (10<sz+dir&&sz+dir<15)
	{
	
		for(var i=0; li=document.getElementsByTagName("link")[i]; i++) 
		{
			// get stylesheets
     			if(li.getAttribute("rel").indexOf("style") != -1 && li.getAttribute("title")) 
			{
      				if(li.getAttribute("title").indexOf("article") != -1) li.disabled = true;
				// check if 1 - it's a stylesheet with a title, 2- if it is an article stylesheet, disable it
				if (li.getAttribute("title").indexOf(sz+dir) > -1) li.disabled = false;
				// if it's the next in line, enable it
	  		}
	 	}
		//don't forget to increment the size, so we know what's next....
    		sz=sz+dir;
		setCookie("CorPicNewFontSize",sz,0,"/");		
   	}
}


function colorchange(id)
     {
     if(id=='enam')
     {
     document.getElementById('enam').style.backgroundColor="#1253a2";
     document.getElementById('enam').style.border="1px solid #1253a2";
     }  
     
      if(id=='asset')
     {
     document.getElementById('asset').style.backgroundColor="#1253a2";
    
    document.getElementById('asset').style.border="1px solid #1253a2";
     }  
     
      if(id=='asset1')
     {
     document.getElementById('asset1').style.backgroundColor="#1253a2";
     document.getElementById('asset1').style.border="1px solid #1253a2";
     }
         
     }
     
     
     
     
     function colorchange1(id)
     {
     
      if(id=='enam')
     {
     document.getElementById('enam').style.backgroundColor="white";
     document.getElementById('enam').style.border="1px solid #d1d3d4";
     }
     
      if(id=='asset')
     {
     document.getElementById('asset').style.backgroundColor="white";
     document.getElementById('asset').style.border="1px solid #d1d3d4";
     }
       
        if(id=='asset1')
     {
     document.getElementById('asset1').style.backgroundColor="white";
      document.getElementById('asset1').style.border="1px solid #d1d3d4";
     }
       
     }
     
         
   
/**************************For fade in fade out in menu*******************************/    


var speed = 10; // milliseconds between each step of transition
var steps = 20; // amount to + or - by each step of transition
var fadeToText = "1253a2"; // color for text to fade to
var fadeToCell = "ffffff"; // color for cell to fade to
var origText = "58595b"; // original text color
var origCell = "d1d3d4"; // original cell color
var newBorder = "ffffff"; // border hover color
var origBorder = "ffffff"; // original border color

dC21 = new Array(hextodec(origText.substring(0, 2)),hextodec(origText.substring(2, 4)),hextodec(origText.substring(4, 6)));
dC22 = new Array(hextodec(fadeToText.substring(0, 2)),hextodec(fadeToText.substring(2, 4)),hextodec(fadeToText.substring(4, 6)));


function makearray(n) {
  this.length = n;
  for(var i = 1; i <= n; i++)
    this[i] = 0;
  return this;
}
function hex(i) {
  if (i < 0)    return "00";
  else if (i > 255) return "ff";
  else      return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function hexnumtodec(hexchar) {
  if (parseInt(hexchar) == hexchar) return Number(hexchar)
  hexchar = hexchar.toUpperCase()
  switch (hexchar) {
    case 'A': return 10; break;
    case 'B': return 11; break;
    case 'C': return 12; break;
    case 'D': return 13; break;
    case 'E': return 14; break;
    case 'F': return 15; break;
  }
}
function hextodec(daHex) {
  var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
  return daDec
}



mode = true;

function setColor(r,g,b,what) {
  var hr = hex(r); var hg = hex(g); var hb = hex(b);
  var daColor = "#"+hr+hg+hb
  if(mode){
           daEl.style.backgroundColor = daColor;
           mode = false;
  }
  else{
          if(dC21[0] < dC22[0]) dC21[0] += step;
          if(dC21[0] > dC22[0]) dC21[0] -= step;
          if(dC21[1] < dC22[1]) dC21[1] += step;
          if(dC21[1] > dC22[1]) dC21[1] -= step;
          if(dC21[2] < dC22[2]) dC21[2] += step;
          if(dC21[2] > dC22[2]) dC21[2] -= step;
          dC2B = "RGB(" + dC21[0] + "," + dC21[1] + "," + dC21[2] + ")";
          daEl.style.color = dC2B;
          mode = true;
  }       
  if (daColor == colorend.toLowerCase()) {
    dC21[0] = hextodec(origText.substring(0, 2));
    dC21[1] = hextodec(origText.substring(2, 4));
    dC21[2] = hextodec(origText.substring(4, 6));
    dC2B = "RGB(" + dC22[0] + "," + dC22[1] + "," + dC22[2] + ")";
    daEl.style.color = dC2B;
    clearInterval(iId)
    iId = null
    timerRunning = false
    mode = true
  }
}

function fade(what) {
  i++
  setColor(
    Math.floor(sr * ((step-i)/step) + er * (i/step)),
    Math.floor(sg * ((step-i)/step) + eg * (i/step)),
    Math.floor(sb * ((step-i)/step) + eb * (i/step)),
    what);
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
  hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

var i
var iId = null
var sr, sg, sb
var er, eg, eb
var interval = 1
var step = 16
var colorstart
var colorend
var daEl
var timerRunning = false

function myfade(el,cs,ce,iv,st) {
  daEl = el
  colorstart = cs
  colorend = ce
  interval = iv
  step = st
  i = 0
  if (timerRunning) {
    clearInterval(iId)
    iId = null
  }
  var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i
  if (colorstart.match(myRe)) {
    sr = hextodec(RegExp.$1)
    sg = hextodec(RegExp.$2)
    sb = hextodec(RegExp.$3)
  }
  if (colorend.match(myRe)) {
    er = hextodec(RegExp.$1)
    eg = hextodec(RegExp.$2)
    eb = hextodec(RegExp.$3)
  }
  timerRunning = false;
  iId = setInterval("fade()",interval)
  timerRunning = true;
}
function orig(tc){
         dC21[0] = hextodec(origText.substring(0, 2));
         dC21[1] = hextodec(origText.substring(2, 4));
         dC21[2] = hextodec(origText.substring(4, 6));
         tc.style.backgroundColor = "#" + fadeToCell;
         tc.style.borderColor = "#" + origBorder;
         tc.style.color = "#" + origText;
}
function cellover1(tc) {
  orig(tc);
  colorNow = "#" + origCell;
  colorTo = "#" + fadeToCell;
  myfade(tc,colorNow,colorTo,speed,steps)
  tc.style.borderColor = "#" + newBorder;
}
function cellout1(tc) {
  clearInterval(iId)
  tc.style.borderColor = "#" + origBorder;
  orig(tc);
}

