//Public Variables
var popupwin,  cToolBar;

// Opens the folders that have been selected after submit
function showFolders(ID) {
var currentState	= document.getElementById(ID).style.display;
var imageName		= ID + '_img';

	if (currentState == "none") {
		if (document.getElementById(ID)) {
			document.getElementById(ID).style.display = "block";
		}
		if (document.getElementById(imageName)) {
			document.getElementById(imageName).src = "/images/ico_menu-open.gif";
		}
	} else {
		if (document.getElementById(ID)) {
			document.getElementById(ID).style.display = "none";
		}
		if (document.getElementById(imageName)) {
			document.getElementById(imageName).src = "/images/ico_menu-closed.gif";
		}
	}
}

// Changes form values and submits to navigate folder structure
function setAndSubmit(strfolder_id,strfolder_path,folder_id_num){
	document.getElementById('folder_id').value	        = strfolder_id;
	document.getElementById('folder_path').value	    = strfolder_path;
	document.getElementById('folder_id_num').value      = folder_id_num;
	//document.aspnetForm.submit();
	document.location = "productlist.aspx?folder_id=" + strfolder_id + "&folder_path=" + strfolder_path + "&folder_id_num=" + folder_id_num;
}

// Changes form values and submits to navigate folder structure
function setAndSubmitMeta(strfolder_id,keyword_value,intfolder_id_num){
	document.getElementById('folder_id').value	        = strfolder_id;
	document.getElementById('folder_id_num').value      = intfolder_id_num
	document.getElementById('keyword_value').value	    = keyword_value;
	//document.aspnetForm.submit();
	document.location = "documenttypelist.aspx?folder_id=" + strfolder_id + "&keyword_value=" + keyword_value + "&folder_id_num=" + intfolder_id_num;
}

// Loads the Images for each item
function loadContentTypeImages(content_id,image_name) {
	if (document.getElementById(content_id)) {
		document.getElementById(content_id).innerHTML = '<img src="' + image_name + '" border="0"/>';
	}
}

// Loads the Images for each Language for each item
function loadLanguageFlags(content_id,images) {
	if (document.getElementById(content_id)) {
		document.getElementById(content_id).innerHTML = images;
	}
}

//Loads the content item delete button if rights exist
function loadDeleteImage(ID,FolderID) {
	var checkID = "del_" + ID;
	
	if (document.getElementById(checkID)){
		document.getElementById(checkID).innerHTML = '<a href="javascript:void(0);" onclick="javascript:window.open(&#39;/WorkArea/content.aspx?LangType=1033&action=submitDelContAction&delete_id=' + ID + '&page=&folder_id=' + FolderID + '&FromPublicSite=1&#39;,&#39;DeleteItem&#39;,&#39;top=10,left=10,height=0,width=0,status=no,menubar=0,directories=0&#39;);"><img src=/dmx/WorkArea/images/application/btn_delete-nm.gif border=0></a>';
	}
}

function ecmPopUpWindow(url, hWind, nWidth, nHeight, nScroll, nResize) {    
    cToolBar = 'toolbar=0,location=0,directories=0,status=' + nResize + ',menubar=0,scrollbars=' + nScroll + ',resizable=' + nResize + ',width=' + nWidth + ',height=' + nHeight;
    popupwin = window.open(url, hWind, cToolBar);
    return popupwin;
}
