/************************************************************************\
 *  js001.js
 *  Path: /
 *  File Version: 1.0
 *  Last Update: 2005-08-23 09:39:12
 *
 *   Main javascript file for DD-CMS
 *
 *  +---------------------------------------------------------------+
 *  +   copyright 2005, Edward Vermillion, Doggydoo Codeworks       +
 *  +       Unless otherwise stated All Rights Are Reserved         +
 *  +       Use or reuse without prior permission is prohibited     +
 *  +   Web: http://www.doggydoo.net                                +
 *  +   Email: evermillion@doggydoo.net                             +
 *  +---------------------------------------------------------------+
 *
\************************************************************************/

// Copyright information must stay intact
// FormCheck v1.10
// Copyright NavSurf.com 2002, all rights reserved
// Creative Solutions for JavaScript navigation menus, scrollers and web widgets
// Affordable Services in JavaScript consulting, customization and trouble-shooting
// Visit NavSurf.com at http://navsurf.com

function formCheck(formobj){
	// name of mandatory fields
	var fieldRequired = Array("name", "email", "subject", "message");
	// field description to appear in the dialog box
	var fieldDescription = Array("Name", "Email", "Subject", "Message");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			if (obj.type == null){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				continue;
			}

			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

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 swapVid(vid,type,num) {

    var vidDiv = MM_findObj('vidDiv'+num);
    var httpro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
	{
		httpro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		httpro = new XMLHttpRequest();
	}

	httpro.open('get', '/getVid.php?vid='+vid+'&type='+type, true);
	httpro.onreadystatechange = function () {
		if(httpro.readyState == 4)
		{
			var response = httpro.responseText;
			vidDiv.innerHTML = response;

		}
	};
	httpro.send(null);
	return;
}

function swapAud(aid,num) {

    var audDiv = MM_findObj('audDiv'+num);
    var httpro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
	{
		httpro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		httpro = new XMLHttpRequest();
	}

	httpro.open('get', '/getAud.php?aid='+aid, true);
	httpro.onreadystatechange = function () {
		if(httpro.readyState == 4)
		{
			var response = httpro.responseText;
			audDiv.innerHTML = response;

		}
	};
	httpro.send(null);
	return;
}

var hiddens = 0;

function swapCont(id, total) {
	var contDiv = MM_findObj('content');
	var showDiv = MM_findObj('div'+id);
	var div, n;
	
	hiddens = total;
	
	if (contDiv.style.display == '' || contDiv.style.display == 'block') {
		contDiv.style.display = 'none';
	}
	
	for (n=1; n<=total; n++) {
		if (n == id) {
			showDiv.style.display = 'block';
		} else {
			div = MM_findObj('div'+n);
			div.style.display = 'none';
		}
	}
}

function showCont() {
	var contDiv = MM_findObj('content');
	var div, n;
	
	if (contDiv.style.display == 'none') {
		contDiv.style.display = 'block';
		for (n=1; n<=hiddens; n++) {
			div = MM_findObj('div'+n);
			div.style.display = 'none';
		}
	}
}
