//Regatta Global Javascript Functions

// General Website Functions

// 2010
	function checkCommentPhoto(whichPanel)
	{
		var theForm = eval("document.forms."+whichPanel + "_comment_form");
		var thisBlogId = theForm.PhotoCommentBlogId.value;
		var thisUserId = theForm.PhotoCommentUser.value;
		if (trimStr(theForm.PhotoCommentText.value) == "")
		{
			alert("Please provide text for your comment");
			theForm.PhotoCommentText.focus();
			theForm.PhotoCommentText.select();
			return false;  	
		}
		
		var thisComment = theForm.PhotoCommentText.value;	
		postCommentsPhoto(thisBlogId,whichPanel + '_posts_make_comment',thisUserId,whichPanel,thisComment);
		return false;
		
	}

	function postCommentsPhoto(id,HintElement,user,whichPanel,comment)
	{
 
		HintContainer = HintElement;

		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		var url="postComments.asp";
		url+="?blog="+id;
		url+="&user="+user;
		url+="&comment="+comment;
		url+="&h="+Math.random();

		xmlHttp.onreadystatechange=stateChangedComment;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

		getComments(id,whichPanel + '_all_comments_area');
		show_info_panels(whichPanel,'all_comments');
	}
	
	function checkCommentMovie(whichPanel)
	{
		var theForm = eval("document.forms."+whichPanel + "_comment_form");
		var thisBlogId = theForm.VideoCommentBlogId.value;
		var thisUserId = theForm.VideoCommentUser.value;
		if (trimStr(theForm.VideoCommentText.value) == "")
		{
			alert("Please provide text for your comment");
			theForm.VideoCommentText.focus();
			theForm.VideoCommentText.select();
			return false;  	
		}
		
		var thisComment = theForm.VideoCommentText.value;	
		postCommentsMovie(thisBlogId,whichPanel + '_posts_make_comment',thisUserId,whichPanel,thisComment);
		return false;
		
	}

	function postCommentsMovie(id,HintElement,user,whichPanel,comment)
	{
 
		HintContainer = HintElement;

		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		var url="postComments.asp";
		url+="?blog="+id;
		url+="&user="+user;
		url+="&comment="+comment;
		url+="&h="+Math.random();

		xmlHttp.onreadystatechange=stateChangedComment;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

		getComments(id,whichPanel + '_all_comments_area');
		show_info_panels(whichPanel,'all_comments');
	}
	
	function deleteCommentsMovie(id, HintElement, whichPanel, VideoID)
	{
 
		HintContainer = HintElement;

		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		var url="post-process.asp?comm=" + id + "&task=delete";
		
		xmlHttp.onreadystatechange=stateChangedComment;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

		getComments(VideoID,whichPanel + '_all_comments_area');
		show_info_panels(whichPanel,'all_comments');
	}
	
	/*********************************************
AJAX
/*********************************************/

	var HintContainer = "";

	function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
		// Internet Explorer
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}


	function stateChanged() 
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
			ajaxResponseText=xmlHttp.responseText;
		}
	}
//*************************************************


//************************************************
// RATINGS
//************************************************

	var ArcTopLat;
		ArcTopLat = "";
	var xmlHttp2;

	function getRating(id,ATL)
	{
		xmlHttp2=GetXmlHttpObject()
		if (xmlHttp2==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		
		ArcTopLat = ATL;

		var url="getRating.asp?post="+id;
		xmlHttp2.onreadystatechange=stateChangedRating;
		xmlHttp2.open("GET",url,true);
		xmlHttp2.send(null);

	}

	function stateChangedRating() 
	{
		
		if (xmlHttp2.readyState==4)
		{ 
			document.getElementById(ArcTopLat).innerHTML=xmlHttp2.responseText;
			ajaxResponseText=xmlHttp2.responseText;
		}
	}

	function postRating(id,rating)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		var url="postRating.asp?task=ratePost&post="+id+"&rate="+rating;
		xmlHttp.onreadystatechange=stateChangedRating;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		var x = setTimeout("getRating("+id+","+ArcTopLat+")", 2000);
	}

//************************************************
// COMMENTS
//************************************************
	var ajaxResponseText = "";

	function getComments(id,HintElement)
	{
 
		HintContainer = HintElement;
		//alert(HintElement);
		//	document.getElementById(HintElement).innerHTML="<img src='images/loading.gif' valign='middle' /> &nbsp;&nbsp;searching ...";
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Your browser does not support AJAX!");
				return;
			} 
			var url="getComments.asp";
			url=url+"?id="+id;//+str;
			url=url+"&sid="+Math.random()
			xmlHttp.onreadystatechange=stateChangedComment;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);

		//}
	}


	var commentContentA = "<div id=\"PhotoCommentContentA\" style=\"width:100%; height: 180px; overflow: hidden\">";
	var commentFooterControlA = "</div><div class=\"clear\"></div>";
	commentFooterControlA+= "<div id=\"photo_comments_footA\">";
	commentFooterControlA+= "	<img onmouseover=\"scroll_down('PhotoCommentContentA');\" onmouseout=\"stop_scroll();\" src=\"images/buttons/arrow_down.jpg\" class=\"activeImage\" />";
	commentFooterControlA+= "	<img onmouseover=\"scroll_up('PhotoCommentContentA');\" onmouseout=\"stop_scroll();\" src=\"images/buttons/arrow_up.jpg\" class=\"activeImage\" />";
	commentFooterControlA+= "</div>";

	var commentContentT = "<div id=\"PhotoCommentContentT\" style=\"width:100%; height: 180px; overflow: hidden\">";
	var commentFooterControlT = "</div><div class=\"clear\"></div>";
	commentFooterControlT+= "<div id=\"photo_comments_footT\">";
	commentFooterControlT+= "	<img onmouseover=\"scroll_down('PhotoCommentContentT');\" onmouseout=\"stop_scroll();\" src=\"images/buttons/arrow_down.jpg\" class=\"activeImage\" />";
	commentFooterControlT+= "	<img onmouseover=\"scroll_up('PhotoCommentContentT');\" onmouseout=\"stop_scroll();\" src=\"images/buttons/arrow_up.jpg\" class=\"activeImage\" />";
	commentFooterControlT+= "</div>";
	
	var commentContentL = "<div id=\"PhotoCommentContentL\" style=\"width:100%; height: 180px; overflow: hidden\">";
	var commentFooterControlL = "</div><div class=\"clear\"></div>";
	commentFooterControlL+= "<div id=\"photo_comments_footL\">";
	commentFooterControlL+= "	<img onmouseover=\"scroll_down('PhotoCommentContentL');\" onmouseout=\"stop_scroll();\" src=\"images/buttons/arrow_down.jpg\" class=\"activeImage\" />";
	commentFooterControlL+= "	<img onmouseover=\"scroll_up('PhotoCommentContentL');\" onmouseout=\"stop_scroll();\" src=\"images/buttons/arrow_up.jpg\" class=\"activeImage\" />";
	commentFooterControlL+= "</div>";

	function stateChangedComment() 
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById(HintContainer).innerHTML=xmlHttp.responseText;
			ajaxResponseText=xmlHttp.responseText;
		}
	}

	function postCommentsPhotoVERSIONONE(id,HintElement,user)
	{
 
		HintContainer = HintElement;

		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		var url="postComments.asp";
		url+="?blog="+document.getElementById("PhotoCommentBlogId").value;
		url+="&user="+document.getElementById("PhotoCommentUser").value;
		url+="&comment="+document.getElementById("PhotoCommentText").value;
		url+="&h="+Math.random();//+hiddenResultField;
		//alert(url);
		
		//var strTempElementContent;
		//strTempElementContent = document.getElementById(HintElement).innerHTML
		//alert(strTempElementContent);
		
		//document.getElementById(HintElement).innerHTML="<img src='images/loading.gif' valign='middle' /> &nbsp;&nbsp;posting your comment ...";

		xmlHttp.onreadystatechange=stateChangedComment;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

		getComments(document.getElementById("PhotoCommentBlogId").value,'latest_photo_posts_all_comments');
		//document.getElementById(HintElement).innerHTML = ajaxResponseText+strTempElementContent;
		show_info_panels('latest_photo_posts','all_comments');
	}

//************************************************
	function show_info_panels(divGroup,divToShow)
	{
		document.getElementById(divGroup+"_thumbnails").className="hideMe";
		document.getElementById(divGroup+"_all_comments").className="hideMe";
		document.getElementById(divGroup+"_make_comment").className="hideMe";
		
		document.getElementById(divGroup+"_"+divToShow).className="showMe";
		
		if(divToShow == "thumbnails"){
		    document.getElementById(divGroup+"_all_comments").className="showMe";
		   }
		if(divToShow == "all_comments"){
		    document.getElementById(divGroup+"_all_comments_area").className=divGroup+"_all_comments_area_long";
		}else{
		    document.getElementById(divGroup+"_all_comments_area").className=divGroup+"_all_comments_area";
        }
		return false;
	}
	function changePhoto(id,src, ArcTopLat,postId,photoTitle){
		if(src != "" && elementExists(id))
		{
			var img = new Image();
			img.src = "user-images/" + src + "-post-photo.jpg";
			var imgWidth;
			var imgHeight;
			
			imgWidth = img.width;
			imgHeight = img.height;
			document.getElementById(id).src = img.src;
		}
		
		if(id != "")
		{
			document.getElementById("PhotoCommentBlogIdArc").value = src;
			document.getElementById("currentPhotoTitle").innerHTML = photoTitle;
			getComments(src,'photo_archive_all_comments_area');
			for(i=0;i<=5000;i++){}
			getRating(src,'currentPhotoRatingARC');
		}
	}


	function iLoad(isrc, id) {
	var oImg = new Image();
	oImg.src = isrc;
		if (oImg.complete) {
			//window.alert(oImg.src + ' ' + oImg.width + ' x ' + oImg.height);
			//alert(oImg.src + " - " + oImg.width);
			document.getElementById(id).src=oImg.src;
			document.getElementById(id).width=oImg.width;
			//alert(id);
		}else {
			window.setTimeout('iLoad(isrc, id)', 1000);
		}
		
	}

	function controlPhotoListPanels(whichPanel)
	{
		document.getElementById("photo_archive").className="panel_closed";
		document.getElementById("photo_archive_content").className="hideMe";
		
		document.getElementById(whichPanel).className="panel";
		document.getElementById(whichPanel + "_content").className="showMe";
	}
 //**********************************************
 // MOVIES
 // *********************************************
	function changeMovie(id,src,ArcTopLat,postId,VideoTitle){
		document.getElementById(id).height="350px";
		document.getElementById(id).width="604px";
		
		if(src.substring(0, 7) == "http://" || src.substring(0, 3) == "www"){
			//alert(id + " " + src);
			//src = src;
		}else{
			src = "http://www.youtube.com/v/"+src+"&rel=0";
		}
				
		swfobject.embedSWF(src, id, "604", "350", "9.0.0");
		
		if(id != "")
		{
			switch(ArcTopLat.toLowerCase())
			{
				case "arc":
					document.getElementById("VideoCommentBlogIdArc").value = postId;
					document.getElementById("currentVideoTitle").innerHTML = VideoTitle;
					getComments(postId,'video_archive_all_comments_area');
					for(i=0;i<=5000;i++){}
					getRating(postId,'currentVideoRatingARC');
					break;

				case "top":
					document.getElementById("VideoCommentBlogIdTop").value = postId;
					getComments(postId,'top_rated_videos_all_comments');
					for(i=0;i<=5000;i++){}
					getRating(postId,'currentVideoRatingTOP');
					break;

				case "lat":
					document.getElementById("VideoCommentBlogIdLat").value = postId;
					getComments(postId,'latest_video_posts_all_comments');
					for(i=0;i<=5000;i++){}
					getRating(postId,'currentVideoRatingLAT');
					break;

				default:
					document.getElementById("VideoCommentBlogIdLat").value = postId;
					getComments(postId,'latest_video_posts_all_comments');
					for(i=0;i<=5000;i++){}
					getRating(postId,'currentVideoRatingLAT');
					break;
			}
		}
		
	}



	function getYouTubeScreen( url, size, elemId)
	{
	  if(url === null){ return ""; }
	
	  size = (size === null) ? "big" : size;
	  var vid;
	  var results;
	
	  results = url.match("[\\?&]v=([^&#]*)");
	
	  vid = ( results === null ) ? url : results[1];
	
	  if(size == "small"){
		  if(elemId != "")
		  {
			  document.getElementById(elemId).src= "http://img.youtube.com/vi/"+vid+"/2.jpg";
		  }else{
			  return "http://img.youtube.com/vi/"+vid+"/2.jpg";
		  }
		
	  }else {
		   if(elemId != "")
		  {
			  document.getElementById(elemId).src= "http://img.youtube.com/vi/"+vid+"/0.jpg";
		  }else{
				return "http://img.youtube.com/vi/"+vid+"/0.jpg";
		  }
	  }
	}


	function controlVideoListPanels(whichPanel)
	{
		document.getElementById("video_archive").className="panel_closed";
		document.getElementById("video_archive_content").className="hideMe";
		
		document.getElementById(whichPanel).className="panel";
		document.getElementById(whichPanel + "_content").className="showMe";
	}
 
 
 
  // *********************************************
 /*BEGIN TEMP SCROLL SCRIPT 2*/
 // *********************************************
     var scrolling = null;
  
     function scroll_up(divid) {
         var d = document.getElementById(divid);
  
         d.scrollTop = d.scrollTop - 1;
  
         scrolling = window.setTimeout(function() {
             scroll_up(divid);
         }, 10);
     }
  
     function scroll_down(divid) {
         var d = document.getElementById(divid);
  
         d.scrollTop = d.scrollTop + 1;
  
         scrolling = window.setTimeout(function() {
             scroll_down(divid);
         }, 10);
     }
  
     function stop_scroll() {
         window.clearTimeout(scrolling);
     }
	 
/*END TEMP SCROLL SCRIPT 2*/

var baseHref = "";
var menuImageArray = new Array(10);

	function clearText(elementId,textValue)
	{
		if(document.getElementById(elementId).value == textValue)
		{
			document.getElementById(elementId).value = "";
		}
	}

	function replace_html(el, html) {
		if( el ) {
					var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
					var newEl = document.createElement(oldEl.nodeName);
	
					// Preserve any properties we care about (id and class in this example)
					newEl.id = oldEl.id;
					newEl.className = oldEl.className;
	
					//set the new HTML and insert back into the DOM
					newEl.innerHTML = html;
					if(oldEl.parentNode)
						oldEl.parentNode.replaceChild(newEl, oldEl);
					else
					oldEl.innerHTML = html;
	
					//return a reference to the new element in case we need it
					return newEl;
		}
	}

	function elementExists(elementId)
	{
		var elementExists = document.getElementById(elementId);
			if (elementExists != null)
			{
				elementExists = true;
			}else{
				elementExists = false;	
			}
			return elementExists;
	}

	function submitForm(strFormId)
	{
		if(strFormName !="")
		{
			document.getElementById(strFormId).submit();
		}
	}
	function movePage(pageNum)
	{
		document.getElementById("page").value=pageNum;
		document.getElementById("product-search-results-form").submit();
	}

	
	function submitForm(strFormName)
	{
		if(strFormName !="")
		{
			//document.getElementById(strFormName).submit();
			eval("document.forms."+strFormName).submit();
		}
	}
	function movePage(pageNum,frmName)
	{
		document.getElementById("page").value=pageNum;
		document.getElementById(frmName).submit();
	}

//--------------------------------------------------------------------------------------------//

function pageRelocateTo(goToPage)
{
	if(goToPage != ""){
		document.location.href = goToPage;	
	}	
}

//--Check for valid Email Address
function checkemailaddress(inputbox){

	var teststring 
	teststring = inputbox.toString()

	if(inputbox == ""){
		return 1002
	}

	if(teststring.length <= 6){
		return 1002
	}

	var illegalchrs = new Array("*","£","$","!")
	var counter
	
	for(counter=0;counter<=illegalchrs.length;counter++){
		if(teststring.indexOf(illegalchrs[counter]) != -1){
			return 1002
		}
	}

	var atpositionback = teststring.lastIndexOf("@")
	var dotpositionback = teststring.lastIndexOf(".")
	var atpositionfront = teststring.indexOf("@")

	if(atpositionback == -1){
		return 1002
	}

	if(dotpositionback == -1){
		return 1002
	}

	if(atpositionfront != atpositionback){
		return 1002
	}

	if(atpositionback > dotpositionback){
		return 1002
	}

	return 0
}

/*Image PreLoader*/
	function loadImages(imageArray)
	{
		var p=imageArray.length;
		var preLoad = new Array();
		for (i=0; i<p; i++)
		{
			preLoad[i] = new Image();
			preLoad[i].src = imageArray[i];
		}
	}
	
/*IMAGE SWAP*/
	function swapImages(elementId,imageSource)
	{

		var elementExists = document.getElementById(elementId);
		if (elementExists != null)
		{
			document.getElementById(elementId).src = imageSource;
		}
	}

/*show / hide layer*/
	function showHideContent(divid)
	{

		if(document.getElementById(divid).style.display == '')
		{
			document.getElementById(divid).style.display = 'none';
		}else{
			document.getElementById(divid).style.display = '';
		}

	}

/*Relocate*/
	function relocate(url)
	{
		if(url !="")
		{
			document.location.href = url;
		}
	}
/*SET FOCUS*/
	function setFocus(elementId)
	{
		var elementExists = document.getElementById(elementId);
		if (elementExists != null)
		{
				document.getElementById(elementId).focus();
		}
	}
    
/*VALIDATORS*/
	function checkForm(fieldString)
	{ 
			
		if(fieldString != "")
		{
			var dottedLine = "---------------------------------------\n";
			var alertMessage = dottedLine;
			alertMessage += " Please complete the following information\n";
			alertMessage += dottedLine;
			var originalAlert = alertMessage;
			var fieldArray = fieldString.split("^");
			var firstFieldToFocus = "";
			for(f = 0; f < fieldArray.length; f++)
			{
				if(document.getElementById(fieldArray[f]).value == "" || document.getElementById(fieldArray[f]).value == fieldArray[f])
				{
					alertMessage += "\n ** " + fieldArray[f].replace("_", " ");
					if(firstFieldToFocus == "")
					{
						firstFieldToFocus = fieldArray[f];
					}
				}
			}
			
			if(alertMessage != originalAlert)
			{
				alertMessage += "\n\n" + dottedLine;
				alert(alertMessage);
				setFocus(firstFieldToFocus);
				return false;
			}
			
		}else{
			return false;
		}
	}

// Cascading Navigation Menu
//--------------------------------------------------------------------------------------------//

// Get Browser Width
function getViewportWidth () {
    var viewportWidth;
    if (typeof window.innerWidth != 'undefined'){
        viewportWidth = window.innerWidth
    }else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){
        viewportWidth = document.documentElement.clientWidth
    }else{
        viewportWidth = document.getElementsByTagName('body')[0].clientWidth
    }
	return viewportWidth;
}

//----------------------------------------
// TEMPORARY TESTING
// Navigation Drop-Downs 
function showProductClasses1 () {
	menuLeft = Math.round((getViewportWidth()/2)-280);
	menuLeft = menuLeft + 105;
	x = document.getElementById("products_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("product_classes1");	
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideProductClasses1 () {
	x = document.getElementById("products_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("product_classes1");
	x.style.visibility = 'hidden';			
}

function showCommunityPages1 () {
	menuLeft = Math.round((getViewportWidth()/2)+220);
	menuLeft = menuLeft + 34;
	x = document.getElementById("community_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("community_pages1");	
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideCommunityPages1 () {
	x = document.getElementById("community_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("community_pages1");
	x.style.visibility = 'hidden';			
}


function showProductRanges1 (pClass) {
	x = document.getElementById(pClass + "_home1");
	x.style.color = "#FFFFFF";		
    x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_ranges1");	
	x.style.visibility = 'visible';	
}

function hideProductRanges1 (pClass) {
	x = document.getElementById(pClass + "_home1");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";		
	x = document.getElementById(pClass + "_ranges1");	
	x.style.visibility = 'hidden';			
}

function showProductTypes1 (pClass, pRange) {
	x = document.getElementById(pClass + "_" + pRange + "_home1");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_" + pRange +  "_types1");	
	x.style.visibility = 'visible';		
	
}

function hideProductType1s1 (pClass, pRange) {	
	x = document.getElementById(pClass + "_" + pRange + "_home1");	
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";	
	x = document.getElementById(pClass + "_" + pRange +  "_types1");	
	x.style.visibility = 'hidden';	
}
//----------------------------------------
var strLanguage = '<%=session("strLanguage")%>';
// Navigation Drop-Downs 
function showProductClasses () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2)-280);
	
	if(strLanguage == "ESP"){
		menuLeft = menuLeft + 400;
		}else{
			menuLeft = menuLeft + 105;
			}
	x = document.getElementById("products_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("product_classes");	
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideProductClasses () {
	x = document.getElementById("products_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("product_classes");
	x.style.visibility = 'hidden';			
}

function showCommunityPages () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2)+220);
	menuLeft = menuLeft + 34;
	x = document.getElementById("community_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("community_pages");	
	x.style.left = "0px";
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideCommunityPages () {
	x = document.getElementById("community_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("community_pages");
	x.style.visibility = 'hidden';			
}

function showContactPages () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2)+320);
	menuLeft = menuLeft + 41;
	x = document.getElementById("contact_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("contact_pages");	
	x.style.left = "0px";
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideContactPages () {
	x = document.getElementById("contact_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("contact_pages");
	x.style.visibility = 'hidden';			
}

function showStockistPages () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2) -108);
	menuLeft = menuLeft + 41;
	x = document.getElementById("stockists_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("stockists_pages");	
	x.style.left = "0px";
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideStockistPages () {
	x = document.getElementById("stockists_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("stockists_pages");
	x.style.visibility = 'hidden';			
}


function showProductRanges (pClass) {
	x = document.getElementById(pClass + "_home");
	x.style.color = "#FFFFFF";		
    x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_ranges");	
	x.style.visibility = 'visible';	
}

function hideProductRanges (pClass) {
	x = document.getElementById(pClass + "_home");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";		
	x = document.getElementById(pClass + "_ranges");	
	x.style.visibility = 'hidden';			
}

function showProductTypes (pClass, pRange) {
	x = document.getElementById(pClass + "_" + pRange + "_home");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_" + pRange +  "_types");	
	x.style.visibility = 'visible';		
	
}

function hideProductTypes (pClass, pRange) {	
	x = document.getElementById(pClass + "_" + pRange + "_home");	
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";	
	x = document.getElementById(pClass + "_" + pRange +  "_types");	
	x.style.visibility = 'hidden';	
}

// Landing Pages Image Montage Roll-overs
//--------------------------------------------------------------------------------------------//

function tileHoverOver (tileID) {
//	x = document.getElementById("tile_" + tileID + "_back");	
//	x.className = "tile_back_1";
//	x = document.getElementById("tile_" + tileID + "_img");	
//	x.className = "tile_img_1";	
  	x = document.getElementById("tile_" + tileID + "_text");
	x.style.visibility = 'visible';		
}

function tileHoverBack (tileID) {
//	x = document.getElementById("tile_" + tileID + "_back");	
//	x.className = "tile_back_0";
//	x = document.getElementById("tile_" + tileID + "_img");	
//	x.className = "tile_img_0";		
  	x = document.getElementById("tile_" + tileID + "_text");
	x.style.visibility = 'hidden';			
}

//function tileHoverOver4Row()
//{
//	document.getElementById("tile_c2r1_4row").style.visibility = 'visible';
//}

//function tileHoverBack4Row()
//{
//	document.getElementById("tile_c2r1_4row").style.visibility = 'hidden';
//}

// Map rollovers
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
		
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
// Map rollovers



// Flag Roll-overs
//--------------------------------------------------------------------------------------------//

function flagOver (flagID) {
    document.getElementById(flagID).src = "../images/flags/" + flagID + "1.jpg";
}

function flagBack (flagID) {
	document.getElementById(flagID).src = "../images/flags/" + flagID + "2.jpg";			
}

//--------------------------------------------------------------------------------------------//

// Name of Code Search
function clearText (divid) {
    document.getElementById(divid).value = "";	
}

function SwopColour(ProductRef,Colour,ColourCode){
document.ProductDetail.MainPicture.src = ProductRef + "-" + ColourCode + "-d.jpg"
document.ProductDetail.CurrentColourCode.value = ColourCode
document.ProductDetail.CurrentColourName.value = Colour
}

var newWindow1 = null;
var newWindow2 = null;
var newWindow3 = null;
var newWindow5 = null;

function OpenWindow1(Item){
	URL = "product-zoom.asp?" + Item
   if(!newWindow1 || newWindow1.closed)	{
        newWindow1 = window.open(URL,"subwin1","height=680,width=530,toolbars=no,status=no,scrollbars=no");
        newWindow1.focus();
   }else{
        newWindow1.close();
        newWindow1 = window.open(URL,"subwin1","height=680,width=530,toolbars=no,status=no,scrollbars=no");
        newWindow1.focus();
   }
}

function OpenWindow2(Item){
	URL = "product-features.asp?" + Item
   if(!newWindow2 || newWindow2.closed)	{
        newWindow2 = window.open(URL,"subwin2","height=450,width=350,toolbars=no,status=no,scrollbars=no");
        newWindow2.focus();
   }else{
        newWindow2.close();
        newWindow2 = window.open(URL,"subwin2","height=450,width=350,toolbars=no,status=no,scrollbars=no");
        newWindow2.focus();
   }
}

function OpenWindow3(Item){
	URL = Item
   if(!newWindow3 || newWindow3.closed)	{
        newWindow3 = window.open(URL,"subwin3","height=700,width=700,toolbars=no,status=no,scrollbars=yes");
        newWindow3.focus();
   }else{
        newWindow3.close();
        newWindow3 = window.open(URL,"subwin3","height=700,width=700,toolbars=no,status=no,scrollbars=yes");
        newWindow3.focus();
   }
}

function OpenWindow5(Item){
	URL = Item
   if(!newWindow5 || newWindow5.closed)	{
        newWindow5 = window.open(URL,"subwin5","height=450,width=420,toolbars=no,status=no,scrollbars=yes");
        newWindow5.focus();
   }else{
        newWindow5.close();
        newWindow5 = window.open(URL,"subwin5","height=450,width=420,toolbars=no,status=no,scrollbars=yes");
        newWindow5.focus();
   }
}

function addtowishlist(ProductCode, ProductRefNo, ProductName){
	alert ("The " + ProductName + " in colour " + document.ProductDetail.CurrentColourName.value + " has been added to your Wishlist");
	document.location.href = "product-wishlist-add.asp?Code=" + ProductCode + "&ColourCode=" + document.ProductDetail.CurrentColourCode.value + "&ColourName=" +  document.ProductDetail.CurrentColourName.value + "&ProductRefNo=" + ProductRefNo + "&ProductName=" + ProductName;
}

/*DEFAULT PAGE ONLOAD*/

/*
var pageOnload = "<%=strOnload%>";

if (window.onload) {
	var func = window.onload;
	window.onload = function() {
		func();
		if(pageOnload != "")
		{
			eval(pageOnload);
		}
	}
} else {
	window.onload = function() {
		if(pageOnload != "")
		{
			eval(pageOnload);
		}
	};
}
*/

function Checkform1(){
	if (document.ENTRY.Surname.value== "" || document.ENTRY.Surname.value== " "){
	     alert ("<%=strErrorMessage015%>")
	     document.ENTRY.Surname.focus();
	     return false;
	}
	if (document.ENTRY.Address1.value== "" || document.ENTRY.Address1.value== " "){
	     alert ("<%=strErrorMessage022%>")
	     document.ENTRY.Address1.focus();
	     return false;
	}
	if (document.ENTRY.Postcode.value== "" || document.ENTRY.Postcode.value== " "){
	     alert ("<%=strErrorMessage023%>")
	     document.ENTRY.Postcode.focus();
	     return false;
	}
	if (document.ENTRY.Telephone.value== "" || document.ENTRY.Telephone.value== " "){
	     alert ("<%=strErrorMessage024%>")
	     document.ENTRY.Telephone.focus();
	     return false;
	}
	if (document.ENTRY.Email.value== "" || document.ENTRY.Email.value== " "){
	     alert ("<%=strErrorMessage017%>")
	     document.ENTRY.Email.focus();
	     return false;
	}
	if(checkemailaddress(document.ENTRY.Email.value)!=0){
		alert("<%=strErrorMessage021%>");
		document.ENTRY.Email.focus();
		return false;
	}
}

function CheckImageForm(){
	if (document.galleryupload.Forename.value== "" || document.galleryupload.Forename.value== " "){
	     alert ("<%= strErrorMessage014%>")
	     document.galleryupload.Forename.focus();
	     return false;
	}
	if (document.galleryupload.Surname.value== "" || document.galleryupload.Surname.value== " "){
	     alert ("<%= strErrorMessage015%>")
	     document.galleryupload.Surname.focus();
	     return false;
	}
	if (document.galleryupload.Town.value== "" || document.galleryupload.Town.value== " "){
	     alert ("<%= strErrorMessage016%>")
	     document.galleryupload.Town.focus();
	     return false;
	}
	if (document.galleryupload.Filename.value== "" || document.galleryupload.Filename.value== " "){
	     alert ("<%= strErrorMessage019%>")
	     document.galleryupload.Filename.focus();
	     return false;
	}
	if (document.galleryupload.Email.value== "" || document.galleryupload.Email.value== " "){
	     alert ("<%= strErrorMessage017%>")
	     document.galleryupload.Email.focus();
	     return false;
	}
	if(checkemailaddress(document.galleryupload.Email.value)!=0){
		alert("<%= strErrorMessage021%>");
		document.galleryupload.Email.focus();
		return false;
		}
	if (document.galleryupload.ConfirmEmail.value != document.galleryupload.Email.value){
	     alert ("<%= strErrorMessage018%>")
	     document.galleryupload.Email.focus();
	     return false;
	}
	if (document.galleryupload.Agree[0].checked){
		}else{
	     alert ("<%= strErrorMessage020%>")
	     return false;
	}
	if (document.galleryupload.Info[0].checked || document.galleryupload.Info[1].checked){
		return true;
	}else{
	     alert ("<%=strPrompt329 & ", " & strPrompt330%>")
	     return false;
	}
	alert ("<%= strPrompt444%>");
}



function BlankField(){
var DefaultValue = "<%=strPrompt400%>"
	if(document.RightHandSearch.ProductSearchName.value== DefaultValue){
		document.RightHandSearch.ProductSearchName.value = ""
		document.RightHandSearch.ProductSearchName.focus();
	}
}

function CheckSearchField(){
	if(document.RightHandSearch.ProductSearchName.value== ""){
		document.RightHandSearch.ProductSearchName.value = " "
	}
}	 

function ProductSearch(){
	Searchclass = document.TopSearch.SearchProduct.value;
	Searchtype = document.TopSearch.SearchType.value;
	document.location.href = "ProductTypeSpecific.asp?SearchType=" + Searchtype + "&Searchclass=" + Searchclass
}

function StockistCountyList(){
	document.location.href='stockist-county.asp?County=' + document.getElementById("county").value;
}

function SubmitImageForm(){
	document.galleryupload.submit();
}

function ChangeCategory(){
	document.ENTRY.Category.value = document.ENTRY.CategorySelect.value
	document.ENTRY.submit();
}

var newMapWindow = null;

function OpenMapWindow(postalcode){
	url = 'stockist-map-popup.asp?PostCode=' + postalcode

	if(!newMapWindow || newMapWindow.closed)	{
		newMapWindow = window.open(url, "mapwin", "height=380, width=355, toolbars=no, status=no, scrollbars=no, resizable=yes");
		newMapWindow.focus();
	}else{
		newMapWindow.close();
		newMapWindow = window.open(url, "mapwin", "height=380, width=355, toolbars=no, status=no, scrollbars=no, resizable=yes");
		newMapWindow.focus();
	}
}

function checkHeadSearch(){

	//alert("Hello: " + document.head_search.button1.value);
	//alert(document.head_search.go1.value);
	return false;
	
		
}

    function StockistPostcode(){
		var postcodeValue = document.getElementById("postcode").value;
	    if (postcodeValue == "" || postcodeValue == " " || postcodeValue == "Enter your postcode"){
		    alert ("Please enter your Postcode for this search")
		    document.getElementById("postcode").focus();
		    return false
		}else{
			document.getElementById("stockistInputForm").action = "regatta-store-locator-by-postcode.asp?"; //Postcode=" + postcodeValue;
			//document.location.href='regatta-store-locator-by-postcode.asp?Postcode=' + postcodeValue;
	    }	
    }

	function StockistCountyList(){
		document.location.href='regatta-store-locator-by-county.asp?County=' + document.getElementById("county").value;
	}

/*--------------------------------------------------------------------
ONLOAD EVENTS
--------------------------------------------------------------------*/

	//onpreload
	var strImages = "";
/*
strImages += baseHref + 'images/navigation/home.jpg,';
	strImages += baseHref + 'images/navigation/home2.jpg,';
	strImages += baseHref + 'images/navigation/home3.jpg,';
	strImages += baseHref + 'images/navigation/mens.jpg,';
	strImages += baseHref + 'images/navigation/mens2.jpg,';
	strImages += baseHref + 'images/navigation/mens3.jpg,';
	strImages += baseHref + 'images/navigation/womens.jpg,';
	strImages += baseHref + 'images/navigation/womens2.jpg,';
	strImages += baseHref + 'images/navigation/womens3.jpg,';
	strImages += baseHref + 'images/navigation/kids.jpg,';
	strImages += baseHref + 'images/navigation/kids2.jpg,';
	strImages += baseHref + 'images/navigation/kids3.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3.jpg,';
	strImages += baseHref + 'images/navigation/locator1.jpg,';
	strImages += baseHref + 'images/navigation/locator2.jpg,';
	strImages += baseHref + 'images/navigation/locator3.jpg';

	strImages += baseHref + 'images/navigation/home_d.jpg,';
	strImages += baseHref + 'images/navigation/home2_d.jpg,';
	strImages += baseHref + 'images/navigation/home3_d.jpg,';
	strImages += baseHref + 'images/navigation/mens_d.jpg,';
	strImages += baseHref + 'images/navigation/mens2_d.jpg,';
	strImages += baseHref + 'images/navigation/mens3_d.jpg,';
	strImages += baseHref + 'images/navigation/womens_d.jpg,';
	strImages += baseHref + 'images/navigation/womens2_d.jpg,';
	strImages += baseHref + 'images/navigation/womens3_d.jpg,';
	strImages += baseHref + 'images/navigation/kids_d.jpg,';
	strImages += baseHref + 'images/navigation/kids2_d.jpg,';
	strImages += baseHref + 'images/navigation/kids3_d.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_d.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_d.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_d.jpg,';
	strImages += baseHref + 'images/navigation/locator1_d.jpg,';
	strImages += baseHref + 'images/navigation/locator2_d.jpg,';
	strImages += baseHref + 'images/navigation/locator3_d.jpg';
	
	strImages += baseHref + 'images/navigation/home_es.jpg,';
	strImages += baseHref + 'images/navigation/home2_es.jpg,';
	strImages += baseHref + 'images/navigation/home3_es.jpg,';
	strImages += baseHref + 'images/navigation/mens_es.jpg,';
	strImages += baseHref + 'images/navigation/mens2_es.jpg,';
	strImages += baseHref + 'images/navigation/mens3_es.jpg,';
	strImages += baseHref + 'images/navigation/womens_es.jpg,';
	strImages += baseHref + 'images/navigation/womens2_es.jpg,';
	strImages += baseHref + 'images/navigation/womens3_es.jpg,';
	strImages += baseHref + 'images/navigation/kids_es.jpg,';
	strImages += baseHref + 'images/navigation/kids2_es.jpg,';
	strImages += baseHref + 'images/navigation/kids3_es.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_es.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_es.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_es.jpg,';
	strImages += baseHref + 'images/navigation/locator1_es.jpg,';
	strImages += baseHref + 'images/navigation/locator2_es.jpg,';
	strImages += baseHref + 'images/navigation/locator3_es.jpg';
	
	strImages += baseHref + 'images/navigation/home_fr.jpg,';
	strImages += baseHref + 'images/navigation/home2_fr.jpg,';
	strImages += baseHref + 'images/navigation/home3_fr.jpg,';
	strImages += baseHref + 'images/navigation/mens_fr.jpg,';
	strImages += baseHref + 'images/navigation/mens2_fr.jpg,';
	strImages += baseHref + 'images/navigation/mens3_fr.jpg,';
	strImages += baseHref + 'images/navigation/womens_fr.jpg,';
	strImages += baseHref + 'images/navigation/womens2_fr.jpg,';
	strImages += baseHref + 'images/navigation/womens3_fr.jpg,';
	strImages += baseHref + 'images/navigation/kids_fr.jpg,';
	strImages += baseHref + 'images/navigation/kids2_fr.jpg,';
	strImages += baseHref + 'images/navigation/kids3_fr.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_fr.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_fr.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_fr.jpg,';
	strImages += baseHref + 'images/navigation/locator1_fr.jpg,';
	strImages += baseHref + 'images/navigation/locator2_fr.jpg,';
	strImages += baseHref + 'images/navigation/locator3_fr.jpg';
	
	strImages += baseHref + 'images/navigation/home_nl.jpg,';
	strImages += baseHref + 'images/navigation/home2_nl.jpg,';
	strImages += baseHref + 'images/navigation/home3_nl.jpg,';
	strImages += baseHref + 'images/navigation/mens_nl.jpg,';
	strImages += baseHref + 'images/navigation/mens2_nl.jpg,';
	strImages += baseHref + 'images/navigation/mens3_nl.jpg,';
	strImages += baseHref + 'images/navigation/womens_nl.jpg,';
	strImages += baseHref + 'images/navigation/womens2_nl.jpg,';
	strImages += baseHref + 'images/navigation/womens3_nl.jpg,';
	strImages += baseHref + 'images/navigation/kids_nl.jpg,';
	strImages += baseHref + 'images/navigation/kids2_nl.jpg,';
	strImages += baseHref + 'images/navigation/kids3_nl.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_nl.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_nl.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_nl.jpg,';
	strImages += baseHref + 'images/navigation/locator1_nl.jpg,';
	strImages += baseHref + 'images/navigation/locator2_nl.jpg,';
	strImages += baseHref + 'images/navigation/locator3_nl.jpg';
*/	
	menuImageArray = strImages.split(",");

	for(n=0; n < menuImageArray.length; n++)
		{
			if(menuImageArray[n] != undefined)
			{
				strImages += baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'1.jpg,';
				strImages += baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'2.jpg,';
				strImages += baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'3.jpg';
				if(n<17){strImages +=","};
			}
		}
	loadImages(strImages);
	
window.onload=function(){

	Nifty('div#column_left,div#column_right','same-height none');

}



/*AW09 references*/
var siteAddress = "";
// var siteAddress = "http://sstest.dare2be.co.uk";

// Trim whitespace from string
function trimStr(str)
{
	//alert(str);
	//return false;
    while(str.charAt(0) == (" ") )	
    {
	    str = str.substring(1);	
    }
    while(str.charAt(str.length-1) == " " )
    {
	    str = str.substring(0,str.length-1);	
    }	
    return str;
}
/*
function setFocus(strFocus)
{

    if (strFocus == "emailLogin"){
	    account_edit.emailLogin.focus();
	    account_edit.emailLogin.select();	
	}
	
    if (strFocus == "passwordUpdate"){
	    account_edit.passwordUpdate.focus();
	    account_edit.passwordUpdate.select();	
	}	
	
	if (strFocus == "firstName"){
	    profile_edit.firstName.focus();
	    profile_edit.firstName.select();	
	}
	
    if (strFocus == "photoTitle"){
	    photo_edit.photoTitle.focus();
	    photo_edit.photoTitle.select();	    	
	}	

    if (strFocus == "videoTitle"){
	    video_edit.videoTitle.focus();
	    video_edit.videoTitle.select();	    	
	}

    if (strFocus == "loginEmail"){
	    user_login.loginEmail.focus();
	    user_login.loginEmail.select();	
	}
	
    if (strFocus == "loginPassword"){
	    user_login.loginPassword.focus();
	    user_login.loginPassword.select();	
	}
	
    if (strFocus == "contactTitle"){
	    contact_us.contactTitle.focus();
	    contact_us.contactTitle.select();	
	}	
}
*/
function goExtBookmark(pageTitle,bmPlatform)
{
	pageUrl = top.location;
	if(pageUrl != "" && pageTitle != "" && bmPlatform != "")
	{	
		var bmUrl;
		switch(bmPlatform)
		{
			case "digg":
				bmUrl = "http://digg.com/submit?phase=2&url="+pageUrl+";title="+pageTitle;
				break;
			case "delicious":
				bmUrl = "http://del.icio.us/post?url="+pageUrl+";title="+pageTitle;
				break;
			case "reddit":
				bmUrl = "http://reddit.com/submit?url="+pageUrl+";title="+pageTitle;
				break;
			case "google":
				bmUrl = "http://www.google.com/bookmarks/mark?op=edit&bkmk="+pageUrl+";title="+pageTitle;
				break;
			case "stumble":
				bmUrl = "http://www.stumbleupon.com/submit?url="+pageUrl+";title="+pageTitle;
				break;
			case "facebook":
				bmUrl = "http://www.facebook.com/sharer.php?u="+pageUrl;
				break;
			case "yahoo":
				bmUrl = "http://myweb2.search.yahoo.com/myresults/bookmarklet?u="+pageUrl+";t="+pageTitle;
				break;
			default:
				bmUrl = "";
				break;
		}
		
		if(bmUrl != "")
		{
			window.open(bmUrl,"bmWindow");		
		}
	}
}

function checkemailaddress(inputbox){

var teststring 
teststring = inputbox.toString()

if(inputbox == ""){
	return 1002
}

if(teststring.length <= 6){
	return 1002
}

var illegalchrs = new Array("*","£","$","!")
var counter
	
for(counter=0;counter<=illegalchrs.length;counter++){
	if(teststring.indexOf(illegalchrs[counter]) != -1){
		return 1002
	}
}

var atpositionback = teststring.lastIndexOf("@")
var dotpositionback = teststring.lastIndexOf(".")
var atpositionfront = teststring.indexOf("@")

if(atpositionback == -1){
	return 1002
}

if(dotpositionback == -1){
	return 1002
}

if(atpositionfront != atpositionback){
	return 1002
}

if(atpositionback > dotpositionback){
	return 1002
}

return 0
}

var newWindow10 = null;

function OpenWindow(Item){
    URL = 'http://www.multimap.com/map/browse.cgi?pc=' + Item
    if(!newWindow10 || newWindow10.closed)	{
        newWindow10 = window.open(URL,"subwin10","height=660,width=960,toolbars=no,status=no,scrollbars=yes,resizable=yes");
        newWindow10.focus();
    }else{
        newWindow10.close();
        newWindow10 = window.open(URL,"subwin10","height=660,width=960,toolbars=no,status=no,scrollbars=yes,resizable=yes");
        newWindow10.focus();
    }
}

function clearPostcode() {
	//document.write("working!");
    document.StockistSearch.postcode.value = "";
	return true
}

function productRateOver (index_id) {
	document.getElementById('rate_' + index_id).src = "assets/buttons/rate_" + index_id + ".gif"	
}

function productRateBack (index_id) {
	document.getElementById('rate_' + index_id).src = "assets/buttons/pig_points_grey.gif"		
}


//**************************************************************************************************
//FROM NETWORK.JS
//**************************************************************************************************
function popup_window (page_name) {
    win1 = window.open(page_name + ".asp", "still","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=460, height=600");
    win1.focus();    
}

// Verify Account Signup
function checkSignup() {
	
    // Check for Contact Email
	if (trimStr(account_edit.emailLogin.value) == "")
    {
        alert("Please provide a contact email");
		account_edit.emailLogin.focus();
		account_edit.emailLogin.select();
	    return false;  	
    } 
	
    // Check for Valid Contact Email
	//if (!validateEmail(trimStr(account_edit.emailLogin.value)))
    //{
        //alert("Sorry, your email address is not valid!");
		//account_edit.emailLogin.focus();
		//account_edit.emailLogin.select();
	    //return false;  	
    //} 	
	
	// Check for Password
	if (trimStr(account_edit.passwordUpdate.value) == "")
	{
        alert("Please provide a password and a confirmation password");
		account_edit.passwordUpdate.focus();
		account_edit.passwordUpdate.select();
	    return false;  		
	}
	
	// Check for Matching Passwords
	if (trimStr(account_edit.passwordUpdate.value) != trimStr(account_edit.passwordConfirm.value))
	{
        alert("Your passwords do not match!");
		account_edit.passwordUpdate.focus();
		account_edit.passwordUpdate.select();
	    return false;  		
	}
	
	if (!account_edit.acceptTerms.checked)
	{
		alert("Please confirm you have read our terms of use");
		account_edit.acceptTerms.focus();	    	
	    return false;  	
	}
	
    return true;	

}

// Verify Account Update
function checkAccount() {
	
    // Check for Contact Email
	if (trimStr(document.getElementById("loginEmail")).value == "")
    {
        alert("Please provide a contact email.");
		document.getElementById("loginEmail").focus();
		document.getElementById("loginEmail").select();
	    return false;  	
    } 
	
    // Check for Valid Email
	if (checkemailaddress(trimStr(document.getElementById("loginEmail")).value)!=0)
    {
        alert("Please provide a valid contact email.");
		document.getElementById("loginEmail").focus();
		document.getElementById("loginEmail").select();
	    return false;  	
    } 	
	
	// Check for Matching Passwords
	if (trimStr(document.getElementById("passwordUpdate").value) != trimStr(document.getElementById("passwordConfirm").value))
	{
        alert("New passwords do not match.");
		document.getElementById("passwordUpdate").focus();
		document.getElementById("passwordUpdate").select();
	    return false;  		
	}
	
    return true;	

}

// Verify Login
function checkLogin() {
	
    // Check for Contact Email
	//alert(":"+trimStr(document.getElementById("loginEmail").value)+":");
	//return false;
	if (trimStr(document.getElementById("loginEmail").value) == "")
    {
        alert("Please provide your email.");
		document.getElementById("loginEmail").focus();
		document.getElementById("loginEmail").select();
	    return false;  	
    } 
	
	// Check for Matching Passwords
	if (trimStr(document.getElementById("loginPassword").value) == "")
	{
        alert("Please provide your password.");
		document.getElementById("loginPassword").focus();
		document.getElementById("loginPassword").select();
	    return false;  		
	}
	
    return true;	
	
}

// Check Profile
function checkProfile() {
	
    // Check for First Name
	if (document.getElementById("firstName").value == "")
    {
        alert("Please provide a first name.");
		document.getElementById("firstName").focus();
		document.getElementById("firstName").select();
	    return false;  	
    } 
	
    // Check for Last Name
	if (document.getElementById("lastName").value == "")
    {
        alert("Please provide a last name.");
		document.getElementById("lastName").focus();
		document.getElementById("lastName").select();
	    return false;  	
    } 	
	
	if (document.getElementById("sex").value == "")
    {
        alert("Please indicate your sex.");
		document.getElementById("sex").focus();
	    return false;  	
    } 	
	
	if (document.getElementById("ageGroup").value == "")
    {
        alert("Please indicate your age group.");
		document.getElementById("ageGroup").focus();
	    return false;  	
    } 	
	
    return true;	

}

// Check Video
function checkVideoNew() {
	
    // Check for First Name
	if (trimStr(document.getElementById("videoTitle").value) == "")
    {
        alert("Please provide a title for this video");
		document.getElementById("videoTitle").focus();
		document.getElementById("videoTitle").select();
	    return false;  	
    } 
	
	if (trimStr(document.getElementById("videoLink").value) == "")
    {
        alert("Please provide a link to this video");
		document.getElementById("videoLink").focus();
		document.getElementById("videoLink").select();
	    return false;  	 	
    } 	
	
    return true;	
	
}

// Check Video
function checkVideoEdit() {
	
    // Check for First Name
	if (trimStr(document.getElementById("videoTitle").value) == "")
    {
        alert("Please provide a title for this video");
		document.getElementById("videoTitle").focus();
		document.getElementById("videoTitle").select();
	    return false;  	
    } 
	
    return true;	
	
}

// Check Icon New
function checkIconNew() {
	
    // Check for First Name
	if (trimStr(document.getElementById("photoFile").value) == "")
    {
        alert("Please upload a photo file");
		document.getElementById("photoFile").focus();
		document.getElementById("photoFile").select();
	    return false;  	
    } 	
	
	if (!icon_add.acceptTerms.checked)
	{
		alert("Please confirm this photo does not violate our terms of use");
		document.getElementById("acceptTerms").focus();	    	
	    return false;  	
	}		
	
    return true;	
	
}

// Check Icon New
function checkIcon() {
	
    // Check for First Name
	if (trimStr(photo_edit.photoFile.value) == "")
    {
        alert("Please upload a photo file");
		document.getElementById("photoFile").focus();
		document.getElementById("photoFile").select();
	    return false;  	
    } 	
	
	if (!document.getElementById("acceptTerms").checked)
	{
		alert("Please confirm this photo does not violate our terms of use");
		document.getElementById("acceptTerms").focus();	    	
	    return false;  	
	}		
	
    return true;	
	
}


// Check Photo
function checkPhoto() {
	
    // Check for First Name
	if (trimStr(document.getElementById("photoTitle").value) == "")
    {
        alert("Please provide a title for this photo");
		document.getElementById("photoTitle").focus();
		document.getElementById("photoTitle").select();
	    return false;  	
    } 
	
	if ((trimStr(document.getElementById("photoFile").value) == "") && (document.getElementById("id").value == 0))
    {
        alert("Please upload a photo file");
		document.getElementById("photoFile").focus();
		document.getElementById("photoFile").select();
	    return false;  	 	
    } 	
	
	if ((!document.getElementById("acceptTerms").checked) && (document.getElementById("id").value == 0))
	{
		alert("Please confirm this photo does not violate our terms of use");
		document.getElementById("acceptTerms").focus();	    	
	    return false;  	
	}	
	
    return true;	
	
}

// Check Photo
function checkPhotoNew() {
	
    // Check for First Name
	if (trimStr(document.getElementById("photoTitle").value) == "")
    {
        alert("Please provide a title for this photo");
		document.getElementById("photoTitle").focus();
		document.getElementById("photoTitle").select();
	    return false;  	
    } 
	
	// Check new Photo complies with terms 
	if (trimStr(document.getElementById("photoFile").value) == "")
    {
		alert("Please upload a photo image file");
		document.getElementById("photoFile").focus();	    	
	    return false;  
	} 
	
	if (document.getElementById("acceptTerms").checked == false)
	{
		alert("Please confirm this photo does not violate our terms of use");
		document.getElementById("acceptTerms").focus();	    	
	    return false;    	
	}	
	
	// Check new Photo complies with terms 
	//if ((trimStr(photo_edit.photoFile.value) != "") && (!photo_edit.acceptTerms.checked))
    //{
		//alert("Please confirm this photo does not violate our terms of use");
		//photo_edit.acceptTerms.focus();	    	
	    //return false;   	
    //} 	
	
    return true;	
	
}

// Check Blog
function checkBlogNew() {
	
    // Check for Blog Title
	if (trimStr(document.getElementById("blogTitle").value) == "")
    {
        alert("Please provide a title for this blog");
		document.getElementById("blogTitle").focus();
		document.getElementById("blogTitle").select();
	    return false;  	
    } 
	
	if (trimStr(document.getElementById("blogAbout").value) == "")
    {
        alert("Please provide a description of this blog");
		document.getElementById("blogAbout").focus();
		document.getElementById("blogAbout").select();
	    return false;  	
    } 	
	
    return true;	
	
}

function checkBlogEdit() {
	
    // Check for Blog Title
	if (trimStr(document.getElementById("blogTitle").value) == "")
    {
        alert("Please provide a title for this blog");
		document.getElementById("blogTitle").focus();
		document.getElementById("blogTitle").select();
	    return false;  	
    } 
	
	if (trimStr(document.getElementById("blogAbout").value) == "")
    {
        alert("Please provide a description of this blog");
		document.getElementById("blogAbout").focus();
		document.getElementById("blogAbout").select();
	    return false;  	
    } 	
		
	
    return true;	
	
}

function checkTextPost() {

    // Check for Title
	if (trimStr(document.getElementById("textTitle").value) == "")
    {
        alert("Please provide a title for this post");
		document.getElementById("textTitle").focus();
		document.getElementById("extTitle").select();
	    return false;  	
    } 
	
	// Check for Entry
	if (trimStr(text_edit.textEntry.value) == "")
    {
        alert("Please provide the text for this post");
		document.getElementById("textEntry").focus();
		document.getElementById("textEntry").select();
	    return false;  	
    } 	
	
	return true;
	
}

// Check Photo
function checkPhotoEdit() {
	
    // Check for First Name
	if (trimStr(document.getElementById("photoTitle").value) == "")
    {
        alert("Please provide a title for this photo");
		document.getElementById("photoTitle").focus();
		document.getElementById("photoTitle").select();
	    return false;  	
    } 
	
	// Check new Photo complies with terms 
	if (trimStr(document.getElementById("photoFile").value) != "")
    {
		if (document.getElementById("acceptTerms").checked == false)
		{
		    alert("Please confirm this photo does not violate our terms of use");
		    document.getElementById("acceptTerms").focus();	    	
	        return false;    	
		}
	} 		
	
	// Check new Photo complies with terms 
	//if ((trimStr(photo_edit.photoFile.value) != "") && (!photo_edit.acceptTerms.checked))
    //{
		//alert("Please confirm this photo does not violate our terms of use");
		//photo_edit.acceptTerms.focus();	    	
	    //return false;   	
    //} 	
	
    return true;	
	
}

function deletePost(postType){

    if (confirm("Delete this " + postType + " permanently?")){
        return true;	
    }
    return false;
	
}

function deleteBlog(blogTitle){

    if (confirm("Delete blog" + blogTitle + " permanently?")){
        return true;	
    }
    return false;
	
}



function deleteAccount(){

    if (confirm("This will delete this account")){
        return true;	
    }
    return false;
	
}

function checkEntry(){

	if (trimStr(document.getElementById("blogEntry").value) == "")
    {
        alert("Please provide some text for this blog entry");
		document.getElementById("blogEntry").focus();
		document.getElementById("blogEntry").select();
	    return false;  	
    } 
	
	return true;
	
}

function checkComment() {
	
	if (trimStr(document.getElementById("commentText").value) == "")
    {
        alert("Please provide text for your comment");
		document.getElementById("commentText").focus();
		document.getElementById("commentText").select();
	    return false;  	
    } 
	
	return true;	
      	
}

function checkReport() {
	
	if (trimStr(document.getElementById("reportText").value) == "")
    {
        alert("Please provide text for your report");
		document.getElementById("reportText").focus();
		document.getElementById("reportText").select();
	    return false;  	
    } 
	
	return true;		
	
}

function showPlay (index_id) {
    document.getElementById('show_' + index_id).style.visibility = "hidden"
	document.getElementById('show_' + index_id).style.height = "0px"
	document.getElementById('play_' + index_id).style.height = "115px"	
    document.getElementById('play_' + index_id).style.visibility = "visible"	
	document.getElementById('link_' + index_id).style.height = "115px"	
    document.getElementById('link_' + index_id).style.visibility = "visible"		
}

function hidePlay (index_id) {
    document.getElementById('link_' + index_id).style.height = "0px"	 
    document.getElementById('link_' + index_id).style.visibility = "hidden"		
    document.getElementById('play_' + index_id).style.height = "0px"	 
    document.getElementById('play_' + index_id).style.visibility = "hidden"
    document.getElementById('show_' + index_id).style.height = "115px"		
    document.getElementById('show_' + index_id).style.visibility = "visible"    	
}

function rateOver (index_id) {
	document.getElementById('rate_' + index_id).src = "images/rate_" + index_id + ".gif"	
}

function rateBack (index_id) {
	document.getElementById('rate_' + index_id).src = "images/pig_points_grey.gif"		
}

function rateOver2 (index_id) {
	document.getElementById('rate2_' + index_id).src = "images/rate_" + index_id + ".gif"	
}

function rateBack2 (index_id) {
	document.getElementById('rate2_' + index_id).src = "images/pig_points_grey.gif"		
}

function play(game) {

	var options  = "toolbar=0,";
	options += "scrollbars=0,";
	options += "location=0,";
	options += "statusbar=0,";
	options += "menubar=0,";
	options += "resizable=0,";
	options += "width=550,";
	options += "height=400,";
	options += "left=300,";
	options += "top=150";

	window.open('http://feedback.dare2b.com/static/DB_DB/play.php?game='+game, 'play', options);
}

function playViral(){
	var options  = "toolbar=0,";
	options += "scrollbars=1,";
	options += "location=0,";
	options += "statusbar=0,";
	options += "menubar=0,";
	options += "resizable=1,";
	options += "width=650,";
	options += "height=700,";
	options += "left=200,";
	options += "top=50";

	window.open('../ViralGame/index.html', 'play', options);
}

function ChangeSubmit(){
	document.icon_add.action = "default.asp";
	document.icon_add.submit();
}	

//**************************************************************************************************


