// DCC Javascript

function FormPanel_FireDefaultButton(event, target) {
    if ((event.keyCode == 13 || event.which == 13) && !(event.srcElement && (event.srcElement.tagName.toLowerCase() == 'textarea'))) 
    {
        var defaultButton = document.getElementById(target);
        if (defaultButton == 'undefined') defaultButton = document.all[target]; 

        if (defaultButton && typeof(defaultButton.click) != 'undefined') 
        {
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
        }
    }
    return true;
}

//Filter gallery category
function filterGalleries(dropdown) {

	window.location = dropdown.value;

}

//Filter events type
function filterEvents(dropdown) {

	window.location = dropdown.value;

}

// Force multi link hover
function multiHover(elem,target) {
	
	var elem	= document.getElementById(elem);
	var target	= document.getElementById(target);
	
	elem.onmouseover = function() { target.className = "highlight"; }
	elem.onmouseout = function() { target.className = null; }
}

function multiHoverArr(arr)
{
	var elems = arr.split(',');
	
	for(i=0;i<elems.length;i++) {
		var elem = document.getElementById(elems[i]);
		elem.onmouseover = function() {
			for(j=0;j<elems.length;j++) {
				document.getElementById(elems[j]).className = "highlight";
			}
		}
		elem.onmouseout = function() {
			for(k=0;k<elems.length;k++) {
				document.getElementById(elems[k]).className = null;
			}
		}
	}
}


//Page load function

function pageLoad() {
	
	var textemail = document.getElementById("ctl00_Content_txtEmail")
	var textname = document.getElementById("ctl00_Content_txtName")
	var textcomment = document.getElementById("ctl00_Content_txtComment")
		
	if(textcomment!=null){
		
		if(textemail.value.length == 0) {
			textemail.value = "Your email address";
		}
		
		textemail.onblur = function() {
			if(textemail.value.length == 0) { 
				textemail.value = "Your email address";
			}
		}
		
		textemail.onfocus = function() {
			if(textemail.value == "Your email address") {
			textemail.value = "";
			}
		} 
		
		if(textname.value.length == 0) {
			textname.value = "Your name";
		}
		
		textname.onblur = function() {
			if(textname.value.length == 0) { 
				textname.value = "Your name";
			}
		}
		
		textname.onfocus = function() {
			if(textname.value == "Your name") {
			textname.value = "";
			}
		}
		
		if(textcomment.value.length == 0) {
			textcomment.value = "Your comment";
		}
		
		textcomment.onblur = function() {
			if(textcomment.value.length == 0) { 
				textcomment.value = "Your comment";
			}
		}
		
		textcomment.onfocus = function() {
			if(textcomment.value == "Your comment") {
			textcomment.value = "";
			}
		} 
		
	}

}

addDOMLoadEvent(pageLoad);

addDOMLoadEvent(function() {
});

function addDOMLoadEvent(func) {
   if (!window.__load_events) {
      var init = function () {
          // quit if this function has already been called
          if (arguments.callee.done) return;
      
          // flag this function so we don't do the same thing twice
          arguments.callee.done = true;
      
          // kill the timer
          if (window.__load_timer) {
              clearInterval(window.__load_timer);
              window.__load_timer = null;
          }
          
          // execute each function in the stack in the order they were added
          for (var i=0;i < window.__load_events.length;i++) {
              window.__load_events[i]();
          }
          window.__load_events = null;
      };
   
      // for Mozilla/Opera9
      if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", init, false);
      }
      
      // for Internet Explorer
      /*@cc_on @*/
      /*@if (@_win32)
          document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");
          var script = document.getElementById("__ie_onload");
          script.onreadystatechange = function() {
              if (this.readyState == "complete") {
                  init(); // call the onload handler
              }
          };
      /*@end @*/
      
      // for Safari
      if (/WebKit/i.test(navigator.userAgent)) { // sniff
          window.__load_timer = setInterval(function() {
              if (/loaded|complete/.test(document.readyState)) {
                  init(); // call the onload handler
              }
          }, 10);
      }
      
      // for other browsers
      window.onload = init;
      
      // create event function stack
      window.__load_events = [];
   }
   
   // add function to event stack
   window.__load_events.push(func);
}