function ShowSwap(_image,_div){
    var x = document.getElementById(_div);
    x.src = _image
}

function showmenu(themenu){
	if (document.getElementById(themenu).style.display == "none"){
		document.getElementById(themenu).style.display = "block"
	} else {
		document.getElementById(themenu).style.display = "none"
	}
}

function loaddiv(divid,ajaxpage,tab,handle){
	//TABS
	var x=document.getElementsByTagName("img");
	for (var i=0;i<x.length;i++){
		if (x[i].id.indexOf(handle)>-1){
			var element = document.getElementById(x[i].id);
			if (element.id == tab){
				element.src = element.src.replace('/off/','/on/')
			} else {
				element.onmouseover = tabover;
				element.onclick = tabclick; 
				element.onmouseout = tabout; 
				element.src = element.src.replace('/on/','/off/')
			}
		}
	}
	
	//AJAX REQUEST
	new Ajax.Request(ajaxpage, {
	method: "get",
	onComplete: function(transport) { 
		document.getElementById(divid).innerHTML = transport.responseText;
		}//-onSuccess
		}//-request arguments
		);// new ajax request	
}

//IMAGE ROLLOVER
function rolloverInit(){
	var x=document.getElementsByTagName("img");
    for (var i=0;i<x.length;i++){
	    if (x[i].className.indexOf('rollover')>-1){
	        x[i].onmouseover = function() {
	            this.src = this.src.replace('/off/','/roll/')
	        }
	        x[i].onmouseout = function() {
	            this.src = this.src.replace('/roll/','/off/')
	        }
	    }
	}
}

function emailsignup(formid) {
    $.post('sc_emailsignup.ashx', $('#' + formid).serialize(), function(data) {
        $('#emailsignupmessage').css('display', 'block');
        $('#emailsignupmessage').html(data);
        setTimeout(function() {
            $('#emailsignupmessage').fadeOut(1000);
        }, 2000);
    })
}

function spidermenus(triggerhandle,menuhandle){

    var x = document.getElementsByTagName("div");
    
	for (var i=0;i<x.length;i++){

		if (x[i].id.indexOf(triggerhandle)>-1){

			//VARIABLES
			var element = document.getElementById(x[i].id);
			var theid = element.id.replace(triggerhandle,'');
			var thetrigger = document.getElementById(triggerhandle + theid);

			//OVER
			
			thetrigger.onmouseover = function() {
			
			    
			if (document.getElementById(this.id.replace('trigger', ''))) {
			    
				
				    document.getElementById(this.id.replace('trigger','')).style.display = "block";
				}
			
				//alert();
				//$('nav' + this.id.replace('menutrigger','')).src = $('nav' + theid).src.replace('/off/','/roll/');
			};
			    
			//OUT
			thetrigger.onmouseout = function() {
			if (document.getElementById(this.id.replace('trigger', ''))) {
			        document.getElementById(this.id.replace('trigger', '')).style.display = "none";
			        //$('nav' + this.id.replace('menutrigger','')).src = $('nav' + theid).src.replace('/roll/','/off/');
			    }
			};
		} 
	}
}

function galleryrollover(){
	var x=document.getElementsByTagName("img");
    for (var i=0;i<x.length;i++){
	    if (x[i].className.indexOf('gallerythumb')>-1){
	        x[i].onmouseover = function() {
	            this.style.borderColor = 'white';
	        }
	        x[i].onmouseout = function() {
	            this.style.borderColor = '#48596a';
	        }
	    }
	}

}

function clearfield(id){
    if (document.getElementById(id).value == 'Enter Keyword') {
        document.getElementById(id).value = ""
    } else {
    }
}

function screenshot() {
    document.getElementById('screenshotlast').innerHTML = $('#clientnav > a:last').attr('id');
    $('#clientnav a,#leftarrow,#rightarrow').click(function() {
        var theid = $('.activeSlide').attr('id');
        document.getElementById('screenshot').innerHTML = theid;
    });
}

window.onload = masterloader();

function masterloader(){
    //screenshot();
	//rolloverInit();
    //galleryrollover();
    //spidermenus('menutrigger','menu');
}