﻿
/*

CLASS: MySettings
MEMBERS:

  
DESCRIPTION:
  This class is used to set user settings such as screen resolution and store this info into permanent cookies
*/
function MySettings(){
  //controls
  this.Div = getEl('divMySettings');
  this.rbMedium = getEl('rb15');
  this.rbLarge = getEl('rb17');
  this.SaveButton = getEl('btnSave');
  this.CancelButton = getEl('btnCancel');
  this.CloseButton = getEl('divMySettingsClose');
  
  //show setting div and pagemask
  this.Div.style.display = 'block';
  getEl('ctl00_cpBody_pageMask').style.display = 'block';
  
  this.SetupMySettings();
  
  var me = this;
	this.CancelButton.onclick =function ClosePopup(){
    me.Close(); 
  } 
  
  this.SaveButton.onclick = function SaveSettings(){
    me.Save();
  }
  
  this.CloseButton.onclick = function Close (){
    me.Close();
  }

}

var ms = MySettings.prototype;

ms.SetupMySettings = function(){
  var res = readCookie('resolution')
  if (res){
    if (res=='medium'){
      this.rbMedium.checked = true;
    }else{
      this.rbLarge.checked = true;
    }
  }else{
    this.rbMedium.checked = true;
  }
}

ms.Close = function(){
  this.Div.style.display = 'none';
  getEl('ctl00_cpBody_pageMask').style.display = 'none';
}

ms.Save = function(){
  var res = '';
  if (this.rbLarge.checked){
    createCookie("resolution", "large", 3650)
  }else{
    createCookie("resolution", "medium", 3650)
  }
  this.Close();
}