function expand(div) {
	var showdomainstuff = new Fx.Styles(div,{duration:250});
	var propheight = document.getElementById(div).scrollHeight;
	var propwidth = document.getElementById(div).scrollWidth;
	showdomainstuff.start({
		'height':[0,propheight],
		'width':[0,propwidth],
		'opacity':[0,1]
	});
	document.getElementById(tdiv).href=('javascript:closeprop(\'' + div + '\',\'' + tdiv + '\');')					;
}
	
function shrink(div) {
	var showdomainstuff = new Fx.Styles(div,{duration:550});
	var propheight = document.getElementById(div).scrollHeight;
	showdomainstuff.start({
		'height':[0,0],
		'width':[0,0],
		'opacity':[0,0]
	});
}

function validateLogin() {

	if(document.login.username.value == "") {
		alert("Please enter username.");
		document.login.username.focus();
		return false;
	}
	
	if(document.login.password.value == "") {
		alert("Please enter password.");
		document.login.password.focus();
		return false;
	}
	
}
	
function validateRegister() {

	if(document.register.username.value == "") {
		alert("Please enter username.");
		document.register.username.focus();
		return false;
	}
	
	if(document.register.password.value == "") {
		alert("Please enter password.");
		document.register.password.focus();
		return false;
	}
	
	if(document.register.email.value == "") {
		alert("Please enter an email address.");
		document.register.email.focus();
		return false;
	}
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.register.email.value)){
		return (true);
	} else {
		alert("Please enter a valid email address.");
		document.register.email.focus();
		return (false);
	}
	
}
	
function validateForm() {
		
	if(document.addlink.linktitle.value == "") {
		alert("Please enter a title for your link.");
		document.addlink.linktitle.focus();
		return false;
	}
		
	if(document.addlink.linkurl.value == "") {
		alert("Please enter your website in the form of http://yourdomain.com.");
		document.addlink.linkurl.focus();
		return false;
	}

	var theurl=document.addlink.linkurl.value;
 	var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{2}/
 	if (tomatch.test(theurl)) {
 	} else {
 		window.alert("Please enter your website in the form of http://yourdomain.com.");
		document.addlink.linkurl.focus();
		return false; 
	}
		
}
	
function confirmPostDelete(delUrl,name_cat) {
	if (confirm("Are you sure you want to delete this Link?")) {
		document.location = delUrl;
	}
}

// shrinkall

function shrinka() {
	$$('.test').each(function(div) {
  		var showdomainstuff = new Fx.Styles(div,{duration:550});
		var propheight = document.getElementById(div).scrollHeight;
		showdomainstuff.start({
			'height':[0,0],
			'width':[0,0],
			'opacity':[0,0]
		});
	});
}

// fade header images

function fade() {
	$$('#info img').each(function(e){
		var fade = new Fx.Style(e, 'opacity', {wait:false});
		fade.set(.5);
		e.addEvent('mouseover', function(){
			fade.start(1);
		});
		e.addEvent('mouseout', function(){
			fade.start(.5);
		});
	});
}
window.addEvent('load', fade );

// Video Ajax Code

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

// tooltips

var offsetx = -35;
var offsety =  20;

function newelement(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode && 
        	document.compatMode != 'BackCompat') ? 
        		document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = document.getElementById('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
}
function tooltip(tip)
{
    if(!document.getElementById('tooltip')) newelement('tooltip');
    var lixlpixel_tooltip = document.getElementById('tooltip');
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getmouseposition;
}
function exit()
{
    document.getElementById('tooltip').style.display = 'none';
}

// Window Size
function getBrowserWindowSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return {width:myWidth, height:myHeight};
}


$(document).ready(function(){ // This sets the opacity of the thumbs to fade down to 60% when the page loads
	$("#navTop").fadeTo("fast", 0.3);
	$("#navTop").hover(function(){
		$("#navTop").fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
	},function(){
		$("#navTop").fadeTo("slow", 0.3); // This sets the opacity back to 60% on mouseout
	});
});

