﻿/***** Source: http://blog.stevenlevithan.com/archives/faster-trim-javascript | trim12 *******/
function trimStr (str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}
/****** End **********/

function ValidNumber(n)
{
    if(n == null || n == '') return false;
    var number = new Number();    
    number = Number(n);
    
    if (isNaN(number)) return false;
    else return true;
}

function isNotNull(obj)
{   
    if(obj != null)
        return true;
   return false;
}

function ValidEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
   return reg.test(email);
}

function OpenPopup(url, widthParam, heightParam, menubarParam,toolbarParam, locationParam, directoriesParam, scrollbarsParam, resizableParam, leftParam, topParam)
{ 
    /* Settings: toolbar = yes/no, location  = yes/no, directories = yes/no, menubar = yes/no, scrollbars = yes/no
    resizable = yes/no, width, height, left, top */
    var setting = '';
    
    if(toolbarParam != null) { setting += 'toolbar=' + toolbarParam; }
    else { setting += 'toolbar=no'; }
    if(locationParam != null) { setting += ',location=' + locationParam; }
    else { setting += ',location=no'; }
    if(directoriesParam != null) { setting += ',directories='+ directoriesParam; }
    else { setting += ',directories=no'; }
    if(menubarParam != null) {  setting += ',menubar='+ menubarParam; }
    else {  setting += ',menubar=yes'; }
    if(scrollbarsParam != null) {  setting += ',scrollbars='+ scrollbarsParam;}
    else {  setting += ',scrollbars=yes';}
    if(resizableParam != null) { setting += ',resizable=' + resizableParam; }
    else { setting += ',resizable=yes'; }
    if(widthParam != 0) { setting += ',width=' + widthParam; }    
    if(heightParam != 0) { setting += ',height=' + heightParam; }
 
    if(leftParam != null) { setting += ',left=' + leftParam;}
    else { setting += ',left=' + (screen.width - widthParam) / 2; }
    if(topParam != null) { setting += ',top=' + topParam; }
    else{ setting += ',top=' + (screen.height - heightParam) / 2;}
    
    window.open(url, '',setting);    
}
function preLoadImages()
{
    imgObj = new Image();
    
    imgURL = new Array();
    imgURL[0] = "Media/Images/MainHeader.jpg";
    imgURL[1] = "Media/Images/MainLeftTile.jpg";
    imgURL[2] = "Media/Images/MainLeftMenu.jpg";
    imgURL[3] = "Media/Images/MainRightTile.jpg";
    imgURL[4] = "Media/Images/MainBottom.jpg";

    var index = 0;
    for(index = 0; index <= imgURL.length; index++){ imgObj.src = imgURL[index]; }
}
preLoadImages();
//************ PreLoad Images - End *************//

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function foucAndSelect(obj) { obj.focus(); obj.select(); }

function showHideDiv(divContentID)
{
    var divContent = document.getElementById(divContentID);
    if(divContent.style.display == '') { divContent.style.display = 'none';}
    else { divContent.style.display = '';}
}
function getTextBoxTrimmedValue(txtBoxClientID) { return trimStr(document.getElementById(txtBoxClientID).value); }
function compareString(Str1, Str2) { if(Str1 == Str2) { return true; } else { return false; } }
