var colorValue;

function mediumFontSize()
{
	var titleOfActiveStyle = getActiveStyleSheet("fontsize");
	setActiveStyleSheet("Size:12pt","fontsize");
}


function decreaseFontSize()
    {  

     var titleOfActiveStyle = getActiveStyleSheet("fontsize");
     if(titleOfActiveStyle == null) 
     titleOfActiveStyle = "Size:12pt";
  
     if(titleOfActiveStyle == "Size:13pt")
      setActiveStyleSheet("Size:12pt","fontsize");
     if(titleOfActiveStyle == "Size:12pt")
      setActiveStyleSheet("Size:11pt","fontsize");
      /*To set the LeftFrame*/
    }
function increaseFontSize()
     {
      var titleOfActiveStyle = getActiveStyleSheet("fontsize");
      if(titleOfActiveStyle == null) 
       titleOfActiveStyle = "Size:12pt"; 
       
       if(titleOfActiveStyle == "Size:12pt")
       setActiveStyleSheet("Size:13pt","fontsize");
       if(titleOfActiveStyle == "Size:11pt")
       setActiveStyleSheet("Size:12pt","fontsize");
       /*To set the LeftFrame*/
     }


function setActiveStyleSheet(title,type) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && isStyleSheetType(a.getAttribute("title"),type)) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function isStyleSheetType(str,type) {
  if      (str == "")                             { return true; }
  else if (type == "fontsize" && str.match(/^Size/))    {return true;}
  else if (type == "weight" && str.match(/\Font/))    {return true;}
  else if (type == "contrast" && str.match(/^Back/))    {return true;}
  
  return false;

}

function getActiveStyleSheet(type) {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && isStyleSheetType(a.getAttribute("title"),type) && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
/*Dynamic color*/
function swapColor(setColor)
{
   setActiveColor(setColor,"color");
   createCookie("color",setColor, 365);
}
function getActiveColor(colortype) {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && isStyleColor(a.getAttribute("title"),type) && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
function setActiveColor(setColor,colortype) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && isStyleColor(a.getAttribute("title"),colortype)) {
      a.disabled = true;
      if(a.getAttribute("title") == setColor) a.disabled = false;
    }
  }
}
function isStyleColor(colorStr,colortype) {
  if      (colorStr == "")        { return true; }
  else if (colortype == "color" && colorStr.match(/^Color/))  {return true;}
 
  return false;

}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function delCookie(name,path) 
{ 
	if (getCookie(name)) 
  	{ 
		document.cookie = name + "=" +
    		((path == null) ? "" : "; path=" + path)  +
   	 	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
 	 }
    
}

function getCookie(name)
{ var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) 
  { begin = dc.indexOf(cname);       
    if (begin != -1) 
    { begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function topNavHeading() {
	var loc=location.toString();
	var ul= document.getElementById('hor-nav');
	var li=ul.getElementsByTagName('li');

	var StrArr = loc.split("/");
	var StrPageName = StrArr[3];
	
	if(StrPageName == "index.html")
	{
		li[0].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">A</span>bouts</a>";
	}
	else if(StrPageName == "interior_exterior.html")
	{
		li[1].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">I</span>nterior/Exterior</a>";
	}
	else if(StrPageName == "constructions.html")
	{
		li[2].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">C</span>onstruction</a>";
	}
	else if(StrPageName == "products.html")
	{
		li[3].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">P</span>roducts</a>";
	}
	else if(StrPageName == "gallery.html")
	{
		li[4].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">G</span>allery</a>";
	}
	else if(StrPageName == "contactus.php" || StrPageName == "contactus.php?Status=Send")
	{
		li[5].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">C</span>ontact Us</a>";
	}
	else
	{
		li[0].getElementsByTagName('a')[0].innerHTML="<span class=\"colors\">A</span>bouts</a>";
	}
}

 window.onload = function(e) {

	
 var title = ""
 var cookie = readCookie("style");
 var title = cookie ? cookie : getPreferredStyleSheet();
 setActiveStyleSheet(title,"fontsize");
 var colorCookie =  readCookie("color");
 if(colorCookie==null) {
	 createCookie("color","Color:brown", 365);
 }
 else {
	swapColor(colorCookie);
 }
 topNavHeading();
 		
}
 
window.onunload = function(e) {

 var title = getActiveStyleSheet("fontsize");
 createCookie("style", title, 365);

}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title,"fontsize");


