function setActiveStyleSheeteyeway(txtsizetitle,bgtitle,fonttitle, reset) 
{   
    var i, a, main;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
    {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))
        { 
            if (a.getAttribute("title")==txtsizetitle || a.getAttribute("title")==bgtitle || a.getAttribute("title")==fonttitle)
            {
              a.disabled = false;   
            }
        }
    }
    if (reset == 1)
    {
        createCookie("wstyle", txtsizetitle, 365,path='/live/eyeway/');
        createCookie("xstyle", bgtitle, 365,path='/live/eyeway/');
        createCookie("ystyle", fonttitle, 365,path='/live/eyeway/');
    }
}





function mycreateCookie(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+"="+escape(value)+expires+"; path=/live/eyeway/;";
    
};


function setCookie(c_name,value,expiredays,path)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/live/eyeway/;";

}



function disablegraphics(chkvar)
{
x=document.getElementsByTagName('style');
for(j=0;j<x.length;j++)
   { 
       x[j].disabled=true;
   }
x=document.getElementsByTagName('link');
for(j=0;j<x.length;j++)
   { 
       x[j].disabled=true;
   }
if (chkvar=='1')
  {
  mycreateCookie('graphicscookie','1',365);
  }
}


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1)
       c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}




function checkCookie()
{
graphicscookie=getCookie('graphicscookie');

if (graphicscookie=="1")
{
   disablegraphics('2');
}


var tagarray=new Array();
tagarray[0]="input";
tagarray[1]="textarea";
tagarray[2]="iframe"; 
tagarray[3]="body"; 
for(j=0;j<tagarray.length;j++)
{
 var d= document.getElementsByTagName(tagarray[j]);

for(i=0;i<d.length;i++)
{
  if(tagarray[j]=='input')
  {
   if(d[i].type=='text')
   {
     var text1= d[i].name;
   }
   if(d[i].type!='text')
   {
     var text1= d[i].value;
   }

  }

  if(tagarray[j]=='textarea')
  {
    var text1= d[i].name;
    /*if(d[i].class='kupu-editor-textarea')
    {text1=d[i].class;}*/
  }
  if(tagarray[j]=='iframe')
  {
    var text1= "Other Details/Body";
    
  }
  
   if(d[i].type!='hidden')
   {
    d[i].setAttribute("title",text1);
    d[i].setAttribute("alt",text1);
  }

}
}
}
function checkCookie2()
{

style1=getCookie('wstyle');
style2=getCookie('xstyle');
style3=getCookie('ystyle');
    if (style1 != null || style2 != null || style3 != null)
    {
      setActiveStyleSheeteyeway(txtsizetitle=style1,bgtitle=style2,fonttitle=style3, reset=0);
    }
 
}




function playCaptcha() {
        document.getElementById('code_entered_by_user').focus();
	var wavURL = document.getElementById('audiolinkurl').value;
        var embedCode = '<EMBED SRC=' + wavURL + ' HIDDEN="true" AUTOSTART="true" >';
	document.getElementById("playAudio").innerHTML = "";
	document.getElementById("playAudio").innerHTML = embedCode;
        
}


function changecss(theClass,element,value) {

var cssRules;
if (document.all) {
 
cssRules = 'rules';
}
else if (document.getElementById) {
cssRules = 'cssRules';
}
for (var S = 0; S < document.styleSheets.length; S++)
{
  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) 
  { 
    if (document.styleSheets[S][cssRules][R].selectorText == theClass) 
    {  document.styleSheets[S][cssRules][R].style[element] = value;
    }
  }
}
} 


function firstselect(thisob)
{
  if(thisob.options[thisob.selectedIndex].value=='helpdesk')
  {
   document.getElementById('helpdesk').style.visibility='visible';
   document.getElementById('inor').style.visibility='visible';
     addOption(document.selectreportform.inor, "City","city");
     addOption(document.selectreportform.inor, "State","mystate");
     addOption(document.selectreportform.inor, "Country","country");
     addOption(document.selectreportform.inor, "Gender","gender");
     addOption(document.selectreportform.inor, "Age","age");
     addOption(document.selectreportform.inor, "Occupation","c1");
     addOption(document.selectreportform.inor, "Marital Status","marital");
     addOption(document.selectreportform.inor, "How did you come to..","c2");
     addOption(document.selectreportform.inor, "EyeProblem","eyeprob");

   document.getElementById('donation').style.visibility='hidden';
   document.getElementById('volunteer').style.visibility='hidden';
   document.getElementById('others').style.visibility='hidden';
  }
  else
  {
   document.getElementById('helpdesk').style.visibility='hidden';
   if(thisob.options[thisob.selectedIndex].value=='donation')
   {  
       removeOptions(document.selectreportform.inor);
       addOption(document.selectreportform.inor, "Prefered mode of Donation","mode");
       addOption(document.selectreportform.inor, "How did you come to..","c2");
       
   }
   if(thisob.options[thisob.selectedIndex].value=='volunteer')
   {
       removeOptions(document.selectreportform.inor);
       addOption(document.selectreportform.inor, "City","city");
       addOption(document.selectreportform.inor, "State","mystate");
       addOption(document.selectreportform.inor, "Country","country");
       addOption(document.selectreportform.inor, "Education","education");
       addOption(document.selectreportform.inor, "How did you come to..","c2");
   }
   if(thisob.options[thisob.selectedIndex].value=='others')
   {
       removeOptions(document.selectreportform.inor);
       addOption(document.selectreportform.inor, "City","city");
       addOption(document.selectreportform.inor, "State","mystate");
       addOption(document.selectreportform.inor, "Country","country");
       addOption(document.selectreportform.inor, "How did you come to..","c2");
   }
  }
}


function secondselect(thisob)
{ removeOptions(document.selectreportform.inor);
  if(thisob.options[thisob.selectedIndex].value=='individual')
  {
     addOption(document.selectreportform.inor, "City","city");
     addOption(document.selectreportform.inor, "State","mystate");
     addOption(document.selectreportform.inor, "Country","country");
     addOption(document.selectreportform.inor, "Gender","gender");
     addOption(document.selectreportform.inor, "Age","age");
     addOption(document.selectreportform.inor, "Occupation","c1");
     addOption(document.selectreportform.inor, "Marital Status","marital");
     addOption(document.selectreportform.inor, "How did you come to..","c2");
     addOption(document.selectreportform.inor, "EyeProblem","eyeprob");
  }
  else
  {  
     addOption(document.selectreportform.inor, "Designation","desig");
     addOption(document.selectreportform.inor, "City","city");
     addOption(document.selectreportform.inor, "State","mystate");
     addOption(document.selectreportform.inor, "Country","country");
     addOption(document.selectreportform.inor, "How did you come to..","c2");
  }
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

function removeOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
