 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){
	//alert(argImage+ " / " +argDownload+ " / " + argTitle+ " / " + argDate+ " / " + argNumber);
	document.getElementById('galImageCaption').innerHTML = argTitle;
	document.galMainImage.src = argImage;
	downloadSingleImage = argDownload;
	document.getElementById('galImageCaption').innerHTML = argTitle;
	//document.getElementById('galCount').innerHTML = argNumber;
	document.getElementById('galDate').innerHTML = argDate;
	document.getElementById('galImageName').innerHTML = argName;
}

function downloadImage(){
	//var location = downloadSingleImage; //
	var location = "/ms-media/dispatch/media?file=" + downloadSingleImage;
	window.open(location,"","");
}

function downloadGallery(galid) {
	var location = "http://chryslermedia.iconicweb.com/tu4ruXe6/gallery" + galid + ".zip";
	window.open(location,"","");
}

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

function downloadCheckedImages(){
	var i=0;
	var checkboxValues=''; 
                var ids = '';
	var count = document.getElementsByTagName("input").length;
	var limit = 30;
	var numchecked = 0;
	for ( i=0; i<count; i++){
		if (document.getElementsByTagName("input")[i].checked == true) {
			var name = document.getElementsByTagName("input")[i].name;
			if ( name.substr(0, "name_".length) === "name_" ) {
				var temp = document.getElementsByTagName("input")[i].value;  
				if (temp != 'on' && temp != 'releases' && temp != 'files' && temp != 'videos' && temp != 'images') {
					checkboxValues += temp + ',';
	 var image_id = document.getElementsByTagName("input")[i].id;
                                        ids += ',' + image_id.substring(3);
					numchecked = numchecked + 1;
				}
			}
		}
  	}
        ids = ids.substring(1);
	if (checkboxValues != '') {
		if ( numchecked > limit ) {
			alert('Please limit downloads to ' + limit + ' images at a time, or use the Download All option.');
		} else {
		// construct a form to post, since the list could be > 2000 characters
//		postwith("/ms-media/dispatch/media", {file:checkboxValues});
			var newWindow = "/ms-media/dispatch/media?images=" + ids; //"${imageDownloadUrl}" + checkboxValues;
			window.open(newWindow,"","");
		}
	} else {
		alert('<bean:message key="please.select.image"/>');
	}
}

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;
			if ( t[i].name.substr(0, "name_".length) === "name_" )
				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;
}

