function reserve(id){
	
	if(!id) return false;
	
	$("#room_id").val(id);
	$("#room_name").html($("#name_" + id).html());
	$("#reserve_form").show();
}

function thickPop(title, page, attached){
	if(!page) return false;
	height = 459;
	width = 590;
	tb_show(title, 'popups/popup.html?page=' + page + '&title=' + title + attached + '&placeValuesBeforeTB_=savedValues&TB_iframe=true&TB_transparent=1&modal=true&height=' + height + '&width=' + width, null);
}

function getWallpaper(size, id) {
	var h = 480;
	var w = 640;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	window.open('wallpapers-get.php?size=' + size + '&id='+id, 'popwallpaper' + id,'width='+w+', height='+h+', scrollbars=0, resizable=0, status=0, top='+t+', left='+l);
}

var addedPhotos = new Array();
function appendPhotos() {	
	if (typeof(addedPhotos.length) == 'undefined') {
		addedPhotos.push(0);
	}else{
		// HIDE REMOVE ICON
		$.each(addedPhotos, 
			function(key, id) {
				$('#photo_remove\\['+key+'\\]').hide();
			}
		);
		
		addedPhotos.push(addedPhotos.length);
	}
	
	// ARGUMENTS
	var toShow = new Array();
	args = appendPhotos.arguments.length;
	for (i = 0; i<args; i++){
		toShow.push(appendPhotos.arguments[i]);
	}
	
	var newKey = (addedPhotos.length - 1);
	
	imageField = '<input name="images['+newKey+']" type="file" class="fields" id="images['+newKey+']" size="35">';
	iconRemove = '<span id="photo_remove['+newKey+']"> <a href="javascript:removePhotos('+newKey+')"><img src="images/icons/icon_remove.gif" align="absmiddle" border="0"></a></span>';
	
	$('#table_photos').createAppend(
		'tr', { id: 'tr_photo['+ newKey +'][file]' }, [
			'td', , "Nueva Foto #" + (newKey + 1),
			'td', , imageField + iconRemove
		]
	);
	
	$('#table_photos').createAppend(
		'tr', { id: 'tr_photo['+ newKey +'][line]' }, [
			'td', { colspan: '2', className: 'tbl_red', height: '1' } , "",
		]
	);
}

function removePhotos(value) {
	var keytodelete;
	
	$.each(addedPhotos, 
		function(key, id) {
			if (id == value) {
				keytodelete = key;
			}
		}
	);

	if (keytodelete >= 0) {
		addedPhotos.splice(keytodelete, 1);
		
		// SHOW REMOVE ICON
		$('#photo_remove\\['+(value - 1)+'\\]').show();
	}
	
	$("#tr_photo\\["+value+"\\]\\[file\\]").remove();
	$("#tr_photo\\["+value+"\\]\\[line\\]").remove();
}

function changeSelect(string, string_id, field, selected) {
	if (typeof(selected) == 'undefined') selected = false;
	
	var counter = new Number();
	var src = eval(string+"_"+string_id);
	
	document.getElementById(field).options.length = 0;
	
	$.each(src, 
		function(id, text) {
			counter++;
			
			document.getElementById(field).options[counter - 1] = new Option(text, id);
			
			if (selected == id) {
				document.getElementById(field).selectedIndex = (counter - 1);
			}
		}
	);
}

function showMenu(name) {
	if ($("#"+name).is(':hidden')) {
		$("#"+name).show('fast');
	}else{
		$("#"+name).hide('fast');
	}
}

// COMPANIES SERVICES PAGER
var actual = 0;

function servicesPager(pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField+"_"+(actual+1)).fadeOut('fast', function() {
			$("#"+pagesField+"_"+(page_id+1)).fadeIn('fast');
			actual = page_id;
		});
	}
}

// COMARCAS NEWS PAGER
function comarcasNewsPager(comarca_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/comarcas-news-pager.php", 
					type: "POST", 
					data: "comarca_id="+comarca_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// CITIES NEWS PAGER
function citiesNewsPager(city_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/cities-news-pager.php", 
					type: "POST", 
					data: "city_id="+city_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// DESHABITADOS NEWS PAGER
function deshabitadosNewsPager(city_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/deshabitados-news-pager.php", 
					type: "POST", 
					data: "city_id="+city_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// EVENTS PAGER
function eventsPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/events-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// INTERVIEWS PAGER
function interviewsPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/interviews-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// DOCUMENTARY PAGER
function documentaryPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/documentary-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// DEPORTES PAGER
function deportesPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/deportes-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// CULTURA PAGER
function culturaPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/cultura-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// NATURALEZA PAGER
function naturalezaPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/naturaleza-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// OCIO PAGER
function ocioPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/ocio-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// HISTORIA PAGER
function historiaPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/historia-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// LINKS PAGER
function linksPager(category_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/links-pager.php", 
					type: "POST", 
					data: "category_id="+category_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// RELATOS PAGER
function storiesPager(tourID, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/stories-pager.php", 
					type: "POST", 
					data: "tourID="+ tourID + "&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// ESPECIALES PAGER
function specialsPager(pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/specials-pager.php", 
					type: "POST", 
					data: "page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// CITIES VIDEOS
function videoShow(id) {
	$.ajax({
		url: "scripts/cities-videos.php", 
		type: "POST", 
		data: "id="+id, 
		dataType: "html", 
		success: function(html) {
			if (html) {				
				htmlArray = html.split('{-SEP-}');
				
				$("#CITIES_VIDEO_title").html(htmlArray[2]);
				$("#CITIES_VIDEO_name").html(htmlArray[3]);
				$("#CITIES_VIDEO_email").html(htmlArray[4]);
				
				var url = htmlArray[0];
				var image = htmlArray[1];
				var obj = {file: url, image: image};
				thisMovie('vids').sendEvent("LOAD",obj);
				
				// TARGET
				window.location.href = window.location.href.replace(/#video/g, '')+'#video';
			}
		}
	});
}

// COMARCA VIDEOS
function videoComarcaShow(id) {	
	$.ajax({
		url: "scripts/comarcas-videos.php", 
		type: "POST", 
		data: "id="+id, 
		dataType: "html", 
		success: function(html) {
			if (html) {				
				htmlArray = html.split('{-SEP-}');
				
				$("#COMARCAS_VIDEO_title").html(htmlArray[2]);
				$("#COMARCAS_VIDEO_name").html(htmlArray[3]);
				$("#COMARCAS_VIDEO_email").html(htmlArray[4]);
				
				var url = htmlArray[0];
				var image = htmlArray[1];
				var obj = {file: url, image: image};
				thisMovie('vids').sendEvent("LOAD",obj);
				
				// TARGET
				window.location.href = window.location.href.replace(/#video/g, '')+'#video';
			}
		}
	});
}


function COMARCAS_VIDEOS_Submit() {
	// CHECK FIELDS
	var comarca_id = $("#comarca_id").val();
	var complete_name = $("#complete_name").val();
	var email = $("#email").val();
	var title = $("#title").val();
	var video_upload = $("#video_upload").val();
	
	$("#COMARCAS_VIDEOS_form").fadeOut('fast', function() {
		$("#COMARCAS_VIDEOS_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/comarcas-videos-send.php", 
				type: "POST", 
				data: "comarca_id="+comarca_id+"&complete_name="+complete_name+"&email="+email+"&title="+title+"&video_upload="+video_upload, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#COMARCAS_VIDEOS_processing").fadeOut('fast', function() {
							$("#COMARCAS_VIDEOS_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#COMARCAS_VIDEOS_errors_description").html(htmlArray[1]);
							$("#COMARCAS_VIDEOS_errors").show();
						});
					}else{
						$("#COMARCAS_VIDEOS_processing").hide('fast', function() {
							$("#COMARCAS_VIDEOS_processed").show('fast');
						});
					}
				}
			});
		});
	});
}


function CITIES_VIDEOS_Submit() {
	// CHECK FIELDS
	var city_id = $("#city_id").val();
	var complete_name = $("#complete_name").val();
	var email = $("#email").val();
	var title = $("#title").val();
	var video_upload = $("#video_upload").val();
	
	$("#CITIES_VIDEOS_form").fadeOut('fast', function() {
		$("#CITIES_VIDEOS_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/cities-videos-send.php", 
				type: "POST", 
				data: "city_id="+city_id+"&complete_name="+complete_name+"&email="+email+"&title="+title+"&video_upload="+video_upload, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#CITIES_VIDEOS_processing").fadeOut('fast', function() {
							$("#CITIES_VIDEOS_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#CITIES_VIDEOS_errors_description").html(htmlArray[1]);
							$("#CITIES_VIDEOS_errors").show();
						});
					}else{
						$("#CITIES_VIDEOS_processing").hide('fast', function() {
							$("#CITIES_VIDEOS_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

function CITIES_VIDEOS_Submit() {
	// CHECK FIELDS
	var city_id = $("#city_id").val();
	var complete_name = $("#complete_name").val();
	var email = $("#email").val();
	var title = $("#title").val();
	var video_upload = $("#video_upload").val();
	
	$("#CITIES_VIDEOS_form").fadeOut('fast', function() {
		$("#CITIES_VIDEOS_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/cities-videos-send.php", 
				type: "POST", 
				data: "city_id="+city_id+"&complete_name="+complete_name+"&email="+email+"&title="+title+"&video_upload="+video_upload, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#CITIES_VIDEOS_processing").fadeOut('fast', function() {
							$("#CITIES_VIDEOS_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#CITIES_VIDEOS_errors_description").html(htmlArray[1]);
							$("#CITIES_VIDEOS_errors").show();
						});
					}else{
						$("#CITIES_VIDEOS_processing").hide('fast', function() {
							$("#CITIES_VIDEOS_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

function thisMovie(swf) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[swf];
	} else {
		return document[swf];
	}
}
function sendEvent(swf,typ,prm) { 
  	thisMovie(swf).sendEvent(typ,prm); 
}

// COMARCAS SEND VIDEO
function COMARCAS_VIDEOS_show() {
	if ($("#COMARCAS_VIDEOS_mainDiv").is(':hidden')) {
		$("#COMARCAS_VIDEOS_text").hide('fast', function() {
			$("#COMARCAS_VIDEOS_mainDiv").show('fast');
		});
	}else{
		$("#COMARCAS_VIDEOS_mainDiv").hide('fast', function() {
			$("#COMARCAS_VIDEOS_text").show('fast');
		});
	}
}

// CITIES SEND VIDEO
function CITIES_VIDEOS_show() {
	if ($("#CITIES_VIDEOS_mainDiv").is(':hidden')) {
		$("#CITIES_VIDEOS_text").hide('fast', function() {
			$("#CITIES_VIDEOS_mainDiv").show('fast');
		});
	}else{
		$("#CITIES_VIDEOS_mainDiv").hide('fast', function() {
			$("#CITIES_VIDEOS_text").show('fast');
		});
	}
}

// COMPANIES NEWS PAGER
function companiesNewsPager(company_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/companies-news-pager.php", 
					type: "POST", 
					data: "company_id="+company_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// HOTELS NEWS PAGER
function hotelsNewsPager(hotel_id, pagesField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+pagesField).fadeOut('slow', function() {
			$("#"+pagesField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/hotels-news-pager.php", 
					type: "POST", 
					data: "hotel_id="+hotel_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+pagesField).html(html);
						$("#"+pagesField+"_loading").hide('fast', function() {
							$("#"+pagesField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// COMPANIES CONTACT
function COMPANIES_CONTACT_Submit() {
	// CHECK FIELDS
	var complete_name = $("#complete_name").val();
	var email = $("#email").val();
	var comments = $("#comments").val();
	var company_id = $("#company_id").val();
	
	$("#COMPANIES_CONTACT_form").fadeOut('fast', function() {
		$("#COMPANIES_CONTACT_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/companies-contact.php", 
				type: "POST", 
				data: "company_id="+company_id+"&complete_name="+complete_name+"&email="+email+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#COMPANIES_CONTACT_processing").fadeOut('fast', function() {
							$("#COMPANIES_CONTACT_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#COMPANIES_CONTACT_errors_description").html(htmlArray[1]);
							$("#COMPANIES_CONTACT_errors").show();
						});
					}else{
						$("#COMPANIES_CONTACT_processing").hide('fast', function() {
							$("#COMPANIES_CONTACT_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

// HOTELS CONTACT
function HOTELS_CONTACT_Submit() {
	// CHECK FIELDS
	var complete_name = $("#complete_name").val();
	var email = $("#email").val();
	var comments = $("#comments").val();
	var hotel_id = $("#hotel_id").val();
	
	$("#HOTELS_CONTACT_form").fadeOut('fast', function() {
		$("#HOTELS_CONTACT_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/hotels-contact.php", 
				type: "POST", 
				data: "hotel_id="+hotel_id+"&complete_name="+complete_name+"&email="+email+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#HOTELS_CONTACT_processing").fadeOut('fast', function() {
							$("#HOTELS_CONTACT_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#HOTELS_CONTACT_errors_description").html(htmlArray[1]);
							$("#HOTELS_CONTACT_errors").show();
						});
					}else{
						$("#HOTELS_CONTACT_processing").hide('fast', function() {
							$("#HOTELS_CONTACT_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

// HUESCA GUESTBOOK
function HUESCA_GUESTBOOK_Submit() {
	var name = $("#name").val();
	var email = $("#email").val();
	var country_id = $("#country_id").val();
	var comments = $("#comments").val();
	
	$("#HUESCA_GUESTBOOK_form").fadeOut('fast', function() {
		$("#HUESCA_GUESTBOOK_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/huesca-guestbook-send.php", 
				type: "POST", 
				data: "name="+name+"&email="+email+"&country_id="+country_id+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {					
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#HUESCA_GUESTBOOK_processing").fadeOut('fast', function() {
							$("#HUESCA_GUESTBOOK_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#HUESCA_GUESTBOOK_errors_description").html(htmlArray[1]);
							$("#HUESCA_GUESTBOOK_errors").show();
						});
					}else{
						$("#HUESCA_GUESTBOOK_processing").hide('fast', function() {
							$("#HUESCA_GUESTBOOK_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

// COMARCAS GUESTBOOK
function COMARCAS_GUESTBOOK_Submit() {
	var name = $("#name").val();
	var email = $("#email").val();
	var country_id = $("#country_id").val();
	var comments = $("#comments").val();
	var comarca_id = $("#comarca_id").val();
	
	$("#COMARCAS_GUESTBOOK_form").fadeOut('fast', function() {
		$("#COMARCAS_GUESTBOOK_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/comarcas-guestbook-send.php", 
				type: "POST", 
				data: "comarca_id="+comarca_id+"&name="+name+"&email="+email+"&country_id="+country_id+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#COMARCAS_GUESTBOOK_processing").fadeOut('fast', function() {
							$("#COMARCAS_GUESTBOOK_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#COMARCAS_GUESTBOOK_errors_description").html(htmlArray[1]);
							$("#COMARCAS_GUESTBOOK_errors").show();
						});
					}else{
						$("#COMARCAS_GUESTBOOK_processing").hide('fast', function() {
							$("#COMARCAS_GUESTBOOK_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

// CITIES GUESTBOOK
function CITIES_GUESTBOOK_Submit() {
	var name = $("#name").val();
	var email = $("#email").val();
	var country_id = $("#country_id").val();
	var comments = $("#comments").val();
	var city_id = $("#city_id").val();
	
	$("#CITIES_GUESTBOOK_form").fadeOut('fast', function() {
		$("#CITIES_GUESTBOOK_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/pueblos-guestbook-send.php", 
				type: "POST", 
				data: "city_id="+city_id+"&name="+name+"&email="+email+"&country_id="+country_id+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#CITIES_GUESTBOOK_processing").fadeOut('fast', function() {
							$("#CITIES_GUESTBOOK_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#CITIES_GUESTBOOK_errors_description").html(htmlArray[1]);
							$("#CITIES_GUESTBOOK_errors").show();
						});
					}else{
						$("#CITIES_GUESTBOOK_processing").hide('fast', function() {
							$("#CITIES_GUESTBOOK_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

// HOTELS GUESTBOOK
function HOTELS_GUESTBOOK_Submit() {
	var name = $("#name").val();
	var email = $("#email").val();
	var country_id = $("#country_id").val();
	var comments = $("#comments").val();
	var hotel_id = $("#hotel_id").val();
	
	$("#HOTELS_GUESTBOOK_form").fadeOut('fast', function() {
		$("#HOTELS_GUESTBOOK_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/hotels-guestbook-send.php", 
				type: "POST", 
				data: "hotel_id="+hotel_id+"&name="+name+"&email="+email+"&country_id="+country_id+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#HOTELS_GUESTBOOK_processing").fadeOut('fast', function() {
							$("#HOTELS_GUESTBOOK_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#HOTELS_GUESTBOOK_errors_description").html(htmlArray[1]);
							$("#HOTELS_GUESTBOOK_errors").show();
						});
					}else{
						$("#HOTELS_GUESTBOOK_processing").hide('fast', function() {
							$("#HOTELS_GUESTBOOK_processed").show('fast');
						});
					}
				}
			});
		});
	});
}

// NEWS COMMENTS PAGER
function contentPager(news_id, commentsField, pagerField, total, pageby, callback) {
	if ($("#"+pagerField).length) {
		$("#"+pagerField).pagination(total, {
			items_per_page: pageby, 
			next_text: "&raquo;", 
			prev_text: "&laquo;", 
			num_display_entries: 10, 
			callback: eval(callback)
		});
	}
	
	function pageselectCallback(page_id, jq) {
		$("#"+commentsField).fadeOut('slow', function() {
			$("#"+commentsField+"_loading").show('fast', function() {
				$.ajax({
					url: "scripts/news-comments-pager.php", 
					type: "POST", 
					data: "news_id="+news_id+"&page="+page_id, 
					dataType: "html", 
					success: function(html) {
						$("#"+commentsField).html(html);
						$("#"+commentsField+"_loading").hide('fast', function() {
							$("#"+commentsField).fadeIn('slow', function() {});
						});
					}
				});
			});
		});
	}
}

// NEWS RATING
function rateNews(id, rating) {
	$("#NEWS_rate").fadeOut('fast', function() {
		$("#NEWS_rating").fadeIn();
	});
	
	
	$.ajax({
		url: "scripts/news-rate.php", 
		type: "POST", 
		data: "news_id="+id+"&rating="+rating, 
		dataType: "html", 
		success: function(html) {
			$("#NEWS_rate").html(html);
			
			$("#NEWS_rating").fadeOut('fast', function() {
				$("#NEWS_rate").fadeIn();
				$('.vote').rating();
			});
		}
	});
}

// NEWS SEND COMMENTS
function NEWS_sendComments() {
	if ($("#NEWS_comments").is(':hidden')) {
		$("#NEWS_comments").show('fast', function() {});
	}else{
		$("#NEWS_comments").hide('fast', function() {});
	}
}

function NEWS_sendComments_Submit() {
	// CHECK FIELDS
	var complete_name = $("#COMMENTS_complete_name").val();
	var email = $("#COMMENTS_email").val();
	var website = $("#COMMENTS_website").val();
	var comments = $("#COMMENTS_comments").val();
	
	var news_id = $("#news_id").val();
	
	$("#NEWS_comments_form").fadeOut('fast', function() {
		$("#NEWS_comments_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/news-comments-send.php", 
				type: "POST", 
				data: "news_id="+news_id+"&complete_name="+complete_name+"&email="+email+"&website="+website+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#NEWS_comments_processing").fadeOut('fast', function() {
							$("#NEWS_comments_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#NEWS_comments_errors_description").html(htmlArray[1]);
							$("#NEWS_comments_errors").show();
						});
					}else{
						$("#NEWS_comments_processing").hide('fast', function() {
							$("#NEWS_comments_processed").show('fast');
							
							// MAKE IT DISSAPEAR
							setTimeout('$("#NEWS_comments").hide("fast", function() {}); $("#NEWS_comments_processed").hide("fast", function() { $("#NEWS_comments_form").show(); });', 4000);
						});
					}
				}
			});
		});
	});
}


// NEWS SEND TO FRIEND
function NEWS_sendFriend() {
	if ($("#NEWS_friend").is(':hidden')) {
		$("#NEWS_friend").show('fast', function() {});
	}else{
		$("#NEWS_friend").hide('fast', function() {});
	}
}

function NEWS_sendFriend_Submit() {
	// CHECK FIELDS
	var from_name = $("#from_name").val();
	var from_email = $("#from_email").val();
	var to_email = $("#to_email").val();
	var comments = $("#comments").val();
	var news_id = $("#news_id").val();
	
	$("#NEWS_friend_form").fadeOut('fast', function() {
		$("#NEWS_friend_processing").fadeIn('fast', function() {
			$.ajax({
				url: "scripts/news-friend-send.php", 
				type: "POST", 
				data: "news_id="+news_id+"&from_name="+from_name+"&from_email="+from_email+"&to_email="+to_email+"&comments="+comments, 
				dataType: "html", 
				success: function(html) {
					htmlArray = html.split('{-SEP-}');
					
					if (htmlArray[0] == '0') {
						$("#NEWS_friend_processing").fadeOut('fast', function() {
							$("#NEWS_friend_form").fadeIn('fast', function() {});
						
							// DISPLAY ERROR
							$("#NEWS_friend_errors_description").html(htmlArray[1]);
							$("#NEWS_friend_errors").show();
						});
					}else{
						$("#NEWS_friend_processing").hide('fast', function() {
							$("#NEWS_friend_processed").show('fast');
							
							// MAKE IT DISSAPEAR
							setTimeout('$("#NEWS_friend").hide("fast", function() {}); $("#NEWS_friend_processed").hide("fast", function() { $("#NEWS_friend_form").show(); });', 4000);
						});
					}
				}
			});
		});
	});
}

function changeImage(src) {
	var img = new Image();
	
	$("#main_image").fadeOut("fast", function() {
		$("#loading\\[0\\]").fadeIn("slow", function() {
			$("#main_image").attr("src", src);
			if ($("#main_image_link").length) $("#main_image_link").attr("href", src.replace(/_m/g, ''));
			
			img.onload = function() {
				$("#loading\\[0\\]").fadeOut("slow", function() {
					$("#main_image").show();
				});
			}
			
			img.src = src;
		});
	});
}

/* GOOGLE MAPS API */
var center = null;
var map = null;
var geocoder = null;

function GMAPS_initialize() {
	lat = parseFloat($("#map\\[lat\\]").val());
	lon = parseFloat($("#map\\[lon\\]").val());
	zoom = parseFloat($("#map\\[zoom\\]").val());
	title = $("#map\\[title\\]").val();
	
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		// map.checkResize();
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		map.setCenter(new GLatLng(lat, lon), zoom);
		
		center = map.getCenter();
		
		marker = new GMarker(center);
		
		map.addOverlay(marker);
	}
}


function disableSubmit(form) {
	form.button.disabled = true;
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
