
/* Pop window */
function popup(theURL,winName,features) {
	window.open(theURL,winName,features);
}
/* END Pop window */


/* img/movie location */
function piclocation(loc) {			
	document.getElementById('slidebox').innerHTML=loc;		
}


/* toggle click on off */
function toggle_swap(obj,i) {			
	var a = document.getElementById(obj);
	if ( a.style.display != 'none' ) {
		a.style.display = 'none';
	} else {
		window.swap(i);
	}			
}
/* toggle click on off */
function toggle_footage(obj,obj2) {			
	var a = document.getElementById(obj);
	if ( a.style.display != 'none' ) {
		a.style.display = 'none';
	} else {
		a.style.display = '';
	}	
	
	var b = document.getElementById(obj2);
	if ( b.style.display != 'none' ) {
		b.style.display = 'none';
	} else {
		b.style.display = '';
	}
}
/* END toggle click on off */


/* confirm link warning */
function confirmLink(theLink, text){
    var is_confirmed = confirm(text);
    return is_confirmed;
}
function confirmLink2(link, text){
    answer = confirm(text);
    if (answer!=0) {
        location = link;
    }
}
/* End confirm link warning */



/* Check/uncheck tables */
function setCheckboxes(the_form, do_check, the_element) {	
    var elts      = document.forms[the_form].elements[the_element];
    var elts_cnt  = elts.length;	
    for (var i = 0; i < elts_cnt; i++) {
    	elts[i].checked = do_check;
    }
	// end for
	return true;	
}
/* End Check/uncheck tables */

	

/* Sets table color background on click */
function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor) {
    var theCells = null;
    
    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }
    
    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
}
/* Sets table color background on click */



/* find object */

function findObj(n, d) { 	
	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=findObj(n,d.layers[i].document);	
	if(!x && document.getElementById) x=document.getElementById(n); 	
	return x;	
}

/* END find object */




/* find XMLHttpRequest object and library */

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");
  }
 }
 if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
 }
 return xmlHttp;
}

function getFormValues(fobj) 
{ 
   var str = ""; 
   var valueArr = null; 
   var val = ""; 
   var cmd = ""; 
   for(var i = 0;i < fobj.elements.length;i++) 
   { 
       switch(fobj.elements[i].type) 
       { 
           case "text": 
                str += fobj.elements[i].name + "=" + encodeURI(escape(fobj.elements[i].value)) + "&";
                break; 
           case "textarea": 
                str += fobj.elements[i].name + "=" + encodeURI(escape(fobj.elements[i].value)) + "&";
                break; 
           case "hidden": 
                str += fobj.elements[i].name + "=" + encodeURI(escape(fobj.elements[i].value)) + "&";
                break; 
           case "radio": 
           		if(fobj.elements[i].checked==true){
                	str += fobj.elements[i].name + "=" + encodeURI(escape(fobj.elements[i].value)) + "&";
           		}
                break; 
           case "checkbox": 
           		if(fobj.elements[i].checked==true){
                	str += fobj.elements[i].name + "=" + encodeURI(escape(fobj.elements[i].value)) + "&";
           		}
                break; 
           case "select-one": 
                str += fobj.elements[i].name + "=" + encodeURI(fobj.elements[i].options[fobj.elements[i].selectedIndex].value) + "&"; 
                break; 
       } 
   }
   str = str.substr(0,(str.length - 1)); 
   return str; 
}

function json_decode(str) {
  arr = eval('('+str+')');
  return arr;
}

/* END find XMLHttpRequest object and library */


/* disable form and button fields on payment forms */
function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
			var obj = theform.elements[i];
			if (obj.type.toLowerCase() == "submit" || obj.type.toLowerCase() == "button")
				//obj.value = '   Process Payment   ';
				obj.disabled = true;
		}		
	}
}

// simulate php in_array function 
Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

// show element and hide others
// 'hide' is array of elementID's to hide
function showElement(show, hide) { 
	var a = hide.split(",");	
    for (var i = 0; i < a.length; i++) {
    	document.getElementById(a[i]).style.display = 'none';
    }
    document.getElementById(show).style.display = '';
} 
function showElementOnOff(show) { 
	if (document.getElementById(show).style.display == '') {
		document.getElementById(show).style.display = 'none';
	}else{
		document.getElementById(show).style.display = '';
	}
} 

// make form input elements hoverable is IE
function inputHover(id) {
	var i = document.getElementById(id);
	i.style.background = '#000000';
	i.style.color = '#ffffff';
	i.style.borderColor = "#ffffff";
	i.style.border = "1px solid #ffffff";
}
function inputHoverOff(id, color, bgcolor) {
	var i = document.getElementById(id);
	if(!color) var color = '#000000';
	if(!bgcolor) var bgcolor = '#ffffff';
	i.style.background = bgcolor;
	i.style.color = color;
	i.style.borderColor = color;
	i.style.border = "1px solid " + color;
}