var totalImages = 8; // Total images used

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function showPic(imgName) 
{
	if (ns3up || ie4up) 
		imgOn = ("images/" + imgName);
		
	document.mainpic.src = imgOn;
}

if(document.images)
{
	mFX = new Array(totalImages);
	for(i = 0; i < mFX.length; i++)
	{
		mFX[i] = new Image();
	}
	
	url = 'http://mammoth-server/PRAEKELT/SMIRNOFF';
	//url = 'http://www.mammothsolutions.co.za/smirnoff';
	
	mFX[0].src = "images/btn-enter.jpg";
	mFX[1].src = "images/btn-enter-over.jpg";
	mFX[2].src = "images/commercial/btn-send.jpg";
	mFX[3].src = "images/commercial/btn-send-over.jpg";
	mFX[4].src = "images/refer/btn-submit.jpg";
	mFX[5].src = "images/refer/btn-submit-over.jpg";
	mFX[6].src = "images/commercial/title-continue.gif";
	mFX[7].src = "images/commercial/title-continue-over.gif";
}

function imgFX(img, num)
{
	if(document.images)
	{
		document.images[img].src = mFX[num].src;
	}
}

function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function validateAge()
{
	fv =  new formValidator();
	
	if (!fv.isSelected("country_name"))
		fv.raiseError("Please enter your Country Name.");
		
	if (!fv.isSelected("birth_day"))
		fv.raiseError("Please enter your Birth Day.");
		
	if (!fv.isSelected("birth_month"))
		fv.raiseError("Please enter your Birth Month.");
		
	if (!fv.isSelected("birth_year"))
		fv.raiseError("Please enter your Birth Year.");
		
	if (!fv.isChecked("t_and_c"))
		fv.raiseError("Please read our Terms and Conditions.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}




function setCookie(c_name,value,expiredays)
{
//var exdate=new Date()
//exdate.setDate(exdate.getDate()+expiredays)
//document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name)
{
/*if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }*/
return ""
}

function checkCookie()
{
//username=getCookie('over18')

if (username!=null && username!="")
  {//fwd to video
  //window.location.href="commercial.html";
  }
}

function getAge() {
	
	if(checkRestricted() == true) {
		alert("Sorry, we are unable to allow you access to our website due to regulations in your country of access. Please leave this website...");
	}
	else {
		

	

var strDOBYear = document.forms["frmAge"].birth_year.value;
var strDOBMonth = document.forms["frmAge"].birth_month.value;
var strDOBDay = document.forms["frmAge"].birth_day.value;
var oDOB = new Date(parseInt(strDOBYear,10), parseInt(strDOBMonth,10)-1, parseInt(strDOBDay,10) );
var strRequiredAge = document.forms["frmAge"].country_name.value.substr(0,2);

var oToday = new Date();

//determine whether the person's birthday has already occurred this year
var boolBirthdayHasOccurred = false;
if (oDOB.getMonth() < oToday.getMonth()) boolBirthdayHasOccurred = true; if ((oDOB.getMonth() == oToday.getMonth()) && (oDOB.getDate() <= oToday.getDate())) boolBirthdayHasOccurred = true;

var nCurrentAge = 0;
if (boolBirthdayHasOccurred)
nCurrentAge = oToday.getFullYear() - oDOB.getFullYear();
else
nCurrentAge = oToday.getFullYear() - oDOB.getFullYear() - 1; 

if (nCurrentAge >= strRequiredAge) {
	//username="over18"  
	//setCookie('over18',username,365)
	return true;
}
else {
	alert("Sorry, you are underage in your country of access");
	return false
}

}

function checkRestricted() {
var strZero = document.forms["frmAge"].country_name.value.substr(0,1);
if (strZero == 0) {
return true;	
}
return false;
}


	}



function validateRefer()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("refer_your_name"))
		fv.raiseError("Please enter Your Name.");
		
	if (fv.isEmpty("refer_your_region"))
		fv.raiseError("Please enter Your Region.");
		
	if (fv.isEmpty("refer_your_city"))
		fv.raiseError("Please enter Your City.");
		
	if (fv.isEmpty("refer_your_cell"))
		fv.raiseError("Please enter Your Cell.");
		
	if (!fv.isSelected("refer_your_age"))
		fv.raiseError("Please enter Your Age.");	
		
	if (!fv.isSelected("refer_your_network"))
		fv.raiseError("Please enter Your Network.");	
		
	if (fv.isEmpty("refer_your_friend1"))
		fv.raiseError("Please specify your Friend's Email Address.");
	else
	{
	if (!fv.isEmailAddress("refer_your_friend1"))
			fv.raiseError("Please specify a valid Email Address.");
	}	
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function openTerms() 
{
	window.open("terms.html", "pops", "scrollbars=yes,resizable=1,height=500,width=560,Left=20,Top=20");
}

function openPrivacy() 
{
	window.open("privacy.html", "pops", "scrollbars=yes,resizable=1,height=500,width=560,Left=20,Top=20");
}

function openRefer() 
{
	window.open("refer.html", "pops", "scrollbars=yes,resizable=1,height=420,width=630");
}

