function LmOver(elem)
{elem.style.backgroundColor = "#FFFFFF";
elem.style.border = "1px solid #e6e6e6";}

function LmOut(elem)
{elem.style.backgroundColor = "";
elem.style.border = "0px solid #e6e6e6";}

function create_order(account_id, item_id)
{
  	dummyimage = new Image();
  	
  	dummyimage.src = "/points.php?account_id=" + account_id + "&item_id=" + item_id;
	alert(dummyimage.src);
}


function get_jpeg_filename(filename)
{
	var myfilename = filename;
	var fname=myfilename.split("\\");
	document.all.filename.value=fname[fname.length-1];
}

function valid_diagram_format(file)
{
	var filename = file.value;
	filename = filename.toLowerCase();
	
	var fname = filename.split("\\");
	
	filename = fname[fname.length-1];
	fname = filename.split(".");
	
	if(fname[fname.length-1] == "3ds" || fname[fname.length-1] == "dwg" || fname[fname.length-1] == "dxf")
	{
		//document.all.format.value=fformat[fformat.length-1];
	}
	else
	{
		alert("Formato no Válido !!!");
		reset_input_file(file);
	}
}

function valid_max_upload_image_diagram(file,msg_error_format_image,qty_image,msg_error_max_upload_image)
{
	if(parseInt(qty_image) > 4)
	{
		alert(msg_error_max_upload_image);
		reset_input_file(file);
	}
	else
	{
		valid_image_format(file,msg_error_format_image);
	}
}

function valid_image_format(file,msg_error_format_image)
{
	var filename = file.value;
	filename = filename.toLowerCase();
	
	var fname = filename.split("\\");
	
	filename = fname[fname.length-1];
	fname = filename.split(".");
	
	if(fname[fname.length-1] == "jpg")
	{
		//document.all.format.value=fformat[fformat.length-1];
	}
	else
	{
		alert(msg_error_format_image);
		reset_input_file(file);
	}
}

function reset_input_file(file)
{
	file.form.reset();
	file.focus();
}
	
function get_filename(filename)
{
	var myfilename = filename.toLowerCase(); 
	var fname=myfilename.split("\\");
	document.all.filename.value=fname[fname.length-1];
	var fformat=myfilename.split(".");
	
	if(fformat[fformat.length-1] == "3ds" || fformat[fformat.length-1] == "dwg" || 
	fformat[fformat.length-1] == "dxf" || fformat[fformat.length-1] == "gif" ||
	fformat[fformat.length-1] == "jpg" || fformat[fformat.length-1] == "max" ||
	fformat[fformat.length-1] == "pat" || fformat[fformat.length-1] == "rpc")
	{
		document.all.format.value=fformat[fformat.length-1];
	}else{
		alert("Formato no Válido !!!");
		document.all.filename.value="";
		document.all.format.value="";
	}
}

function DisplayNext(url) 
{
	location.replace(url);
}


/* Open a popup window with a picture send as a parameter, windows is openned with the picture size */
function PopupPic(sPicURL,widthx, heighty, topx,lefty,toolbarYN) 
{
	window.open("/popuppicture.php?"+sPicURL,"",'toolbar='+ toolbarYN + ',location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + widthx + ',height=' + heighty + ',screenX=100,screenY=100,top=' + topx + ',left=' + lefty + "'");
}
/* Open a popup window with a URL send as a parameter, windows is openned width=widthx, height=heighty, and from top=topx, left=lefty  */
function popupWindow(url,widthx, heighty, topx,lefty,toolbarYN) 
{
	windowHandle = window.open(url,"",'toolbar='+ toolbarYN + ',location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + widthx + ',height=' + heighty + ',screenX=100,screenY=100,top=' + topx + ',left=' + lefty + "'");
}


function SubmitForm(actiontxt)
{
	document.pictures.action = actiontxt;
	pictures.submit();
}	

function starttime() 
{ 
	var starttime 
	starttime=new Date()
	starttime=starttime.getTime() 
	countdown(starttime) 
} 

function countdown(starttime) 
{ 
	var nowtime 
	var reloadseconds=0 
	var secondssinceloaded=0 
	var refreshinterval=10
	var displaycountdown="no" 
	nowtime= new Date() 
	nowtime=nowtime.getTime() 
	secondssinceloaded=(nowtime-starttime)/3000 
	reloadseconds=Math.round(refreshinterval-secondssinceloaded) 
	if (refreshinterval>=secondssinceloaded) 
	{ 
		var timer=setTimeout("countdown(starttime)",3000) 
		if (displaycountdown=="yes") 
		{ 
			window.status="Page refreshing in "+reloadseconds+ " seconds" 
		} 
	} 
	else 
	{ 
		clearTimeout(timer)
		var xcat = Math.floor(Math.random()*5)
		showLastFile(1, parameters[2],xcat);
		starttime();
	} 
} 

function selectedAll(form,checkbox)
{
	for(var i=0; i < document.forms[form].elements[checkbox + "[]"].length; i++)
	{
		document.forms[form].elements[checkbox + "[]"][i].checked = 1;
	}
}

function deselectedAll(form,checkbox)
{
	for(var i=0; i < document.forms[form].elements[checkbox + "[]"].length; i++)
	{
		document.forms[form].elements[checkbox + "[]"][i].checked = 0;
	}
}
