/* all misc functions for template */

// check if a number is an integer
function isInt(myNum) 
{
	// get the modulus: if it's 0, then it's an integer
         var myMod = myNum % 1;

         if (myMod == 0) {
                 return true;
         } else {
                 return false;
         }
}

// check if positive int
function isIntPositive(numvalue)
{	
	if(isInt(numvalue) && numvalue > 0)
	{
		return true;
	}
	else
	{
		return false;
	}

}

function isFloatPositive(numvalue)
{
	if(!isNaN(numvalue) && numvalue > 0)
	{
		return true;
	}
	else
	{
		return false;
	}

}



	
	function readCookie(name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	

	
	
	function HideHelpExt(div)
	{
		objDiv = document.getElementById(div);
		objDiv.style.display = 'none';
	}
	
	function ShowHelpExt(div, title, desc, width)
	{
		 
		objDiv = document.getElementById(div);
		objDiv.style.display = 'inline';
		
		objDiv.style.position = 'absolute';
		objDiv.style.width = width;
		objDiv.style.backgroundColor = 'lightyellow';
		objDiv.style.border = 'dashed 1px black';
		objDiv.style.padding = '10px';
		objDiv.innerHTML = '<b>' + title + '</b><br/><img src="../images/blank.gif" width="1px" height="5px"><br/>' +
				'<div style="padding-left:10px; padding-right:5px">' + desc + '</div>';
		
	}	
	
	function initPage()
	{

		
		pkCustomer = readCookie('pkCustomer');
		


		var objDiv = document.getElementById('loginLabel');

		custName = new String(readCookie('custName'));
		custName = (custName.replace(/\+/g," "));

		
		if(pkCustomer != null && pkCustomer != '')
		{
			objDiv.innerHTML = '<div style="padding:0px 0px;" >Welcome ' + custName + '<br>' + 
						'<a href=/webshaper/store/custHome.asp class="headerLink" >Account Menu</a> &nbsp; ' +
						'<a href=/webshaper/store/logoff.asp class="headerLink" >Logoff</a></div>';
		}
	}

	
	