﻿var pageTracker = _gat._getTracker("UA-3657703-2");
pageTracker._initData();
pageTracker._trackPageview();

function checkEnter(e)
{ //e is event object passed from function invocation
    var characterCode;// literal character code will be stored in this variable
    if(e && e.which)
    { //if which property of event object is supported (NN4)
        e = e;
        characterCode = e.which; //character code is contained in NN4's which property
    }
    else
    {
        e = event;
        characterCode = e.keyCode; //character code is contained in IE's keyCode property
    }
    if(characterCode == 13 && e.srcElement.type!='textarea' && window.name!="Login")
    { //if generated character code is equal to ascii 13 (if enter key)
        return false ;
    }
    else
    {
        return true ;
    }
}

function addFunction(eventObject,eventFiresOn,eventFunction)
{
	 if(eventObject.addEventListener) eventObject.addEventListener(eventFiresOn, eventFunction, false); else if (eventObject.attachEvent) eventObject.attachEvent('on'+ eventFiresOn, eventFunction); 
}

function OpenPopup(popupDivId, backgroundDivId, topPos) 
{
    var popupDiv = document.getElementById(popupDivId);
    
    if (popupDiv != null)
    {
        popupDiv.style.left = "-5000px";
        popupDiv.style.display = '';
        popupDiv.style.left = (((f_clientWidth() - popupDiv.offsetWidth) / 2) - 0) + "px";
        
        if (!topPos)
        {
            popupDiv.style.top = "150px"; /*(((f_clientHeight() - popupDiv.offsetHeight) / 2) - 0) + "px";*/
        }
        else
        {
            popupDiv.style.top = topPos;
        }
    }
        
    var backgroundDiv = document.getElementById(backgroundDivId);
    if (backgroundDiv != null)
        backgroundDiv.style.display = '';
}

function OpenFixPopup(popupDivId, backgroundDivId, topPos, leftPos) {
    var popupDiv = document.getElementById(popupDivId);

    if (popupDiv != null) {
        popupDiv.style.left = "-5000px";
        popupDiv.style.display = '';

        if (!leftPos) {
            popupDiv.style.left = (((f_clientWidth() - popupDiv.offsetWidth) / 2) - 0) + "px";
        }
        else {
            popupDiv.style.left = leftPos;
        }
        

        if (!topPos) {
            popupDiv.style.top = "150px"; /*(((f_clientHeight() - popupDiv.offsetHeight) / 2) - 0) + "px";*/
        }
        else {
            popupDiv.style.top = topPos;
        }
    }

    var backgroundDiv = document.getElementById(backgroundDivId);
    if (backgroundDiv != null)
        backgroundDiv.style.display = '';
}
function ClosePopup(popupDivId, backgroundDivId) 
{
    var popupDiv = document.getElementById(popupDivId);
 
    var backgroundDiv = document.getElementById(backgroundDivId);
    
    if (popupDiv != null)
        popupDiv.style.display = 'none';
        
    if (backgroundDiv != null)
        backgroundDiv.style.display = 'none';
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function StopEvent(pE)
{
   if (!pE)
	 if (window.event)
	   pE = window.event;
	 else
	   return;
  if (pE.cancelBubble != null)
	 pE.cancelBubble = true;
  if (pE.stopPropagation)
	 pE.stopPropagation();
  if (pE.preventDefault)
	 pE.preventDefault();
  if (window.event)
	 pE.returnValue = false;
  if (pE.cancel != null)
	 pE.cancel = true;
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	return [curleft, curtop];
}

var on = (function(){
    if ("addEventListener" in window) {
        return function(target, type, listener){
            target.addEventListener(type, listener, false);
        };
    }
    else {
        return function(object, sEvent, fpNotify){
            object.attachEvent("on" + sEvent, function(){
                fpNotify(window.event);
            });
        };
    }
}());

function ValidateInteger(e)
{
	// Always use this function for onkeydown event
	var key;
	if (window.event) key = window.event.keyCode;
	else if (e) key = e.which;
	if (!((key >= 48 && key <= 57) || (key >= 96 && key <= 105) || (key >= 33 && key <= 39) || key == 8 || key == 9 || key == 16 || key == 18 || key == 46 ||  key == 116))
	{
		StopEvent(e);
	}
}

function GetKeyCode(e)
{
    var key;
	if (window.event) key = window.event.keyCode;
	else if (e) key = e.which;
	return key;
}

function EnterKey(e, obj, lnkObject)
{
    if (GetKeyCode(e) == 13) {
        StopEvent(e);
        lnkObject.click();
    }
}

function EnterKeyPostBack(e, obj, lnkObject) {
    if (GetKeyCode(e) == 13) {
        __doPostBack(lnkObject.id, '');
    }
}
