﻿// trung.ho@aki.com

function FixInputClassName()
{
	var els = document.getElementsByTagName('input');
	var elsLen = els.length;
	var i = 0;
	var type;
	for ( i=0;i<elsLen;i++ )
	{
		type = els[i].getAttribute('type');
		if (type != null && typeof type != "undefined" )
		{ 
			if ((type == "submit" || type == "button" || type=="reset") && ((els[i].className.indexOf("submit-button") < 0)
				|| (els[i].className.indexOf("submit-button-big") < 0)))
				els[i].className = els[i].className + ' submit-button';
			else 
			if(type == "text" || type == "password" && (els[i].className.indexOf("input-box") < 0))
				els[i].className = els[i].className + ' input-box';			
		}
	}
}

function Toggle(img, cltId)
{
	img.src = img.src.indexOf('Images/small-minus.gif') != -1 ? 'Images/small-plus.gif' : 'Images/small-minus.gif';
    var clt = document.getElementById(cltId);   
    if(clt != null && typeof(clt) != 'undefined') 
        clt.style.display =  clt.style.display == 'none'? clt.style.display = 'block' : clt.style.display = 'none';
}

window.onresize = FixHeight;

var pageOffset, minimalheight
function FixHeight()
{
	var viewportwidth;
	 var viewportheight;
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  viewportwidth = window.innerWidth,
		  viewportheight = window.innerHeight
	 }
	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth,
		   viewportheight = document.documentElement.clientHeight
	 }
	 else
	 {
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	 var minheight;
	 minheight = document.getElementById('height');
	 if(minheight != null && typeof minheight != "undefined")
	 {
		if(viewportheight > minimalheight)
			minheight.style.height = (viewportheight - pageOffset)  + "px";			
	 }	
}

function SetHeight(offset, height)
{
	pageOffset = offset;
	minimalheight = height;
	FixHeight();
}

function ecmPopUpWindow(url, hWind, nWidth, nHeight, nScroll, nResize) 
{
	var popupwin,  cToolBar;
	cToolBar = 'toolbar=0,location=0,directories=0,status=' + nResize + ',menubar=0,scrollbars=' + nScroll + ',resizable=' + nResize + ',width=' + nWidth + ',height=' + nHeight;
	popupwin = window.open(url, hWind, cToolBar);
	return popupwin;
}

