// <!--
// navigator window reload on resize
function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
	}}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// class swap function
function pviiClassNew(obj, new_style) {
  obj.className=new_style;
}

function mySelect(x)
{
  window.location.href = "/editor/addPage.asp?section=" + x.options[x.selectedIndex].value;
}

function OpenAddPage(section)
	{
	//alert (url);
	//alert (win_name);
		thiswin = window.open("/editor/addPage.asp?section=" + section,"AddWin","height=160,width=600,scrollbars=no,resizable=yes,toolbar=0,location=no");
		thiswin.focus();	
	}

// open windows
function OpenChat()
	{
	//alert (url);
	//alert (win_name);
	if (document.all) { 
		//IE
		thiswin = window.open("/forum/forums.asp","ChatWin","height=590,width=800,scrollbars=yes,resizable=no,toolbar=0,location=1");
		thiswin.focus();				
	} else if (document.layers) {
	  //NS4+ code 
	 	thiswin = window.open("/forum/forums.asp","ChatWin","height=590,width=800,scrollbars=yes,resizable=no,toolbar=yes,location=1,resizable=false");
		thiswin.focus();		
} else if (document.getElementById) {
	  //NS6+ code 
		thiswin = window.open("/forum/forums.asp","ChatWin","height=590,width=800,scrollbars=yes,resizable=no,toolbar=yes,location=1,resizable=false");	  
		thiswin.focus();		
	} 
	}	
	
function OpenSearch()
	{
	//alert (url);
	//alert (win_name);
	if (document.all) { 
		//IE
		thiswin = window.open("/crew/search.asp","SearchWin","height=500,width=560,scrollbars=yes,resizable=yes,toolbar=0,location=1");
		thiswin.focus();				
	} else if (document.layers) {
	  //NS4+ code 
	 	thiswin = window.open("/crew/search.asp","SearchWin","height=500,width=560,scrollbars=yes,resizable=yes,toolbar=yes,location=1");
		thiswin.focus();				
	} else if (document.getElementById) {
	  //NS6+ code 
		thiswin = window.open("/crew/search.asp","SearchWin","height=500,width=560,scrollbars=yes,resizable=yes,toolbar=yes,location=1");	
		thiswin.focus();				
	} 
	}	

function OpenObject(url,win_name)
	{
	//alert (url);
	//alert (win_name);
	if (document.all) { 
		//IE
		thiswin = window.open(url,win_name,"height=500,width=800,scrollbars=yes,resizable=no,location=1,toolbar=0");
		thiswin.focus();				
	} else if (document.layers) {
	  //NS4+ code 
	 	thiswin = window.open(url,win_name,"height=500,width=800,scrollbars=yes,resizable=no,location=1,toolbar=yes");
		thiswin.focus();				
	} else if (document.getElementById) {
	  //NS6+ code 
		thiswin = window.open(url,win_name,"height=500,width=800,scrollbars=yes,resizable=no,location=1,toolbar=yes");	
		thiswin.focus();				
	} 
	}	

function openTeam(url)
	{
	//alert (url);
	//alert (win_name);
	if (document.all) { 
		//IE
		thiswin = window.open(url,"TeamWin","scrollbars=yes,resizable=yes,toolbar=0,location=1");
		thiswin.focus();
	} else if (document.layers) {
	  //NS4+ code 
	 	thiswin = window.open(url,"TeamWin","scrollbars=yes,resizable=yes,toolbar=yes,location=1");
		thiswin.focus();		
	} else if (document.getElementById) {
	  //NS6+ code 
		thiswin = window.open(url,"TeamWin","scrollbars=yes,resizable=yes,toolbar=yes,location=1");	  
		thiswin.focus();
	} 
	}	
	
function openCvv()
	{
	//alert (url);
	//alert (win_name);
	if (document.all) { 
		//IE
		thiswin = window.open("/shopping/store/cvv.asp","CVVwin","height=500,width=800,scrollbars=yes,resizable=yes,toolbar=0,location=1");
		thiswin.focus();
	} else if (document.layers) {
	  //NS4+ code 
	 	thiswin = window.open("/shopping/store/cvv.asp","CVVwin","height=500,width=800,scrollbars=yes,resizable=yes,toolbar=yes,location=1");
		thiswin.focus();		
	} else if (document.getElementById) {
	  //NS6+ code 
		thiswin = window.open("/shopping/store/cvv.asp","CVVwin","height=500,width=800,scrollbars=yes,resizable=yes,toolbar=yes,location=1");	  
		thiswin.focus();
	} 
	}	
	

function editMembers(id)
{
	opener.location.href = "/shopping/backofficeplus/comersus_backoffice_listChapterCustomersExec.asp?chapterAdminID="+id;
}
	
// rollovers for register and recover		
  Rollimage = new Array()

  Rollimage[0]= new Image(82,18)
  Rollimage[0].src = "/images/login/registerOff.jpg"

  Rollimage[1] = new Image(82,18)
  Rollimage[1].src = "/images/login/registerOn.jpg"
  
  Rollimage[2]= new Image(82,18)
  Rollimage[2].src = "/images/login/recoverOff.jpg"

  Rollimage[3] = new Image(82,18)
  Rollimage[3].src = "/images/login/recoverOn.jpg"  

  function SwapOut(){
    document.roll.src = Rollimage[1].src;
    return true;
  }

  function SwapBack(){
    document.roll.src = Rollimage[0].src; 
    return true;
  }

  function SwapOut2(){
    document.roll2.src = Rollimage[3].src;
    return true;
  }

  function SwapBack2(){
    document.roll2.src = Rollimage[2].src; 
    return true;
  }  

// dynamic username check
  function OnChangedUsername()
	{
		if(document.custReg.username.value == "")
			{
				document.custReg.save.disabled = true;
			}
		else
		{
			document.custReg.save.disabled = false;
		}
	}
	function createRequestObject() {
		var ro;
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			ro = new XMLHttpRequest();
		}
		return ro;
	}

	var http = createRequestObject();

	function sndReq() {
		http.open('get', 'ajax_username.asp?username='+document.custReg.username.value);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
	function sndReq2() {
		http.open('get', '/crew/ajax_username.asp?username='+document.orderform.username.value);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}	

	function handleResponse() {
		if(http.readyState == 4){
			var response = http.responseText;
			var update = new Array();

			if(response.indexOf('|' != -1)) {
				update = response.split('|');
				document.getElementById("username_chk").innerHTML = update[0];
			}
		}
	}
function P7_swapClass(){ 
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

// swap text for search criteria

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;
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
	var obj = MM_findObj(objName); if (obj) obj.innerHTML = newText;
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function checkExtensions() {
	checkField(document.photoForm.FILE1.value);
	checkField(document.photoForm.FILE2.value);
	checkField(document.photoForm.FILE3.value);
	checkField(document.photoForm.FILE4.value);
	checkField(document.photoForm.FILE5.value);
	checkField(document.photoForm.FILE6.value);
	checkField(document.photoForm.FILE7.value);
	checkField(document.photoForm.FILE8.value);
	checkField(document.photoForm.FILE9.value);
	checkField(document.photoForm.FILE10.value);
	checkField(document.photoForm.FILE11.value);
	checkField(document.photoForm.FILE12.value);
}

function checkField(thisField) {
if (thisField != "") {
		alert (thisfield);
		var passType = false	
		if ((thisField.lastIndexOf(".jpg")>0) || (thisField.lastIndexOf(".png")>0) || (thisField.lastIndexOf(".gif")>0)) {
			passType = true;
		}
		if (passType) {
			return true;
		}
		else {
			alert("Only files of type .jpg, .png and .gif are allowed for upload!");
			return false;
		}
	}	
}

function deleteEntry(id) {
  if (confirm("Are you sure you want to delete this account?")) {
	var id
	document.myForm.Thisid.value = id
	document.myForm.deleteThis.value = "true"
	//alert(document.myForm.deleteThis.value);
	//alert(document.myForm.Thisid.value);
	document.myForm.submit();
	}
}
function ArticleDelete() {
  if (confirm("Are you sure you want to delete this article?")) {
	var id
	document.EditForm.Action.value = "delete"
	document.EditForm.submit();
	}
}
function deActivate(id) {
	var id
	document.myForm.Thisid.value = id
	document.myForm.deactivate.value = "true"
	//alert(document.myForm.deactivate.value);
	//alert(document.myForm.Thisid.value);	
	document.myForm.submit();
	}	
function Activate(id) {
	var id
	document.myForm.Thisid.value = id
	document.myForm.activate.value = "true"
	//alert(document.myForm.activate.value);
	//alert(document.myForm.Thisid.value);
	document.myForm.submit();
	}
	

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if ((formField.value == "") || (formField.value == "undefined"))
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	return result;
	
	if (formField == "zipcode")
	{
		allDigits(formField.value);
	}
	
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			//alert('Please enter a numeric value for the zip code field.');
			//form1.zipcode.focus();
			result = false;
		}
	
	return result;
}

function allDigits2(str)
{
	alert(str);
	return inValidCharSet2(str,"0123456789");
}

function inValidCharSet2(str,charset)
{
	alert(str);
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			alert('Please enter a numeric value for the zip code field.');
			//form1.zipcode.focus();
			result = false;
		}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}



//-->
	



