function popup(url,divname, w, h) {
	// w & h are not used, deprecated of previous 'popup' function
	myDial = $("#"+divname);
	myDial.load(url, function() {
		$(this).dialog({
			modal:true,
			bgiframe: true,
			height: w,
			width: h,
			resizeable: true,
			buttons: {
				"Close": function() { $(this).dialog("close"); }
			}
		});
	});
	return false;
}
function select_value(select,value){
	for(i=0;i<select.options.length;i++){
		if(select.options[i].value==value){
			select.options[i].selected=true;
			return true;
		}
	}
	return false;
}

function DisplayMsg(myMsg, boxid, timeout)
{
	myBox = $('#'+boxid);
	if (myMsg.length > 1)
	{
		// check in which element should we write the message
		if (myBox.children("p").length) {
			textin = myBox.children("p");
		}
		else { 
			textin = myBox; // if no <p> child, then write into the div box itself
		}
		textin.html(myMsg);
	}
	// show div
	myBox.show('blind',{},700,callback);
		
//	callback function to bring a hidden box back
	function callback(){
		if (timeout > 1) {
			setTimeout(function(){
				myBox.hide(800).fadeOut(900);
			}, timeout);
		}
	};
	
	return false;
}

function clearMsg(boxid) {
	$('#'+boxid).hide();
}

function DisplayMsg2(myMsg, boxid)
{
	if (document.getElementById)
	{
		document.getElementById(boxid).innerHTML = myMsg;
		document.getElementById(boxid).style.display = '';
	}
	else if (document.all)
	{
		document.all[boxid].innerHTML = myMsg;
		document.getElementById(boxid).style.display = '';
	}
}

function clearMsg2(boxid) {
	clearMsg(boxid);
}	

function showInfo(mybox) {
	//get the position of the placeholder input
	var pos = mybox.offset();  
	var width = mybox.width();
	var tickbox = mybox.next("span.hint");
	tickbox.css( { "left": (pos.left + width + 2) + "px", "top":(pos.top - 9) + "px"} );
	tickbox.fadeIn(200);
	setTimeout(function(){
				tickbox.fadeOut(700);
			}, 5500);
}
function hideInfo(mybox) {
	mybox.next("span.hint").fadeOut(600);
}
function loadMobilePhoto(id, modelName, brandName, size)
{
	$('#modelPicture').fadeTo("fast", 0.33);
	// Set image source
	if (id==0 && modelName=='' && brandName=='') {
		var src = "/img/shared/phone_nopict.jpg";
		$('#modelPicture').attr("src", src);
	}
	else {
		var src = "/pict/" + size + "-" + brandName + "-" + modelName + "-" + id + ".jpg";
		var title = brandName + " " + modelName;
		$('#modelPicture').attr("src", src);
		$('#modelPicture').attr("alt", title);
		$('#modelPicture').attr("title", title);
		$('#modelPicture').fadeTo("slow", 1);
	}
}