function swapimage(what, init) { 
	what.style.background = 'url(images/layup/sidenavi.gif) no-repeat 0 ' + init + 'px'
}

function theflash(movie,width,height) 
{
	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">\n');
    document.write('<param name="movie" value="'+movie+'">\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="menu" value="false">\n');
	document.write('<param name="wmode" value="transparent">\n');
	document.write('<embed src="'+movie+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>\n');
    document.write('</object>\n');
	
}

function showthis(what)
{
	
if (document.getElementById(''+what+'').style.display=="none")
	{
			document.getElementById(''+what+'').style.display ="";
			}else{ 
			document.getElementById(''+what+'').style.display ="none";
	}
}

function resizeme(){
	
	windowWidth= document.documentElement.clientWidth
	
	if (windowWidth > 810){
		
		document.getElementById('footer').style.width = '800px'
		
		}
	
	}
	
window.onresize = function() {
  resizeme();
}
window.onload = function() {
  resizeme();
}

function changeContactDiv(value) {
    /*document.getElementById('uk_enquiry_div').style.display = 'none';
    document.getElementById('int_enquiry_div').style.display = 'none';
    document.getElementById('ret_enquiry_div').style.display = 'none';
                
    switch(value) {
        case 'Area Franchise':
            document.getElementById('uk_enquiry_div').style.display = 'block';  
        break;
        case 'Master Franchise':
            document.getElementById('int_enquiry_div').style.display = 'block';
        break;
        case 'Retailer':
            document.getElementById('ret_enquiry_div').style.display = 'block';
        break;
    }*/
	
	$('uk_enquiry_div').hide();
    $('int_enquiry_div').hide();
    $('ret_enquiry_div').hide();
                
    switch(value) {
        case 'Area Franchise':
            $('uk_enquiry_div').show();  
        break;
        case 'Master Franchise':
            $('int_enquiry_div').show();
        break;
        case 'Retailer':
            $('ret_enquiry_div').show();
        break;
    }
	getLables("labels");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function showOther(value, divId) {
    if(value == 'Other') {
        $(divId).show();
    } else {
        $(divId).hide();
    }
}

function getLables(location) {
	var labels;
	var separator = "";
	labels = "{";
	$$("label").each(function(e) {
		e.update(e.innerHTML.replace(/\*/,'<span style="color:red">*</span>'));
		if((e.up().up().nodeName == "DIV") && (separator != "OTHER DETAILS")) {
			labels += '"separator": "OTHER DETAILS",';
			separator = "OTHER DETAILS";
		}
		if((e.up().up().nodeName != "DIV") || ((e.up().up().nodeName == "DIV") && (e.up().up().visible()))) {
			labels += '"'+e.next().id+'": "'+e.innerHTML.replace(/\s*<.*>\s*/,"")+'",';
		}
	});
	labels = rtrim(labels,",");
	labels += "}";
	$(location).value = labels;
}

function validateForm() {
	var label;
	var output = "";
	var field = "";
	$$("label").each(function(e) { 
		label = e.innerHTML;
		if( (label.match(/\*/)) && ((e.next().value=="") || (e.next().value.match(/-.*-/))) && (e.up().up().visible())) {
			if(output == "") {
				output = label.replace(/\s*<.*>\s*/,"")+" needs to be completed";
				field = e;
			}
		}
	})
	if(output != "") {
		alert(output.replace(/\*/,""));
		field.focus();
	} else {
		$("emailform").submit();
	}
}

