 /******************************************************************************
* lib_atvmag.js                                                                *
*                                                                              *
* ATV Magazine v.2 javascript library, form validation functions,              *
*******************************************************************************/

function VerifyContact()
	{
	var email_ad=document.form2.email.value
	

		if (document.form2.name.value == "") 
		{
			alert ("Please enter your name...");
			return false;
		}	
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		} 	
		else
			return true;
		}		
			

 var urlAddress = window.location.href;
 var pageName = "All-Terrain Vehicle Magazine";

/******************************************************************************
AJAX YEARS
******************************************************************************/
var xmlHttp;
var rootpath;
 
rootpath = "http://www.supertraxmag.com/";  
 
function getFormYears(str)
{
    var url=rootpath + "process_getyears.asp?class=" + str
    
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
}
  
function stateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("years").innerHTML=xmlHttp.responseText
    }
}

function GetXmlHttpObject(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 

function fillyears(str) {
    var theform = document.getElementById("frmdefault");
    theform.year.value = str;
}
/*END OF YEARS THING*/


/******************************************************************************
AJAX CLASS
******************************************************************************/

var xmlHttp;
var rootpath;
 
rootpath = "http://www.supertraxmag.com/";  
 
function getFormClass(str)
{
    var url=rootpath + "process_getclass.asp?oem=" + str
    
    xmlHttp=GetXmlHttpObjectClass(stateChangeClass)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
}
  
function stateChangeClass()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("class").innerHTML=xmlHttp.responseText
    }
}

function GetXmlHttpObjectClass(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 

function fillClass(str) {
    var theform2 = document.getElementById("frmdefault");
    theform2.year.value = str;
}
  



/*END OF CLASS THING*/
/******************************************************************************
AJAX SUBS
******************************************************************************/

var xmlHttp;
var srootpath;
 
srootpath = "https://www.supertraxmag.com/subscribe/";  
 
function getFormSubs(str)
{
    var url=srootpath + "process_getsubs.asp?country=" + str
    
    xmlHttp=GetXmlHttpObjectSubs(stateChangeSubs)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
}
  
function stateChangeSubs()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("subs").innerHTML=xmlHttp.responseText
    }
}

function GetXmlHttpObjectSubs(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 

//function fillSubs(str) {
//    var theform2 = document.getElementById("frmdefault");
//    theform2.year.value = str;
//}
  



/*END OF SUBS THING*/


	if (document.images) {
		home1 = new Image
		home2 = new Image

		home1.src = "graphics/topNav/home1.gif"
		home2.src = "graphics/topNav/home2.gif"
	}
	else {
		home1 = ""
		home2 = ""
		document.home = ""
	}
	if (document.images) {
		news1 = new Image
		news2 = new Image

		news1.src = "graphics/topNav/news1.gif"
		news2.src = "graphics/topNav/news2.gif"
	}
	else {
		news1 = ""
		news2 = ""
		document.news = ""
	}
	if (document.images) {
		photos1 = new Image
		photos2 = new Image

		photos1.src = "graphics/topNav/photos1.gif"
		photos2.src = "graphics/topNav/photos2.gif"
	}
	else {
		photos1 = ""
		photos2 = ""
		document.photos = ""
	}
	if (document.images) {
		fieldGuide1 = new Image
		fieldGuide2 = new Image

		fieldGuide1.src = "graphics/topNav/fieldGuide1.gif"
		fieldGuide2.src = "graphics/topNav/fieldGuide2.gif"
	}
	else {
		fieldGuide1 = ""
		fieldGuide2 = ""
		document.fieldGuide = ""
	}
		if (document.images) {
		subscribe1 = new Image
		subscribe2 = new Image

		subscribe1.src = "graphics/topNav/subscribe1.gif"
		subscribe2.src = "graphics/topNav/subscribe2.gif"
	}
	else {
		subscribe1 = ""
		subscribe2 = ""
		document.subscribe = ""
	}
	if (document.images) {
		events1 = new Image
		events2 = new Image

		events1.src = "graphics/topNav/events1.gif"
		events2.src = "graphics/topNav/events2.gif"
	}
	else {
		events1 = ""
		events2 = ""
		document.events = ""
	}
			if (document.images) {
		contact1 = new Image
		contact2 = new Image

		contact1.src = "graphics/topNav/contact1.gif"
		contact2.src = "graphics/topNav/contact2.gif"
	}
	else {
		contact1 = ""
		contact2 = ""
		document.contact = ""
	}
			if (document.images) {
		about1 = new Image
		about2 = new Image

		about1.src = "graphics/topNav/about1.gif"
		about2.src = "graphics/topNav/about2.gif"
	}
	else {
		about1 = ""
		about2 = ""
		document.about = ""
	}

function addToFavorites()
 {
  if (window.external)
  {
   window.external.AddFavorite(urlAddress,pageName)
  }
  else
  { 
   alert("Sorry! Your browser doesn't support this function.");
  }
 }

function VerifyEntry()
	{
	var email_ad=document.form3.email.value
		if (document.form3.fname.value == "")
		{
			alert ("Please enter your full name!");
			return false;
		}
		else if (document.form3.lname.value == "")
		{
			alert ("Please enter your full name!");
			return false;
		}			
		else if (document.form3.street.value == "")
		{
			alert ("Please enter your full mailing address");
			return false;
		}
		else if (document.form3.city.value == "")
		{
			alert ("Please enter your full mailing address");
			return false;
		}
		else if (document.form3.province.value == "")
		{
			alert ("Please enter your full mailing address");
			return false;
		}
		else if (document.form3.postal.value == "")
		{
			alert ("Please enter your full mailing address");
			return false;
		}
		else if (document.form3.phone.value == "")
		{
			alert ("You must enter a phone number at which we may contact you.");
			return false;
		}			
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address");
			return false;
		}
		else if (document.form3.terms.checked == false)
		{
			alert ("You must read the rules and regulations and check the corresponding checkbox to signify your acceptance.");
			return false;
		}																				
		else		
			return true;
	}

function openRules()
{
open ("terms.asp","Rules", "height=400,width=400,scrollbars=yes,location=0,resizable=yes,status=no,border=no")
}
	function VerifySub()
	{
	var email_ad=document.form3.email.value
	var subid = document.form3.pid.value
// only allow up to 2 checkboxes be checked
var checkCounter = 0;
for (i = 0;  i < form3.pid.length;  i++)
{
if (((form3.pid[i].checked) && (form3.pid[i].value == "7")) || ((form3.pid[i].checked) && (form3.pid[i].value == "8")) || ((form3.pid[i].checked) && (form3.pid[i].value == "9")) || ((form3.pid[i].checked) && (form3.pid[i].value == "10")))
checkCounter = checkCounter + 1;
}
if (checkCounter > 1)
{
alert("Sorry, you may only select ONE Christmas special at a time.");
return (false);
}

	
		if ((document.form3.fname.value == "") || (document.form3.lname.value == ""))
		{
			alert ("You must enter your FULL name.");
			return false;
		}
		else if ((document.form3.street.value == "") || (document.form3.city.value == "") || (document.form3.province.value == "") || (document.form3.postal.value == "") || (document.form3.country.value == ""))
		{
			alert ("You must enter the FULL mailing address for the subscriber!");
			return false;
		}
		else if (document.form3.phone.value == "")
		{
			alert ("Please enter your phone number.");
			return false;
		}				
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("You must enter a valid email address.");
			return false;
		}    		
		else
			return true;
		}
		
	function VerifyFriend()
	{
	var email_ad=document.form3.email.value
	
		if ((document.form3.fname.value == "") || (document.form3.lname.value == ""))
		{
			alert ("You must enter your FULL name.");
			return false;
		}
		else if ((document.form3.street.value == "") || (document.form3.city.value == "") || (document.form3.province.value == "") || (document.form3.postal.value == "") || (document.form3.country.value == ""))
		{
			alert ("You must enter the FULL mailing address for the subscriber!");
			return false;
		}
		else if (document.form3.phone.value == "")
		{
			alert ("Please enter your phone number.");
			return false;
		}				
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("You must enter a valid email address.");
			return false;
		}    		
		else
			return true;
		}		

	function VerifySub2()
	{
	var cn=document.form3.cn.value
		if (document.form3.cfname.value == "")
		{
			alert ("Please enter your full name.");
			return false;
		}
		else if (document.form3.cn.value == "")
		{
			alert ("You must enter a valid card number.");
			return false;
		}
		else if ((document.form3.street.value == "") || (document.form3.city.value == "") || (document.form3.province.value == "") || (document.form3.postal.value == "") || (document.form3.country.value == ""))
		{
			alert ("You must enter your FULL billing address!");
			return false;
		}
				
		else
			return true;
		}



 var urlAddress = window.location.href;
 var pageName = "Supertrax International Magazine";

 function addToFavorites()
 {
  if (window.external)
  {
   window.external.AddFavorite(urlAddress,pageName)
  }
  else
  { 
   alert("Sorry! Your browser doesn't support this function.");
  }
 }

function openWebTrek()
{
open ("webtrek/index.asp","WebTrek", "height=524,width=425,scrollbars=yes,location=0,resizable=no,status=no,border=no")
}

function openSubForm()
{
open ("https://www.supertraxmag.com/sub_welcome.asp","Subscriptions", "height=500,width=600,scrollbars=yes,location=0,resizable=no,status=no,border=no")
}

function initMail(form) {
text = "Check out the new ATVMAG.COM: " + window.referrer;
form.message.value = "Hi " + form.sendto.value + " (" + form.to.value + "):\n\n"
 + text + "\n\nYour Friend,\n" + form.sendername.value + "(" + form.senderemail.value + ")";
return (form.to.value != "");
}


function openDisclaimer()
{
open ("popUpDisclaimer.html","Test", "height=400,width=400,scrollbars=no,location=0,resizable=no,status=no,border=no")
}

function openEmailer(urlv)
{
open ("email_page.asp?url="+urlv+"","Emailer", "height=400,width=400,scrollbars=no,location=0,resizable=no,status=no,border=no")
}

function openFeedback()
{
open ("popUpFeedback.html","Test", "height=400,width=400,scrollbars=no,location=0,resizable=no,status=no,border=no")
}

	if (document.images) {
		news1 = new Image
		news2 = new Image

		news1.src = "graphics/topNav/news1.gif"
		news2.src = "graphics/topNav/news2.gif"
	}
	else {
		news1 = ""
		news2 = ""
		document.news = ""
	}
	if (document.images) {
		fanPhotos1 = new Image
		fanPhotos2 = new Image

		fanPhotos1.src = "graphics/topNav/fanPhotos1.gif"
		fanPhotos2.src = "graphics/topNav/fanPhotos2.gif"
	}
	else {
		fanPhotos1 = ""
		fanPhotos2 = ""
		document.fanPhotos = ""
	}
	if (document.images) {
		archives1 = new Image
		archives2 = new Image

		archives1.src = "graphics/topNav/archives1.gif"
		archives2.src = "graphics/topNav/archives2.gif"
	}
	else {
		archives1 = ""
		archives2 = ""
		document.archives = ""
	}
	if (document.images) {
		links1 = new Image
		links2 = new Image

		links1.src = "graphics/topNav/links1.gif"
		links2.src = "graphics/topNav/links2.gif"
	}
	else {
		links1 = ""
		links2 = ""
		document.links = ""
	}
		if (document.images) {
		subscribe1 = new Image
		subscribe2 = new Image

		subscribe1.src = "graphics/topNav/subscribe1.gif"
		subscribe2.src = "graphics/topNav/subscribe2.gif"
	}
	else {
		subscribe1 = ""
		subscribe2 = ""
		document.subscribe = ""
	}
			if (document.images) {
		contact1 = new Image
		contact2 = new Image

		contact1.src = "graphics/topNav/contact1.gif"
		contact2.src = "graphics/topNav/contact2.gif"
	}
	else {
		contact1 = ""
		contact2 = ""
		document.contact = ""
	}
			if (document.images) {
		about1 = new Image
		about2 = new Image

		about1.src = "graphics/topNav/about1.gif"
		about2.src = "graphics/topNav/about2.gif"
	}
	else {
		about1 = ""
		about2 = ""
		document.about = ""
	}
	
function VerifyQContact()
	{
	var email_ad=document.form6.email.value
	

		if ((document.form6.name.value == "") || (document.form6.name.value == "Name"))
		{
			alert ("Please enter your name...");
			return false;
		}	
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		}    			
		else
			return true;
		}		
		
function VerifyMailingList()
	{
	var email_ad=document.form5.email.value
	

		if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		}	   			
		else
			return true;
		}		
		
function VerifyExperts()
	{
	var email_ad=document.form3.email.value
	

		if (document.form3.name.value == "") 
		{
			alert ("Please enter your name...");
			return false;
		}	
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		} 
		else if (document.form3.question.value == "") 
		{
			alert ("Please submit your question.");
			return false;
		} 		
		else
			return true;
		}		
		
function VerifyFanBlog()
	{
	var email_ad=document.form3.email.value
	

		if (document.form3.name.value == "") 
		{
			alert ("Please enter your name...");
			return false;
		}	
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		} 
		else if (document.form3.text.value == "") 
		{
			alert ("Please submit your editorial.");
			return false;
		} 		
		else
			return true;
		}			
if (document.images) {
		homepage1 = new Image
		homepage2 = new Image

		homepage1.src = "graphics/tabs/SetHomepageTab1.gif"
		homepage2.src = "graphics/tabs/SetHomepageTab2.gif"
	}
	else {
		homepage1 = ""
		homepage2 = ""
		document.homepage = ""
	}
	if (document.images) {
		Email1 = new Image
		Email2 = new Image

		Email1.src = "graphics/tabs/EmailAFriendTab1.gif"
		Email2.src = "graphics/tabs/EmailAFriendTab2.gif"
	}
	else {
		Email1 = ""
		Email2 = ""
		document.Email = ""
	}
	if (document.images) {
		bookmark1 = new Image
		bookmark2 = new Image

		bookmark1.src = "graphics/tabs/bookmarkTab1.gif"
		bookmark2.src = "graphics/tabs/bookmarkTab2.gif"
	}
	else {
		bookmark1 = ""
		bookmark2 = ""
		document.bookmark = ""
	}

//NEW SUBSCRIPTION APP VALIDATION
function VerifySubNew()
	{

var checkCounter2 = 0;
for (i = 0;  i < form3.pid.length;  i++)
{
if (document.form3.pid[i].checked) {
checkCounter2 = checkCounter2 + 1;
}
}
if (checkCounter2 == 0)
{
alert("You must select a subscription offer to continue.");
return (false);
}

var email_ad=document.form3.email.value
	

		if ((document.form3.fname.value == "") || (document.form3.lname.value == ""))
		{
			alert ("Please enter the full name of the subscriber");
			return false;
		}	
		else if ((document.form3.address1.value == "") || (document.form3.city.value == "") || (document.form3.postal.value == ""))
		{
			alert ("Please enter your full mailing address.");
			return false;
		} 
		else if (document.form3.phone.value == "")
		{
			alert ("Please enter your phone number.");
			return false;
		} 
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		} 
		else if ((document.form3.ccname.value == "") || (document.form3.ccnum.value == ""))
		{
			alert ("Please complete your credit card information.");
			return false;
		} 		
		else
			return true;

			
		}			
		
	if (document.images) {
		index1 = new Image
		index2 = new Image

		index1.src = "graphics/topNav/homeBtn1.jpg"
		index2.src = "graphics/topNav/homeBtn2.jpg"
	}
	else {
		index1 = ""
		index2 = ""
		document.index = ""
	}
	if (document.images) {
		news1 = new Image
		news2 = new Image

		news1.src = "graphics/topNav/newsBtn1.jpg"
		news2.src = "graphics/topNav/newsBtn2.jpg"
	}
	else {
		news1 = ""
		news2 = ""
		document.news = ""
	}
	if (document.images) {
		video1 = new Image
		video2 = new Image

		video1.src = "graphics/topNav/videoBtn1.jpg"
		video2.src = "graphics/topNav/videoBtn2.jpg"
	}
	else {
		video1 = ""
		video2 = ""
		document.video = ""
	}
	if (document.images) {
		photos1 = new Image
		photos2 = new Image

		photos1.src = "graphics/topNav/photosBtn1.jpg"
		photos2.src = "graphics/topNav/photosBtn2.jpg"
	}
	else {
		photos1 = ""
		photos2 = ""
		document.photos = ""
	}
		if (document.images) {
		guide1 = new Image
		guide2 = new Image

		guide1.src = "graphics/topNav/guideBtn1.jpg"
		guide2.src = "graphics/topNav/guideBtn2.jpg"
	}
	else {
		guide1 = ""
		guide2 = ""
		document.guide = ""
	}
	if (document.images) {
		events1 = new Image
		events2 = new Image

		events1.src = "graphics/topNav/eventsBtn1.jpg"
		events2.src = "graphics/topNav/eventsBtn2.jpg"
	}
	else {
		events1 = ""
		events2 = ""
		document.events = ""
	}
			if (document.images) {
		links1 = new Image
		links2 = new Image

		links1.src = "graphics/topNav/linksBtn1.jpg"
		links2.src = "graphics/topNav/linksBtn2.jpg"
	}
	else {
		links1 = ""
		links2 = ""
		document.links = ""
	}
		if (document.images) {
		contact1 = new Image
		contact2 = new Image

		contact1.src = "graphics/topNav/contactBtn1.jpg"
		contact2.src = "graphics/topNav/contactBtn2.jpg"
	}
	else {
		contact1 = ""
		contact2 = ""
		document.contact = ""
	}
	
	if (document.images) {
		about1 = new Image
		about2 = new Image

		about1.src = "graphics/topNav/aboutBtn1.jpg"
		about2.src = "graphics/topNav/aboutBtn2.jpg"
	}
	else {
		about1 = ""
		about2 = ""
		document.about = ""
	}
			if (document.images) {
		webtrek1 = new Image
		webtrek2 = new Image

		webtrek1.src = "graphics/topNav/webtrekBtn1.jpg"
		webtrek2.src = "graphics/topNav/webtrekBtn2.jpg"
	}
	else {
		webtrek1 = ""
		webtrek2 = ""
		document.webtrek = ""
	}		
		
//PROMO FORM VALIDATION
function VerifyPromo()
	{



var email_ad=document.form3.email.value
	

		if ((document.form3.fname.value == "") || (document.form3.lname.value == ""))
		{
			alert ("Please enter the full name of the subscriber");
			return false;
		}	
		else if ((document.form3.address1.value == "") || (document.form3.city.value == "") || (document.form3.postal.value == ""))
		{
			alert ("Please enter your full mailing address.");
			return false;
		} 
		else if (document.form3.phone.value == "")
		{
			alert ("Please enter your phone number.");
			return false;
		} 
		else if ((email_ad.indexOf("@")==-1) || (email_ad.indexOf(".")==-1))
		{
			alert ("Please enter a valid email address.");
			return false;
		} 		
		else
			return true;

			
		}					