// JavaScript Document
function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}
ddtabcontent.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}
function intiateTab(){

	document.getElementById('faqDiv').getElementsByTagName("div")[0].style.display="block";
}
function expandTabs(tab){
    
	if (tab == null)
	{
	    return;
	}
	var divs=document.getElementById('faqDiv').getElementsByTagName("div");	
	for(var i=0; i<divs.length; i++)
	{
		divs[i].style.display="none";	
	}
	
	document.getElementById(tab).style.display="block";
}
ddtabcontent.prototype={
	
	init:function(){
		var tabs= document.getElementById('faqDiv').getElementsByTagName('a');
		var divs=document.getElementById('faqDiv').getElementsByTagName("div");	
		intiateTab();
		expandTabs(tabs[0].getAttribute("rel"));
		expandTabs('applist');				
		
		for(var i=0; i<tabs.length; i++){
			tabs[i].onclick=function(){					
					if(this.getAttribute("rel") != ""){
						ddtabcontent.setCookie("tab", this.getAttribute("rel"));
						expandTabs(this.getAttribute("rel"));
					}
				}
			}
	}

} //END Prototype assignment


function adjustFontSize(inc)
{
        var old = GetFontSize();
        incrementFontSize(0-old);
        incrementFontSize(inc);
}
function incrementFontSize(inc)
{


      var heading = document.getElementsByTagName('h5');
        for(n=0; n<heading.length; n++) 
        {
          if(heading[n].style.fontSize) 
          {
            var size = parseInt(heading[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           heading[n].style.fontSize = size+ 'px';
        }


       
        var p = document.getElementsByTagName('p');
        for(n=0; n<p.length; n++) 
        {
          if(p[n].style.fontSize) 
          {
            var size = parseInt(p[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           p[n].style.fontSize = size+ 'px';
        }
        
        var a = document.getElementsByTagName('a');
        var i = 0;
        for(n=0; n<a.length; n++) 
        {
          if (a[n].className != "doNotChangeFont")
          {
              if(a[n].style.fontSize) 
              {
                var size = parseInt(a[n].style.fontSize.replace("px", ""));
              } 
              else 
              {
                var size = 12;
                
               }
               size = size + parseInt(inc);
               
               a[n].style.fontSize = size+ 'px';
           }
        }
        
        var Li = document.getElementsByTagName('li');
        for(n=0; n<Li.length; n++) 
        {
           if(Li[n].style.fontSize) 
          {
            var size = parseInt(Li[n].style.fontSize.replace("px", ""));
          } 
           else 
          {
          

             var size = 12;
            
           }
           size = size + parseInt(inc);
           
           Li[n].style.fontSize = size+ 'px';
        }
        
        var s = document.getElementsByTagName('span');
         
        for(n=0; n<s.length; n++) 
        {
           if(s[n].style.fontSize) 
          {
            var size = parseInt(s[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           s[n].style.fontSize = size+ 'px';
        }
        
        var l = document.getElementsByTagName('label');
         
        for(n=0; n<l.length; n++) 
        {
            if(l[n].style.fontSize) 
          {
            var size = parseInt(l[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
          l[n].style.fontSize = size+ 'px';
        }
        
        var td = document.getElementsByTagName('td');
         
        for(n=0; n<td.length; n++) 
        {
            if(td[n].style.fontSize) 
          {
            var size = parseInt(td[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           td[n].style.fontSize = size+ 'px';
        }
        
        var bold = document.getElementsByTagName('b');
         
        for(n=0; n<bold.length; n++) 
        {
           if(bold[n].style.fontSize) 
          {
            var size = parseInt(bold[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           bold[n].style.fontSize = size+ 'px';
        }
        
         var List = document.getElementsByTagName('ul');
         
        for(n=0; n<List.length; n++) 
        {
           if(List[n].style.fontSize) 
          {
            var size = parseInt(List[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           List[n].style.fontSize = size+ 'px';
        }
        
        
        
        SaveFontSize(inc);
}
//-----Ramesh ----//

function SetFont()
{
       var i = 0;
       var inc = 12
       inc = GetFontSize();
        
       var heading = document.getElementsByTagName('h5');
       
        for(n=0; n<heading.length; n++) 
        {
          
          if(heading[n].style.fontSize) 
          {
            var size = parseInt(heading[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;            
          }
                    
           
            size = size + parseInt(inc);
             if(heading[n].id == "changeFont" && inc == "0")
             {
               heading[n].style.fontSize = 11+ 'px';
             }
             else
             {
              heading[n].style.fontSize = size+ 'px';
             } 
        }

        var p = document.getElementsByTagName('p');
        for(n=0; n<p.length; n++) 
        {
          if(p[n].style.fontSize) 
          {
            var size = parseInt(p[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           
             size = size + parseInt(inc);
             if(p[n].id == "newFont" && inc == "0")
             {
               p[n].style.fontSize = 11+ 'px';
             }
             else
             {
              p[n].style.fontSize = size+ 'px';
             } 
        }
        
        var a = document.getElementsByTagName('a');
        var i = 0;
        
        for(n=0; n<a.length; n++) 
        {
          if (a[n].className != "doNotChangeFont")
          {
              if(a[n].style.fontSize) 
              {
                var size = parseInt(a[n].style.fontSize.replace("px", ""));            
              } 
              else 
              {
                 var size = 12;
              }
              size = size + parseInt(inc);
              if(a[n].id == "Font" && inc == "0")
              {
                   a[n].style.fontSize = 11+ 'px';
              }
              else if (a[n].id == "changeFont" && inc == "0")
              {
                   a[n].style.fontSize = 24+ 'px';                
              }
              else 
              {
                   a[n].style.fontSize = size+ 'px';
              } 
          }        
        }        

        var s = document.getElementsByTagName('span');
         
        for(n=0; n<s.length; n++) 
        {
           if(s[n].style.fontSize) 
          {
            var size = parseInt(s[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
             size = size + parseInt(inc);
             if(s[n].id == "newFont" && inc == "0")
             {
               s[n].style.fontSize = 11+ 'px';
             }
             else
             {
              s[n].style.fontSize = size+ 'px';
             } 
        }
        
        var l = document.getElementsByTagName('label');
         
        for(n=0; n<l.length; n++) 
        {
            if(l[n].style.fontSize) 
          {
            var size = parseInt(l[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           l[n].style.fontSize = size+ 'px';
        }
        
        var td = document.getElementsByTagName('td');
         
        for(n=0; n<td.length; n++) 
        {
            if(td[n].style.fontSize) 
          {
            var size = parseInt(td[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           td[n].style.fontSize = size+ 'px';
        }
        
        var bold = document.getElementsByTagName('b');
         
        for(n=0; n<bold.length; n++) 
        {
           if(bold[n].style.fontSize) 
          {
            var size = parseInt(bold[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           bold[n].style.fontSize = size+ 'px';
        }
        
        var List = document.getElementsByTagName('ul');
        for(n=0; n<List.length; n++) 
        {
           if(List[n].style.fontSize) 
          {
            var size = parseInt(List[n].style.fontSize.replace("px", ""));
          } 
          else 
          {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           List[n].style.fontSize = size+ 'px';
        }
        
        
        var Li = document.getElementsByTagName('li');
        for(n=0; n<Li.length; n++) 
        {
           if(Li[n].style.fontSize) 
          {
            var size = parseInt(Li[n].style.fontSize.replace("px", ""));
          } 
            else 
           {
            var size = 12;
            
           }
           size = size + parseInt(inc);
           
           Li[n].style.fontSize = size+ 'px';
        }
        
        AppendQueryStringForSecondaryDevices();
        SaveFontSize(inc);
        
        
}

function AppendQueryStringForSecondaryDevices()
{
    
    var href, subString;
    var anchors = document.getElementsByTagName("a");
    var windowLocation = window.location;
    // Check if the current version of the site is for secondary devices.
    if (windowLocation.href.indexOf("?p=2") > 0)
    {
        for (counter =0; counter < anchors.length; counter++)
        {
              // Consider only those anchors that are internal links. Meaning they have the same host as the window.location. Further check if the Urls already have a query strng.
              if (windowLocation.hostname == anchors[counter].hostname && anchors[counter].href.indexOf("?p=2") <= 0)
              {
                  // Next check if the anchors already have a query string. If so append the querystring with an "&" 
                  if (anchors[counter].href.indexOf("?") > 0 )
                  {
                        // secondary devices would not work if p=2 is not the first querystring. So
                        var split = anchors[counter].href.split("?");
                        anchors[counter].href = split[0] + "?p=2" + "&?" + split[1];                        
                  }
                  else
                  {
                        anchors[counter].href = anchors[counter].href + "?p=2";
                  }  
              }              
        }
    }
   
}

function wOpen()
{
 window.location.href('contactus.aspx');
}


function SaveFontSize(inc) 
{
    CreateCookie("myappfont", inc, 365, false);
}
function GetFontSize() 
{
    return getCookie("myappfont");
}
//end colour picker
function CreateCookie(name,value,days,useLang) 
{

  var langString = useLang ? GetLang() : "";

  var cookie = name + langString + "=" + value + ";";

  if (days) 
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    cookie += " expires=" + date.toGMTString() + ";";
  }
  cookie += " path=/";
  document.cookie = cookie;
}

function GetLang()
{
  var langString = "";

  if (document.documentElement){
    langString = document.documentElement.lang;
    if (langString != ""){
      langString = "-" + langString;
    }
  }  
  return langString;
}

function getCookie(name)
{
if (document.cookie.length>0)
  {
  var c_start=document.cookie.indexOf(name + "=");
  if (c_start!=-1)
    { 
      c_start=c_start + name.length+1; 
      c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
      return document.cookie.substring(c_start,c_end);
    } 
  }
return 0;
}