﻿// JScript File for TextArea
// Keep user from entering more than maxLength characters
function doKeypress(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}
// Cancel default behavior
function doBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}

function resizeimages(){
  var max_width = 280;
  if (document.images) {
    for (i = 0; i < document.images.length; i++) {

       while ( !document.images[i].complete ){
             break;
       }
       if(document.images[i].id == 'ctl00_cphContentUp_BigNewsInHome_dlNewsBig_ctl01_imgImageNameBig'){
          var imagetoprocess = document.images[i];
          var old_width = imagetoprocess.width;
           if ( document.images[i].width > 280 ){
              imagetoprocess.width = max_width;
           }   
           if ( document.images[i].height > 200 ){
              imagetoprocess.height = 200; 
           }
       }
       if(document.images[i].id == 'imgNewsDett'){
          var imagetoprocess = document.images[i];
          var old_width = imagetoprocess.width;
           if ( document.images[i].width > 280 ){
              imagetoprocess.width = max_width;
           }   
           if ( document.images[i].height > 200 ){
              imagetoprocess.height = 200; 
           }
       }
       if(document.images[i].id == 'imgEventDett'){
          var imagetoprocess = document.images[i];
          var old_width = imagetoprocess.width;
           if ( document.images[i].width > 280 ){
              imagetoprocess.width = max_width;
           }   
           if ( document.images[i].height > 200 ){
              imagetoprocess.height = 200; 
           }
       }
    }
  }
}

