<!--

function urlencode( str ) {
    var histogram = {}, unicodeStr='', hexEscStr='';
    var ret = (str+'').toString();

    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };

    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF';
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';

    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);

    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr];
        ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
    }

    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
}//end function url encode
function priting() {
   document.getElementById('prt_id').style.visibility = 'visible';
   document.getElementById('prt_id').style.display = '';
   document.getElementById('body').style.visibility = 'hidden';
   window.print();
   document.getElementById('body').style.visibility = '';
   //document.getElementById('prt_id').style.visibility = 'hidden';
   //document.getElementById('prt_id').style.display = 'none';
}

function showdiv(id) {
   var div_id = "drop"+id;
   //alert(div_id);

  // document.getElementById("menu").style.height = "85px";
   document.getElementById(div_id).style.top = "90%";
  // document.getElementById("drop"+menu_id).style.visibility = "visible";
}

function hidediv(id) {
   var div_id = "drop"+id;
   //alert(div_id);

   //document.getElementById("menu").style.height = "59px";
   document.getElementById(div_id).style.top = "0%";
}
//----------------------------------End edit----------------------------------------//
  
function openWin(winURL,winWidth,winHeight,winName) { 
     var leftPos  =  (screen.width-winWidth)/2;
     var topPos   =  (screen.height-winHeight)/2;
     window.open(winURL,winName,'width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0') ; 
}// open a new window

function pop_win(winURL,winName,winWidth,winHeight,sb,rs) { 
   var leftPos =  (screen.width-winWidth)/2;
   var topPos  =  (screen.height-winHeight)/2;
     window.open(winURL,winName,'width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars='+sb+',resizable='+rs) ; 
}// pop up window
  
function clearDefault(thefield){
   var thefield = document.getElementById(thefield);

   if (thefield.defaultValue==thefield.value){
      thefield.value = "";
      thefield.focus();
   }//endif
}//If a field has a default it is empty after text entered
  
function textCounter(field,counter,maxlimit,linecounter) {
   var field      =  document.getElementById(field);
   var fieldWidth =  parseInt(field.offsetWidth);
   var charcnt    = field.value.length;

   // trim the extra text
   if (charcnt > maxlimit) { 
      field.value = field.value.substring(0, maxlimit);
   } 
   else { 
   // progress bar percentage
   var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
   document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
   document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
   // color correction on style from CCFFF -> CC0000
   setcolor(document.getElementById(counter),percentage,"background-color");
   }
}

function setcolor(obj,percentage,prop){
   obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
   // ADD <div id="progressbar1" class="progress"></div>
   //<textarea name="profile" id="profile" cols="55" rows="5" onKeyDown="textCounter(this,'progressbar1',600)" ><?php echo $profile; ?></textarea>
   /*.progress{
      width: 1px;
      height: 14px;
      color: white;
      font-size: 12px;
       overflow: hidden;
      background-color: FF0000;
      padding-left: 5px;
   }   */
  // forwardbar function end
function isValidEmail(email) {
var error = 0;
     AtPos = email.indexOf("@")
     StopPos = email.lastIndexOf(".")
     if (email == "") {
             error = 1;
     }
     if (AtPos == -1 || StopPos == -1) {
             error = 1;
     }
     if (StopPos < AtPos) {
             error = 1;
     }
     if (StopPos - AtPos == 1) {
             error = 1;
     }
     if (error == 1) {return false;} else {return true;}
} // email chking function called

function checkEmail(email) {
var str = "";
     if (!isValidEmail(document.getElementById(email).value)) {
        str = str + 'Invalid email address supplied for '+ email+'<br/> \r\n';
     }
     return str;
}// chk if it is a valid email and calls the funstion to chk if it is an email

//empty field check
function required(formobj,array_name, array_name_desc) {
   // Enter name of mandatory fields
   var fieldRequired = array_name;
   // Enter field description to appear in the dialog box
   var fieldDescription = array_name_desc;
   // dialog message
   var alertMsg = "Please complete the following fields:<br/> \r\n";
   
   var l_Msg = alertMsg.length;
   
   for (var i = 0; i < fieldRequired.length; i++){
      //alert(fieldRequired[i]);
      //var obj = formobj.elements[fieldRequired[i]];
      var obj = document.getElementById(fieldRequired[i]);
      if (obj){
         switch(obj.type){
         case "select-one":
            if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
               alertMsg += " - " + fieldDescription[i] + "<br/>  \r\n";
            }//endif
            break;
         case "select-multiple":
            if (obj.selectedIndex == -1){
               alertMsg += " - " + fieldDescription[i] + "<br/> \r\n";
            }//endif
            break;
         case "text":
         case "textarea":
            if (obj.value == "" || obj.value == null){
               alertMsg += " - " + fieldDescription[i] + "<br/> \r\n";
            }//endif
            break;
         default:
         }//endSwitch
         if (obj.type == undefined){
            var blnchecked = false;
            for (var j = 0; j < obj.length; j++){
               if (obj[j].checked){
                  blnchecked = true;
               }//endif
            }//endofor
            if (!blnchecked){
               alertMsg += " - " + fieldDescription[i] + "\<br/> \r\n ";
            }//endif
         }//endif
      }//endif obj
   }//endfor

   if (alertMsg.length == l_Msg){
      return '';
   }else{      
      return alertMsg;
   }
}//end function
//end empty field chk
//Default value for field and change class  
//var setCnt = 0; 
function default_value(field) {
 var f_name = document.getElementById(field);
   if (f_name.defaultValue==f_name.value) {
      f_name.value='';
      f_name.focus();
      f_name.className='myfont';
   }//if end
}//end function

//min char
function checkLength(name,leng, defl) {
   var field = document.getElementById(name);
   var msg = '';
   if (field.value.length < leng || field.value == defl ) {
      msg = 'Please enter at least the first three letters of the '+field+'<br/>  \r\n';
   }//end if
   return msg;
}//end function

// Checks for password corectness
function checkPw(name, valueChk) {
   var pw1 = document.getElementById(name).value;   
   var msg = '';

   if (isset(valueChk)) pw2 = valueChk;
   else var pw2 = document.getElementById('passConfirm').value;
   if (pw1 != pw2) {
      msg   = "Please re-enter your "+name+". \r\n";
   }
   return msg;
}//end function

// Submit count, check that only one is submited
var submitcount=0;
function submitChk(){
   if (submitcount == 0)      {
         submitcount++;
         return '';
      } else {
         return "This form has already been submitted.  Thanks!<br/> \r\n";
         
      }
}//end function

function print_open(strOpen) {
   //alert(strOpen);
   W = screen.availWidth
   H = (screen.availHeight - 20)
   if (W > 1024) {                   
      W = 1024
   }
   if (H > 740) {
      H = 740
   }
   if (screen.availWidth > 1024) {
      X = Math.ceil((screen.Width-W)/2);
      Y = (Math.ceil((screen.Height-H)/2) - 10);
   } else {
      X = 0;
      Y = 0;
   }
     
   //strOpen = "print_page.php";  
   var strTitle = 'Print_Page';
   strOptions = "fullscreen=0, scrollbars=1";
   var CWIN = window.open(strOpen, strTitle, strOptions);
   CWIN.resizeTo(W,H);
   CWIN.moveTo(X,Y);
   CWIN.focus();       
   //window.open(strOpen,strTitle,'width='+W+',height='+H+',left='+X+',top='+Y+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0') ; 
}//end function



function select_all(chk, sel, max,max2) {
   var sel = document.getElementById(sel);
   if(!isset(max2)) max2 = '';
   if (max2=='') {
      for (i=0; i<max; i++)
      //alert(chk +' name, '+ sel +' this, '+ max +' number');
      if(sel.checked) document.getElementById(chk+i).checked = true;
      else document.getElementById(chk+i).checked = false;
   }else{
      //alert(max2);
      max += max2;
      for (i=max2; i<max; i++)      
      if(sel.checked) document.getElementById(chk+i).checked = true;
      else document.getElementById(chk+i).checked = false;
   }
}//end function

function select_all2(chk, sel, max,max2) {
   var sel = document.getElementById(sel);
      for (i=0; i<max; i++) {      
         if(sel.checked) {
            document.getElementById(chk+i).checked = true;
            for (a=0; a<max2; a++) if (document.getElementById('type_opt2_'+a)!=null) document.getElementById('type_opt2_'+a).checked = true;
         } else {
            document.getElementById(chk+i).checked = false;
            for (a=0; a<max2; a++) if (document.getElementById('type_opt2_'+a)!=null) document.getElementById('type_opt2_'+a).checked = false;
         }
      }

}
function select_all_final(sel, min,max,sub_chk) {
      for (i=min; i<max; i++) {      
         if(sel.checked) {
            document.getElementById(sub_chk+i).checked = true;            
         } else {
            document.getElementById(sub_chk+i).checked = false;            
         }
      }

}

function value_chk(max, label, filed) {
   var y = 0;
   for(i=0;i<max;i++) if(document.getElementById(label+i).checked == true) y=1;
   if( y==0) {
      document.getElementById('msg').innerHTML  = 'No values has been selected for the required search' ;
      //document.getElementById('msg2').innerHTML  = 'No values has been selected for the required search' ;
      return false;
   }
}

function default_value(field,deflt) {
 var f_name = document.getElementById(field);
 if (!isset(deflt)) deflt = f_name.defaultValue;
   if (deflt==f_name.value) {
      f_name.value='';
      f_name.focus();
      //f_name.className='myfont';
      f_name.style.color = '#666666';
   }
}

//--> document.location= '?pg=12&pgm=M&devname='+document.getElementById('devname').value
function goto_location(id,path) {
   var office = document.getElementById(id); 
   if (office.value == -1) {
      return false;
   } else {      
      var moveTo =path + office.value;       
      document.location = moveTo;
   }
}
//---------------------------------AUTOMATIC GO TO JUMP MENU ---------------------------------------//
function go_to_menu(targ,selObj,restore){ //v3.0 
      eval(targ+".location='"+ selObj.options[selObj.selectedIndex].value +"'");
      if (restore) selObj.selectedIndex=0;              
}

function isset() {    
    var a=arguments; var l=a.length; var i=0;
    
    if (l==0) { 
        throw new Error('Empty isset'); 
    }//end if
    
    while (i!=l) {
        if (typeof(a[i])=='undefined' || a[i]===null) { 
            return false; 
        } else { 
            i++; 
        }//endif
    }
    return true;
}//end function

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {
   var x = Math.round(num * Math.pow(10,dec));
   if (x >= 0) n1=n2='';
   var y = (''+Math.abs(x)).split('');
   var z = y.length - dec; if (z<0) z--; 
   for(var i = z; i < 0; i++) y.unshift('0'); 
   if (z<0) z = 1; 
   y.splice(z, 0, pnt); 
   if(y[0] == pnt) y.unshift('0'); 
   while (z > 3) {z-=3; y.splice(z,0,thou);}
   var r = curr1+n1+y.join('')+n2+curr2;
   return r;
   //formatNumber(mynum,2,' ','.','','','-','');   formatNumber(trsf,2,',','.','R ','','-','CR')
}

function submitForm(elementId, browser, frm) {
   
   if(browser=='IE') document.forms[elementId].submit();
   else document.getElementById(elementId).submit();

}
function forgot_login(elementId, field){
   $(field).value = 2;
   document.forms[elementId].submit();
}
function creatField(id, type, js){
   field = document.createElement('input');
   field.value = '';
   field.id    = id;
   field.type  = type;
   field.name  = id;
   field.onblur= 'this.select()';
   field.onfocus= js;
   //field.size  = '';
   document.getElementById('insert_image').appendChild(image);
}

function getHtmlPosition(obj, all,type){
    var topValue= 0,leftValue= 0;
    if (all==true){
       while(obj){
         leftValue+= obj.offsetLeft;
         topValue+= obj.offsetTop;
         obj= obj.offsetParent;
       }
    } else {
       leftValue= obj.offsetLeft;
       topValue = obj.offsetTop;
    }
    if (type=='x') return parseInt(leftValue);
    else return parseInt(topValue);
}

//==========================================get mouse position=========================================//
function startPosition(set){

   if(set){
      if (!$(set).all) $(set).captureEvents(Event.MOUSEMOVE)
      $(set).onmousemove = getPosition2;
   }else{
      if (!document.all) document.captureEvents(Event.MOUSEMOVE)
      document.onmousemove = getPosition;
   }
   

}
function getPosition2(args) {
  // Gets IE browser position


  if ($(args).all)   {
    X = event.clientX + $(args).body.scrollLeft
    Y = event.clientY + $(args).body.scrollTop
  }
  // Gets position for other browsers
  else
  {
    X = args.pageX
    Y = args.pageY
  }
}
var X = 0;
var Y = 0;
function getPosition(args) {
  // Gets IE browser position


  if (document.all)   {
    X = event.clientX + document.body.scrollLeft
    Y = event.clientY + document.body.scrollTop
  }
  // Gets position for other browsers
  else
  {
    X = args.pageX
    Y = args.pageY
  } 
}
//disable background
function alterDivDisplay(divName, setPosition, x, y) {
   var div = $(divName);
   if(!isset(x)) x=0; if(!isset(y)) y=0;
   if(div.style.display== '' && div.offsetWidth != undefined && div.offsetHeight != undefined) {

        div.style.display = (div.offsetWidth!=0 && div.offsetHeight!=0)?'block':'none';
    }
    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block';
    if (setPosition==true){
       div.style.left = X+x+'px';
       div.style.top  = Y+y+'px';
    }
    if (setPosition=='custom'){
       div.style.left = x+'px';
       div.style.top  = y+'px';
    }
//div.style.display='block';
}
function alterDivDisplay2(divName, setPosition, x, y) {
   var div = $(divName);
   if(!isset(x)) x=0; if(!isset(y)) y=0;
   if(div.style.display== '' && div.offsetWidth != undefined && div.offsetHeight != undefined) {

        div.style.display = (div.offsetWidth!=0 && div.offsetHeight!=0)?'block':'none';
    }
    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block';
      getPosition2(setPosition);
      div.style.left = X+x+'px';
      div.style.top  = Y+y+'px';

//div.style.display='block';
}
//popup
function callOut(field, idref, id){
   var option = '?option='+field;
   
   if(isset(idref)) option = '?transaction=insert&option='+field+'&smoke=survey&profile_idref='+idref;
   if(isset(id))    option = '?transaction=select&profile_idref='+idref+'&question_id='+id;
   alterDivDisplay('background_div');
   alterDivDisplay('pop_div');
   requestAjax('pop_div', 'modules/question.php', option);

}
function callOut2(id){
   if(isset(id))    option = '?transaction=select&profile_id='+id;
   alterDivDisplay('background_div');
   alterDivDisplay('pop_div'); 
   requestAjax('pop_div', 'modules/step01_survey.php', option);

}
function popUp(divName) {
    var div = $(divName);

    // if the style.display value is blank we try to check it out here

    if(div.style.display== '' && div.offsetWidth != undefined && div.offsetHeight != undefined) {

        div.style.display = (div.offsetWidth!=0 && elem.offsetHeight!=0)?'block':'none';

    }
    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block';

    X = X + 15;
    div.style.left = X+'px';
    div.style.top = Y+'px'; 
}
function getElementsByClassName2(className, tag){
   var classNameArray = [];alert('one');

        tag = document.getElementsByTagName(tag);
        L   = tag.length;
        while(L){
            temp = tag[--L];
            if(temp.className.indexOf(className)!=-1) classNameArray.push(temp);
        }

    return classNameArray;
}//endfunction
function callImageMaker(element, size) {
   y = document.getElementById(element).value;
   document.getElementById('insert_image'+element).innerHTML = '';
   if (isset(size)) y=size;
      for (x=1;x<=y;x++) {
         image = document.createElement('img');
         image.src = "../images/star-full.png";
         document.getElementById('insert_image'+element).appendChild(image);
      }
}//endif
//

function ranking(name,over,x, txt, max) {
   
   if(over && $(name).value==''){
      for (a=0;a<=x;a++){
         $('rankImg'+name+a).src = 'http://smokesurvey.dev.co.za/images/star-full.png';
      }//end for
   }//endif
   else if (over==false && $(name).value=='') {
      for (a=0;a<=x;a++){
         $('rankImg'+name+a).src = 'http://smokesurvey.dev.co.za/images/star-empty.png';
      }//end for
   }//end elseif
   if (isset(txt)) {
      $$('input[name="'+txt+'"]').each(function(set){set.value = x+1; });
      
      for (a=0;a<=max-1;a++){
         $('rankImg'+name+a).src = 'http://smokesurvey.dev.co.za/images/star-empty.png';
      }//end for
      for (a=0;a<=x;a++){
         $('rankImg'+name+a).src = 'http://smokesurvey.dev.co.za/images/star-full.png';
      }//end for
   }//endif
}
function refresh(id) {
   var params = '?transaction=select&smoke=survey&profile_idref='+id;
   var url    = 'modules/step01_question.php';
   //requestAjax('question_div','"+url+"', '"+params+"');
   $('feel_free2').innerHTML += "<span><br/> Please click <a href='javascript: void(0)' onclick=\"requestAjax('question_div','"+url+"', '"+params+"')\" >here</a> to refresh the page.</span>";
   //$('feel_free3').innerHTML += "<span><br/> Please click <a href='javascript: void(0)' onclick=\"requestAjax('question_div','"+url+"', '"+params+"')\" >here</a> to refresh the page.</span>";
}

//=====================================AJAX===========================================================//


function auto_update(required, form, path, option, params) {
   var err        = 0;   
   if (!isset(option))option='transaction';   
   if (form!=''){
      var inputForm  = $(form);
      var trans      = $(option);
   }//endif
   
   for (x=0; x<required.length; x++) {
      if(!isset($F(required[x]) ) || $F(required[x])=='' ) err++;
   }//end for
   if (err==0) {
      if(form!=''){
         postAjax(path, '', form);
         //$('debug').setStyle({display: 'block'});
         //requestAjax('debug', path, '', form);
      }
      else postAjax(path, params);      
      
      if(form!='') {
         if(trans.value=='insert') {
            trans.value = 'update';
         }//endif
      }//endif
   }//endif
}//endfunction

function auto_update2(form, path, required, params) {
   var err        = 0;

   for (x=0; x<required.length; x++) {
      if(!isset($F(required[x]) ) || $F(required[x])=='' ) err++;
   }//end for
   //alert('path='+path+' form='+form+' err='+err+' params'+params);
   if (err==0) {
      if(form!=''){
         postAjax(path, '', form);
         //$('debug').setStyle({display: 'block'});
         //requestAjax('debug', path, '', form);
      }
      else {
         postAjax(path, params);
         //$('debug').setStyle({display: 'block'});
         //requestAjax('debug', path, params);
      }
      
   }//endif
}//endfunction

function auto_update3(path, params) {
   var err        = 0;
   postAjax(path, params); 
   //$('debug').setStyle({display: 'block'});
   //requestAjax('debug', path, params);
}//endfunction

function auto_update4(path, params) {
   var err        = 0;
   //postAjax(path, params);
   $('debug').setStyle({display: 'block'});
   requestAjax('debug', path, params);
}//endfunction

function callIT() {
   Event.observe(document.body, 'click', function(event) {
      alert('passed1');
         var elt = Event.element(event);
         if ('a' == elt.tagName || 'select' == elt.tagName){
            alert('passed2');
            auto_update2('frm_class', 'modules/program.php', Array('class_name','font_color', 'profile_id'));
         }
      }
   );
}//end function

function detectBrowser(){
   var browser = '';
   browser = navigator.appVersion;
   if (browser.indexOf('MSIE 8') != -1) return 'IE8';
   if (browser.indexOf('MSIE') != -1) return 'IE';
}

function moveToStep01(id,step){
   var html ='';

   if(step==02){
      document.location = "?pg=5&pgm=M&option=edit&id="+id+"&step=01";
      return;
   }//endif
   requestAjax('sidebar', 'modules/step00_option.php','?profile_id='+id+'&step=01');
   if (step==05) requestAjax('main_content', 'modules/step01_survey.php','?profile_id='+id);
   //if (detectBrowser()=='IE') requestAjax('question_div','modules/step01_question.php', '?transaction=select&smoke=survey&profile_idref='+id);
   setTimeout(
      function(){
         $('step_heading').innerHTML= "Step one<span class='stepstext1'> - Add question</span>";
         $('feel_free').innerHTML= "Start creating your questions from the options on the left. You will need to create a survey title below (by clicking on the text) before starting.";
         //$('feel_free2').show();
         html += "<a href='#top' onclick=\"javascript: moveToStep02('"+id+"')\">";
         html += "<p class='smoketoolboxheadin3' style='text-align: right'>Next&nbsp;<span class='smoketoolboxheadin4'>Step</span> </p>";
         $('nav').innerHTML         = html;
      }
   ,3000);
     
}
function moveToStep02(id,step){
   var html ='';

//   if(!chkID(id)) return false;
   requestAjax('sidebar', 'modules/step00_option.php','?profile_id='+id+'&step=02&id='+id);
   //if (step==05) requestAjax('main_content', 'modules/step01_survey.php','?profile_id='+id);
   requestAjax('main_content', 'modules/step02_display.php','?profile_id='+id+'&id='+id);
   /*
   setTimeout(
      function(){
         $('step_heading').innerHTML= "Step two<span class='stepstext1'> - Colours</span>";
         $('feel_free').innerHTML = "Please click a section you’d like to change on the left and then select your chosen colour, font size and font type. Or, select a predefined colour template";
         //$('feel_free2').hide();
         html += "<p style='display: inline' class='smoketoolboxheadin3' style='text-align: right'><a href='#top' onclick=\"javascript: moveToStep01('"+id+"')\">";
         html += "Previous&nbsp;<span class='smoketoolboxheadin4'>Step |</span> ";
         html += "<a href='#top' onclick=\"javascript: moveToStep03('"+id+"')\">";
         html += "Next&nbsp;<span class='smoketoolboxheadin4'>Step</span> </p>";
         $('nav').innerHTML         = html;
      }
   ,3000);
   */
}
function moveToStep03(id,step){
   var html ='';
   
//   if(!chkID(id)) return false;
   if(step==02){
      document.location = "?pg=5&pgm=M&option=edit&id="+id+"&step=03";
      return;
   }//endif
   requestAjax('sidebar', 'modules/step00_option.php','?profile_id='+id+'&step=03');
   if (step==05) requestAjax('main_content', 'modules/step01_survey.php','?profile_id='+id);
   setTimeout(
      function(){
         $('step_heading').innerHTML= "Step three<span class='stepstext1'> - images</span>";
         $('feel_free').innerHTML = "This is where you're able to upload your own branding and images relating to your survey. View example <a onclick=\"pop_win('http://smokesurvey.dev.co.za/template.html','Survey',700,420,1,0)\" href='javascript: void(0)'  >here</a>";
         //if ($('feel_free2').visible())$('feel_free2').hide();
         html += "<p style='display: inline' class='smoketoolboxheadin3' style='text-align: right'><a href='#top' onclick=\"javascript: moveToStep02('"+id+"')\">";
         html += "Previous&nbsp;<span class='smoketoolboxheadin4'>Step |</span>";
         html += "<a href='#top' onclick=\"javascript: moveToStep04('"+id+"')\">";
         html += "Next&nbsp;<span class='smoketoolboxheadin4'>Step</span> </p>";
         $('nav').innerHTML         = html;
      }
   ,3000);
}
function moveToStep04(id,step){
   var html ='';
 
//   if(!chkID(id)) return false;
   if(step==02){
      document.location = "?pg=5&pgm=M&option=edit&id="+id+"&step=04";
      return;
   }//endif
   requestAjax('sidebar', 'modules/step00_option.php','?profile_id='+id+'&step=04');
   if (step==05) requestAjax('main_content', 'modules/step01_survey.php','?profile_id='+id);
   setTimeout(
      function(){
         $('step_heading').innerHTML= "Step four<span class='stepstext1'> - preview</span>";
         $('feel_free').innerHTML = "You can now preview your survey. It will open in a new window.";
         //if ($('feel_free2').visible())$('feel_free2').hide();
         html += "<p style='display: inline' class='smoketoolboxheadin3' style='text-align: right'><a href='#top' onclick=\"javascript: moveToStep03('"+id+"')\">";
         html += "Previous&nbsp;<span class='smoketoolboxheadin4'>Step |</span>";
         html += "<a href='#top' onclick=\"javascript: moveToStep05('"+id+"')\">";
         html += "Next&nbsp;<span class='smoketoolboxheadin4'>Step</span> </p>";
         $('nav').innerHTML         = html;
      }
   ,3000);
     
}
function moveToStep05(id,step){
   var html ='';

//   if(!chkID(id)) return false;
   if(step==02){
      document.location = "?pg=5&pgm=M&option=edit&id="+id+"&step=05";
      return;
   }//endif
   requestAjax('sidebar', 'modules/step00_option.php','?profile_id='+id+'&step=05');
   requestAjax('main_content', 'modules/step05_logo.php','?profile_id='+id);
   /*setTimeout(
      function(){   
         html += "<p style='display: inline' class='smoketoolboxheadin3' style='text-align: right'><a href='#top' onclick=\"javascript: moveToStep04('"+id+"')\">";
         html += "Previous&nbsp;<span class='smoketoolboxheadin4'>Step |</span>";
         html += "<a href='#top' onclick=\"javascript: window.location='?pg=8&pgm=M&option=done'\" >";
         html += "Complete&nbsp;<span class='smoketoolboxheadin4'>&nbsp;</span> </p>";
         $('nav').innerHTML         = html;
      }
   ,3000);*/
}
function moveToFinal(){
   var empty = '';   
      empty = $('mail_field[0]').value;
      empty += $('mail_field[1]').value;
      empty += $('mail_field[2]').value;
      empty += $('mail_field[3]').value;
      empty += $('mail_field[4]').value;
   
   if (empty=='') window.location='?pg=8&pgm=M&option=done';
   else {if(confirm('You haven’t sent your emails yet, would you like to go back?')){window.location='#top'}else{window.location='?pg=8&pgm=M&option=done'}}
   
}
function chkID(id){
   if(!id){
      alterDivDisplay('background_div');
      alterDivDisplay('pop_div');
      $('pop_div').innerHTML = "<p><b>Please give your survey a heading title before adding anything. <a href='javascript: void(0)' onclick=\"alterDivDisplay('background_div'); alterDivDisplay('pop_div')\";><img src='images/edit-delete.gif'></b></p>";
      return false;
   }//endif
}//endfunc
//=====================================AJAX===========================================================//
//=============================script for date function===============================================//
   var currentDate = new Date();
   var today   = currentDate.getDay();
   var thisyr  = currentDate.getFullYear();
   
   function jsDelAll(dayID) {

      var dayObj = document.getElementById(dayID);
      var ngLen = dayObj.options.length;

      for (x = ngLen; x >= 0; x--) {
          dayObj.options[x] = null;
      }//next x

      dayObj.options.lenth = 0;
   }//end function

   function createDays(max, dayID) {

      var dayObj = document.getElementById(dayID);

      jsDelAll(dayID);

      for (x = 1; x <= max; x++) {

          dayObj.options[x - 1] = new Option(x, x);

      }//next x
   }//end function

   function updateDays(monID, dayID) {

      var monObj = document.getElementById('month_'+monID);
      var selMon = monObj.value;

      
      if (selMon == 1 || selMon == 3 || selMon == 5 || selMon == 7 || selMon == 8 || selMon == 10 || selMon == 12) {
         createDays(31, dayID);
      } else if (selMon == 4 || selMon == 6 || selMon == 9 || selMon == 11) {
         createDays(30, dayID);
      } else if (selMon == 2) {
         if (thisyr == 2004 || thisyr == 2008 || thisyr == 2012) {
            createDays(29, dayID);
         } else {
            createDays(28, dayID);
         }//end if
      }//end if
      setHiddenDate(monID);
   }//end function

   function setHiddenDate(selName){
      var year       = document.getElementById('year_'+selName).value;
      var month      = document.getElementById('month_'+selName).value;
      var day        = document.getElementById('day_'+selName).value;
      var dateChosen = year+'/'+month+'/'+day
      document.getElementById(selName).value = dateChosen;

   }//end function sethideendate

   function disableEnterKey(k) {
        var key;
        if(window.event)
             key = window.event.keyCode; //IE
        else
             key = k.which; //firefox

        return (key != 13);
   }

   function validColour(hexcolor) {
      var strPattern = /^#?([0-9a-f]{1,2}){3}$/i;
      if (strPattern.test(hexcolor)) return true;
      else return false
   }

   function getTemplate(temp,num){
      var theTemplate = new Array();
      //['background','font','size','bold','italic']
      if(num=='butter'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#c4a000','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#918300','14px','bold','italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#666666','10px'];break;
            case 'survey_quest':theTemplate  = ['#fce94f','#797900','15px','bold','italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#797900','11px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#666666','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      } //endif butter temple
      else if (num=='orange'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#fcaf3e','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#fcaf3e','#ce5c00','14px','bold'];break;
            case 'survey_desc' :theTemplate  = ['#fcaf3e','#ce5c00','10px', 'normal', 'italic'];break;
            case 'survey_quest':theTemplate  = ['#ce5c00','#ffffff','15px','bold'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#cccccc','11px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#666666','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#fcaf3e'];break;
         }
      }//endif orange templte
      else if (num=='chocolate'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#e9b96e','#8f5902','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#8f5902','14px','bold','italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#666666','10px'];break;
            case 'survey_quest':theTemplate  = ['#c17d11','#ffffff','15px','bold','italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#e9b96e','10px','bold'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#8f5902','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      }//endif chocolate template
      else if (num=='Chameleon'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#4e9a06','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#4e9a06','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#666666','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#73d216','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','rgb(102,102,102)','10px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#333333','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      }//endif orange templte
      else if (num=='SkyBlue'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#204a87','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#204a87','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#204a87','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#3465a4','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#204a87','10px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#333333','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff','','','','','#cccccc','solid','1px'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      }//endif orange templte
      else if (num=='Plum'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#5c3566','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#ad7fa8','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#5c3566','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#75507b','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#5c3566','10px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#333333','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      }//endif orange templte
      else if (num=='Scarlet'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#cc0000','#ffffff','22px','bold','','#cc0000','solid','3px'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#a40000','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#333333','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#a40000','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#000000','10px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#333333','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      }//endif orange templte
      else if (num=='Aluminium'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#555753','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#ffffff','#2e3436','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#ffffff','#2e3436','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#888a85','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#FFFFFF','#2e3436','12px'];break;
            case 'survey_label':theTemplate  = ['#FFFFFF','#2e3436','12px'];break;
            case 'subContent'  :theTemplate  = ['#FFFFFF'];break;
            case 'mainContent' :theTemplate  = ['#FFFFFF'];break; 
         }
      }//endif orange templte
      else if (num=='Silver'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#d3d7cf','#666666','22px','bold','','#d3d7cf','solid','3px'];break;
            case 'survey_intro':theTemplate  = ['#eeeeec','#666666','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#eeeeec','#666666','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#ffffff','#666666','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#eeeeec','#666666','10px'];break;
            case 'survey_label':theTemplate  = ['#eeeeec','#666666','12px'];break;
            case 'subContent'  :theTemplate  = ['#eeeeec'];break;
            case 'mainContent' :theTemplate  = ['#eeeeec'];break;
         }
      }//endif orange templte
      else if (num=='Smoke'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#ffffff','#666666','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#f7f7f5','#233f92','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#f7f7f5','#233f92','10px', 'normal'];break;
            case 'survey_quest':theTemplate  = ['#ff9900','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#eae8e4','#666666','10px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#666666','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#f7f7f5'];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='GSK'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#ffffff','#f05223','','bold','','#ffffff', 'solid','3px'];break;
            case 'survey_intro':theTemplate  = ['','#f05223','14px','', ''];break;
            case 'survey_desc' :theTemplate  = ['','#666666','11px', ''];break;
            case 'survey_quest':theTemplate  = ['#f8981f','#ffffff','14px','', ''];break;
            case 'survey_hint' :theTemplate  = ['','#cccccc','','bold'];break;
            case 'survey_label':theTemplate  = ['','',''];break;
            case 'subContent'  :theTemplate  = ['#ffffff','','','','','#e3e1e1', 'solid','1px'];break;
            case 'mainContent' :theTemplate  = ['#ffffff'];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='Indwe'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#46a7ca','#ffffff','22px','bold'];break;
            case 'survey_intro':theTemplate  = ['#46a7ca','#ffffff','14px','bold', 'italic'];break;
            case 'survey_desc' :theTemplate  = ['#46a7ca','#ffffff','10px', ''];break;
            case 'survey_quest':theTemplate  = ['#035294','#ffffff','15px','bold', 'italic'];break;
            case 'survey_hint' :theTemplate  = ['#ffffff','#666666','11px'];break;
            case 'survey_label':theTemplate  = ['#ffffff','#666666','12px'];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#46a7ca'];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='Nedbank'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['','#ffffff','','bold'];break;
            case 'survey_intro':theTemplate  = ['','#ffffff'];break;
            case 'survey_desc' :theTemplate  = ['','#ffffff', '11px'];break;
            case 'survey_quest':theTemplate  = ['#ececdb','#22513c',''];break;
            case 'survey_hint' :theTemplate  = [''];break;
            case 'survey_label':theTemplate  = [''];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#22513c'];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='FNB'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#ffffff','#01aaad','','bold'];break;
            case 'survey_intro':theTemplate  = ['','#ffffff'];break;
            case 'survey_desc' :theTemplate  = ['','#ffffff'];break;
            case 'survey_quest':theTemplate  = ['#ffffff','#f68e1f'];break;
            case 'survey_hint' :theTemplate  = [''];break;
            case 'survey_label':theTemplate  = [''];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#01aaad'];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='AfriHost'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['','#d02626','','bold'];break;
            case 'survey_intro':theTemplate  = ['','#666666', '14px'];break;
            case 'survey_desc' :theTemplate  = ['','#666666', '11px'];break;
            case 'survey_quest':theTemplate  = ['#d02626','#ffffff'];break;
            case 'survey_hint' :theTemplate  = ['','#cccccc','','bold'];break;
            case 'survey_label':theTemplate  = [''];break;
            case 'subContent'  :theTemplate  = ['','','','','','#cccccc','solid','1px'];break;
            case 'mainContent' :theTemplate  = [''];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='ABSA'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#ffffff','#ed1b2d','','bold','','#ffffff','solid','3px'];break;
            case 'survey_intro':theTemplate  = ['','#ed1b2d', '12px'];break;
            case 'survey_desc' :theTemplate  = ['','#333333', '11px'];break;
            case 'survey_quest':theTemplate  = ['#e11f2e','#ffffff','','bold','','#e11f2e','solid','3px'];break;
            case 'survey_hint' :theTemplate  = [''];break;
            case 'survey_label':theTemplate  = [''];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#f5f5f5'];break;
         }
      }//endif orange templte //['background','font','size','bold','italic','borderCol', 'borderStyle','borderSize']
      else if (num=='STD'){
         switch(temp){
            case 'survey_head' :theTemplate  = ['#0021a4','#ffffff','','bold','','#ffffff','none','3px'];break;
            case 'survey_intro':theTemplate  = ['#0021a4','#ffffff'];break;
            case 'survey_desc' :theTemplate  = ['#0021a4','#ffffff'];break;
            case 'survey_quest':theTemplate  = ['','#0021a4'];break;
            case 'survey_hint' :theTemplate  = [''];break;
            case 'survey_label':theTemplate  = [''];break;
            case 'subContent'  :theTemplate  = ['#ffffff'];break;
            case 'mainContent' :theTemplate  = ['#0021a4'];break;
         }
      }//endif orange templte
      return theTemplate;
   }//endfunction
   function templateColour (num,id, upgrade){
      var theFields = ['survey_head','survey_intro','survey_desc','survey_quest','survey_hint','survey_label','subContent','mainContent'];
      var theClass,template, theCall;
      var url = new Array();
      var font_size,font_colour,background_colour, font_style, font_weight, borderCol, borderStyle, borderSize = '';
   
      postAjax('modules/tables.php','?profile_idref='+id+'&transaction=delete&option=css');
      for(xX=0;xX<theFields.length;xX++){
         theCall  = theFields[xX];
         theClass = getTheId(theCall);//alert(theClass);
         //if(confirm(theClass+'='+theFields.length+'='+xX+'='+theCall)){return;}
         template = getTemplate(theCall,num); 
        
         if(template[2]) font_size         = template[2];
         else font_size          = '';

         if(template[1]) font_colour       = template[1];
         else font_colour        = '#666666';

         if(template[0]) background_colour = template[0];
         else background_colour  = 'transparent';

         if(template[4]) font_style        = template[4];
         else font_style         = 'normal';

         if(template[3]) font_weight       = template[3];
         else font_weight        = '';

         if(template[5]) borderCol         = template[5];
         else borderCol          = 'transparent';

         if(template[6]) borderStyle       = template[6];
         else borderStyle        = 'none';

         if(template[7]) borderSize        = template[7];
         else borderSize         = '0px';

         $(theCall).setStyle({
            fontSize    : font_size,
            color       : font_colour,
            fontStyle   : font_style,
            fontWeight  : font_weight,
            backgroundColor: background_colour,
            borderColor : borderCol,
            borderStyle : borderStyle,
            borderWidth : borderSize
         });
         
         if(font_colour.indexOf('#') != -1) font_colour = '%23'+font_colour.substring(1, font_colour.length);
         if(background_colour.indexOf('#') != -1) background_colour = '%23'+background_colour.substring(1, background_colour.length);
         if(borderCol.indexOf('#') != -1) borderCol = '%23'+borderCol.substring(1, borderCol.length);
         url[xX] = "?smoke=survey&class_name="+theClass+"&profile_idref="+id+"&font_colour="+font_colour+"&background_colour="+background_colour+"&font_style="+font_style+"&font_weight="+font_weight+"&font_size="+font_size+"&border_colour="+borderCol+"&border_style="+borderStyle+"&border_width="+borderSize;
         //alert(url);         
      }//endfor
      if(upgrade=='false'){
         setTimeout(
            function(){
               auto_update2('', 'modules/program.php', '', url[0]);
               auto_update2('', 'modules/program.php', '', url[1]);
               auto_update2('', 'modules/program.php', '', url[2]);
               auto_update2('', 'modules/program.php', '', url[3]);
               auto_update2('', 'modules/program.php', '', url[4]);
               auto_update2('', 'modules/program.php', '', url[5]);
               auto_update2('', 'modules/program.php', '', url[6]);
               auto_update2('', 'modules/program.php', '', url[7]);
            },2000
         )//end settimeout
      }//endif

   }//endfunction
   
   function readyColours(id, col1, col2, col3, col4, col5, col6, col7, col8, col9) {
      var url = '';
      if (col1!='') {
         setColours('.surveyHeading', col1);
         if(col1.indexOf('#') != -1) col1 = '%23'+col1.substring(1, col1.length);
         url = "?smoke=survey&class_name=.surveyHeading&profile_idref="+id+"&font_color="+col1;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col2!='') {
         setColours('.surveySubHeading', col2);
         if(col2.indexOf('#') != -1) col2 = '%23'+col2.substring(1, col2.length);
         url = '?smoke=survey&class_name=.surveySubHeading&profile_idref='+id+'&font_color='+col2;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col3!='') {
         setColours('.surveyDescription', col3);
         if(col3.indexOf('#') != -1) col3 = '%23'+col3.substring(1, col3.length);
         url = '?smoke=survey&class_name=.surveyDescription&profile_idref='+id+'&font_color='+col3;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col4!='') {
         setColours('.question', col4);
         if(col4.indexOf('#') != -1) col4 = '%23'+col4.substring(1, col4.length);
         url = '?smoke=survey&class_name=.question&profile_idref='+id+'&font_color='+col4;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col5!='') {
         setColours('.subquestion', col5);
         if(col5.indexOf('#') != -1) col5 = '%23'+col5.substring(1, col5.length);
         url = '?smoke=survey&class_name=.subquestion&profile_idref='+id+'&font_color='+col5;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col6!='') {
         setColours('.surveyField', col6);
         if(col6.indexOf('#') != -1) col6 = '%23'+col6.substring(1, col6.length);
         url = '?smoke=survey&class_name=.surveyField&profile_idref='+id+'&font_color='+col6;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col7!='') {
         setColours('.label', col7);
         if(col7.indexOf('#') != -1) col7 = '%23'+col7.substring(1, col7.length);
         url = '?smoke=survey&class_name=.label&profile_idref='+id+'&font_color='+col7;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col8!='') {
         setColours('.inside', col8);
         if(col8.indexOf('#') != -1) col8= '%23'+col8.substring(1, col8.length);
         url = '?smoke=survey&class_name=.inside&profile_idref='+id+'&font_color='+col8;
         auto_update2('', 'modules/program.php', '', url);
      }
      if (col9!='') {
         setColours('.tableCss', col9);
         if(col9.indexOf('#') != -1) col9 = '%23'+col9.substring(1, col9.length);
         url = '?smoke=survey&class_name=.tableCss&profile_idref='+id+'&font_color='+col9;
         auto_update2('', 'modules/program.php', '', url);
      }
   }

function setColours(fullClass, col){
      fullClass = fullClass.substring(1, fullClass.length);
      $$('[class="'+fullClass+'"]').each(function(sets){
         sets.style.color = col;
         if (fullClass=='tableCss' || fullClass=='inside') sets.style.backgroundColor = col;
      });
   }
function checkLevelOne (id){
      var elem = 'one'+id;
      var elem2= 'two'+id;
      document.getElementsByTagName('input').each(function(a){
         if(a.ClassName==elem)alert(a.checked);
      });
   }//end function chklevone

function closeWin() {
   if(navigator.appName=="Microsoft Internet Explorer") {
      window.parent.window.opener=null;
      window.parent.window.close();
   } else if(navigator.appName=="Netscape") {
      top.window.opener = top;
      top.window.open('','_parent','');
      top.window.close();
   }
}
