﻿/************************* Font resizer **********************************/
var min=11;
var max=19;
function increaseFontSize(target) { //Increase font
    //resize text
   var elem = document.getElementById(target);
   if(elem){
        if(elem.style.fontSize){
            var size=parseInt(elem.style.fontSize.replace("px",""));
        } else{
            size=11;
        }
        if(size<max){
            size+=4;
        }
        elem.style.fontSize=size+"px";
   }
   //resize links
   var a = elem.getElementsByTagName('a');
   for(i=0;i<a.length;i++) {
        if(a[i].style.fontSize) {
            var asize = parseInt(a[i].style.fontSize.replace("px",""));
        } else {
            var asize = 11;
        }
        if(asize<max) {
            asize += 4;
        }
      a[i].style.fontSize = asize+"px"
   }

}

function decreaseFontSize(target) { //Decrease font
    //resize text
   var elem = document.getElementById(target);
   if(elem){
        if(elem.style.fontSize){
            var size=parseInt(elem.style.fontSize.replace("px",""));
        } else{
            size=11;
        }
        if(size>min){
            size-=4;
        }
        elem.style.fontSize=size+"px";
   }
   //resize links
   var a = elem.getElementsByTagName('a');
   for(i=0;i<a.length;i++) {
        if(a[i].style.fontSize) {
            var asize = parseInt(a[i].style.fontSize.replace("px",""));
        } else {
            var asize = 11;
        }
        if(asize>min) {
            asize -= 4;
        }
      a[i].style.fontSize = asize+"px"
   }
   
}

/************************* Google search **********************************/
function GoogleSearch(domain,TextBoxId) {     //Input1: domain, Input2: search textbox id
    var txtQ=document.getElementById(TextBoxId);
    var q=txtQ.value;
    window.location = "http://www.google.com/custom" + "?q=" + q + "&domains=" + domain + "&sitesearch=" + domain;
}
  
/************************* Input check ************************************/
function checkInput(obj) {
    //var invalidChars = /["'\\'<>]/gi
    var invalidChars = /[<>]/gi
    if(invalidChars.test(obj.value)) {
        //alert("Invalid characters.");
        obj.value = obj.value.replace(invalidChars,"");
    }
}

/************************** Open PopUp window ******************************/
function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=yes');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

