function topNavSwitch(argNav, argDirection){

var sloganOn = "/images/audi_media_header_on.gif";
var sloganOff = "/images/"+argNav+"_over.gif";
var sNav = document[argNav].src;
var sSwitch = "images/" + argNav + "_" +argDirection+".gif";

	if (argDirection == "on"){
		//alert(sloganOff);
		document[argNav].src=sSwitch;
		document["headimage"].src = sloganOff;
	} else {
		document[argNav].src=sSwitch;
		document["headimage"].src = sloganOn;
		
	}
}

 function quickSearch(){
	if(document.textSearchForm.keyword.value!=null && document.textSearchForm.keyword.value!=''){
		document.textSearchForm.submit();
	}else{
		alert("Please enter a keyword.");
		document.textSearchForm.keyword.focus();
	}
}
//media site pop up issue fix
opn = window.opener;
	locationUrl = null;
if(opn!=null){
	locationUrl=window.opener.location;
}
if(locationUrl!=null){
	top.window.moveTo(0,0);
}

<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->


function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function changeSelectedImage(argImage, argDownload, argTitle, argDate, argNumber, argName, argThumb, argGalleryName, argCaption){
	$("#galleryName").text(argTitle);
	$("#galImageCaption").text(argCaption);
//	document.getElementById('galImageCaption').innerHTML = argTitle;
	document.galMainImage.src = argImage;
	$("img#galMainImage").cjObjectScaler({
	   method: "fit",
	   fade: 550
	});
	downloadSingleImage = argDownload;
	downloadSingleImageMd = argImage;
	downloadSingleImageSm = argThumb;
//	document.getElementById('galImageCaption').innerHTML = argTitle;
	//document.getElementById('galCount').innerHTML = argNumber;
	//document.getElementById('galDate').innerHTML = argDate;
	//document.getElementById('galImageName').innerHTML = argName;
//	if( argGalleryName != null) {
//		document.getElementById('galleryName').innerHTML = argGalleryName;
//	}
	
}

function downloadImage(argSize){
	if ((argSize == "") || (argSize == "large") || (argSize == null) || (argSize == undefined)){
		var location = downloadSingleImage; //"/ms-media/dispatch/media?file=" + downloadSingleImage;
	} else if (argSize == "medium"){
		var location = downloadSingleImageMd; //"/ms-media/dispatch/media?file=" + downloadSingleImage;
	} else if (argSize == "small")  {
		var location = downloadSingleImageSm; //"/ms-media/dispatch/media?file=" + downloadSingleImage;
	} else {
		var location = downloadSingleImage; //"/ms-media/dispatch/media?file=" + downloadSingleImage;
	}
	window.open(location,"","");
}

function downloadImages(argSelect) {
	var location = "/ms-media/dispatch/media?file=";
	var images  = document.getElementsByName("imagefile");
	for ( i = 0; i < images.length; i++ ) {
		location = location + images[i].value + ",";
	}
	window.open(location, "", "");
}

function downloadCheckedImages(argSize){
	//alert(argSize);
	var i=0;
	var checkboxValues=''; 
	var count = document.largeform.getElementsByTagName("input").length;
	for ( i=0; i<count; i++){
		if (document.largeform.getElementsByTagName("input")[i].checked == true) {
			var image_id = document.largeform.getElementsByTagName("input")[i].id;
			//if (argSize =='small'){
			//	var temp = document.smallform.getElementsByTagName("input")[i].value;  
			//} 
			//else if (argSize =='medium'){
			//	var temp = document.mediumform.getElementsByTagName("input")[i].value;  
			//} 
			//else {
			//	var temp = document.largeform.getElementsByTagName("input")[i].value;  
			//}
			//if (temp != 'on' && temp != 'releases' && temp != 'files' && temp != 'videos' && temp != 'images') {
			if (document.largeform.getElementsByTagName("input")[i].id.substring(0,3) == 'ic_') { 
					image_id = image_id.substring(3);
					checkboxValues += image_id + ',';
					//checkboxValues += temp + ',';
			}
		}
	}
  	if (checkboxValues != '') {
		// construct a form to post, since the list could be > 2000 characters
		//postwith("/ms-media/dispatch/media", {file:checkboxValues});
		//window.location.href="/ms-media/dispatch/media?file=" + checkboxValues;
		var size = "hi";
		if ( argSize == 'small' ) {
			size = "low";
		} else if ( argSize == 'medium' ) {
			size = "mid";
		}
		window.location.href="/ms-media/dispatch/media?images=" + checkboxValues + "&size=" + size;
	} else {
		alert('Please select an image to download.');
	}
}

function postwith (to,p) {
  var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = to ;
  for (var k in p) {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", p[k]);
    myForm.appendChild(myInput) ;
  }
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;
}

function checkAll(){
	var t = document.getElementsByTagName('input');
	for (var i in t)
		if (t[i].type=='checkbox')
			if ( t[i].name != "selectedList" )
				t[i].checked=true;
}


function uncheckAll(){
var t = document.getElementsByTagName('input');
for(var i in t)
if(t[i].type=='checkbox')
t[i].checked=false;
}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}


