// JavaScript Document

function checkHead()
		{
		checkHeadRefer();
		
		if(window.location.href.indexOf('enrol.php') > 0)
			{
			if(window.location.search.indexOf('cpc621') > 0)
				{
				//alert(window.location);
				discountCost1();
				discountCost2();
				discountCostForm();
				}
			}
		}

function checkHeadRefer()
		{
		var cameFrom
		
		if(window.location.href.indexOf('resource/view.php?id=886') > 0)
			{
			//checkRef()	
			//cameFrom = document.referrer.split('id=');
			cameFrom = document.referrer
			//cameFrom = 'http://www.foriuscommunities.com/course/enrol.php?id=' + cameFrom[1]
			cameFrom += '&cc=cpc621';
				{
				//alert(cameFrom) 
				window.location.replace(cameFrom)
				}
			}
		}
	
function discountCost1()
	{
	var myNode, innerVal, splitVal, discountedCost
	
	myNode = document.getElementById('classcost1');	
	innerVal = document.getElementById('classcost1').innerHTML;
	splitVal = innerVal.split(' ');
	discountedCost = splitVal[2] * .8;
	
	if(discountedCost.toString().indexOf('.') < 0)
		{
		discountedCost += '.00';
		}	
	
	myNode.innerHTML = 'Discounted Cost:  $' + discountedCost;
	}	

function discountCost2()
	{
	var myNode, innerVal, splitVal, discountedCost
	
	myNode = document.getElementById('classcost2');
	innerVal = document.getElementById('classcost2').innerHTML;
	splitVal = innerVal.split('$');
	discountedCost = splitVal[1] * .8;
	
	if(discountedCost.toString().indexOf('.') < 0)
		{
		discountedCost += '.00';
		}	
//	for(i=0; i< splitVal.length; i++)
//		{
//		myNode.innerHTML += splitVal[i] + '<br>'
//		}
/**********************
HIDE THE ACTIVATE LINK
***********************/
	myNode.innerHTML = 'Discounted Cost: $' + discountedCost;
	document.getElementById('activateDiscount').style.visibility='hidden'
	}
	
function discountCostForm()
	{
	var formamount, discountedCost
	formamount = document.myform.amount.value;
	discountedCost = formamount * .8;
	if(discountedCost.toString().indexOf('.') < 0)
		{
		discountedCost += '.00';
		}	
	document.myform.amount.value = discountedCost
	}
	

